From gitlab at gitlab.haskell.org Fri Mar 1 00:13:31 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 29 Feb 2024 19:13:31 -0500 Subject: [Git][ghc/ghc][wip/T24359] More progress Message-ID: <65e11dab5e7f1_1da9522c24190972ae@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: e7a4ac08 by Simon Peyton Jones at 2024-03-01T00:12:31+00:00 More progress - - - - - 2 changed files: - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Gen/Sig.hs Changes: ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -844,7 +844,9 @@ finishSpecPrag :: Maybe CoreExpr -- See the first param of dsSpec -> CoreExpr -- LHS pattern -> InlinePragma -> DsM (Maybe (OrdList (Id,CoreExpr), CoreRule)) -finishSpecPrag mb_poly_rhs spec_bndrs rule_lhs spec_inl +finishSpecPrag mb_poly_rhs rule_bndrs rule_lhs + spec_bndrs spec_bindsno + spec_inl = do { dflags <- getDynFlags ; case decomposeRuleLhs dflags spec_bndrs rule_lhs (mkVarSet spec_bndrs) of { Left msg -> do { diagnosticDs msg; return Nothing } ; ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -823,9 +823,10 @@ We want to generate: RULE forall @a d1 d2 d3 x xs. f @Int @p @p (d1::Eq p) (d2::Eq p) (d3::Ord Int) y y True = $sf @p d1 y - $sf @p (d1::Eq p) (y::p) - = let d3 = $fOrdInt - d2 = d1 + $sf @p (dx::Eq p) (y::p) + = let d1 = dx + d2 = dx + d3 = $fOrdInt in @p @p @Int (d1::Eq p) (d2::Eq p) (d3::OrdInt) y y True Note that @@ -843,7 +844,8 @@ Note that -} tcSpecPrag _poly_id (SpecSigE nm bndrs spec_e inl) - = do { skol_info <- mkSkolemInfo (SpecESkol nm) + = do { let skol_info_anon = SpecESkol nm + ; skol_info <- mkSkolemInfo skol_info_anon ; (tc_lvl, wanted, (id_bndrs, spec_e', rho)) <- pushLevelAndCaptureConstraints $ do { (tv_bndrs, id_bndrs) <- tcRuleBndrs skol_info bndrs @@ -858,36 +860,48 @@ tcSpecPrag _poly_id (SpecSigE nm bndrs spec_e inl) -- Apply the unifications ; seed_tys <- liftZonkM (mapM zonkTcType (rho : map idType id_bndrs)) + -- Quantify ; let (quant_cts, residual_wanted) = getRuleQuantCts wanted quant_preds = ctsPreds quant_cts - + quant_wc = mkSimpleWC quant_cts ; dvs <- candidateQTyVarsOfTypes (quant_preds ++ seed_tys) ; let grown_tcvs = growThetaTyVars quant_preds (tyCoVarsOfTypes seed_tys) ; weeded_dvs = weedOutCandidates (`dVarSetIntersectVarSet` grown_tcvs) dvs - ; skol_info <- mkSkolemInfo (SpecESkol nm) ; qtkvs <- quantifyTyVars skol_info DefaultNonStandardTyVars weeded_dvs - ; bound_evs <- mk_quant_evs quant_cts - ; (implic, ev_binds) <- buildImplicationFor tc_lvl (getSkolemInfo skol_info) - qtkvs bound_evs residual_wanted - ; emitImplications implic - ; spec_binds_var <- newTcEvBinds - ; spec_cts <- setTcLevel tc_lvl $ - runTcSWithEvBinds spec_binds_var $ - solveWanteds (mkSimpleWC quant_cts) + -- Left hand side of the RULE + ; rule_evs <- mk_quant_evs quant_cts + ; (implic1, lhs_binds) <- buildImplicationFor tc_lvl skol_info_anon + qtkvs rule_evs residual_wanted + ; let lhs_expr = mkHsDictLet lhs_binds spec_e' + + -- Right hand side of the RULE + ; (spec_cts, _) <- setTcLevel tc_lvl $ runTcS $ + solveWanteds quant_wc + + -- No need to zonk; any unifications have happened already + ; let min_spec_cts :: [Ct] + min_spec_cts = mkMinimalBySCs ctPred $ + bagToList $ + approximateWC True spec_cts - ; spec_evs <- mk_quant_evs spec_cts + -- rhs_binds uses spec_evs to build rule_evs + ; spec_evs < mapM (newEvVar . ctPred) min_spec_cts + ; (implic2, rhs_binds) <- buildImplicationFor tc_lvl skol_info_anon + qtkvs spec_evs quant_wc + + ; emitImplications (implic1 `unionBags` implic2) - ; let bndrs' = mkTcRuleBndrs bndrs (qtkvs ++ bound_evs ++ id_bndrs) - lhs_expr = mkHsDictLet ev_binds spec_e' ; traceTc "tcSpecPrag:SpecSigE" $ vcat [ text "bndrs:" <+> ppr bndrs' , text "full_e:" <+> ppr full_e' , text "inl:" <+> ppr inl ] - ; return [SpecPragE (qtkvs ++ bound_evs ++ id_bndrs) lhs_expr - (qtkvs ++ spec_evs ++ id_bndrs) (TcEvBinds spec_binds_var) - inl] } - + ; return [SpecPragE { spe_bndrs = qtkvs ++ rule_evs ++ id_bndrs + , spe_lhs = lhs_expr + , spe_rhs = map ctEvTerm min_spec_cst + , spe_spec_bndrs = qtkvs ++ spec_evs ++ id_bndrs + , spe_spec_binds = rhs_binds + , spe_inl = inl }] } tcSpecPrag _ prag = pprPanic "tcSpecPrag" (ppr prag) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e7a4ac08bda1d7ec174a5e735861c3e26325480a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e7a4ac08bda1d7ec174a5e735861c3e26325480a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 00:32:46 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 29 Feb 2024 19:32:46 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/fma_globals Message-ID: <65e1222e445ac_1da952368b944989fb@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/fma_globals You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 01:39:23 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 29 Feb 2024 20:39:23 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] x86-ncg: Fix fma codegen when arguments are globals. Message-ID: <65e131caeb819_1da952543aa0810112b@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: c24db25d by Andreas Klebinger at 2024-03-01T02:25:33+01:00 x86-ncg: Fix fma codegen when arguments are globals. Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 3 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - + testsuite/tests/primops/should_run/T24496.hs - testsuite/tests/primops/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3424,6 +3424,7 @@ genFMA3Code :: Width -> FMASign -> CmmExpr -> CmmExpr -> CmmExpr -> NatM Register genFMA3Code w signs x y z = do + -- platform <- getPlatform -- For the FMA instruction, we want to compute x * y + z -- @@ -3445,17 +3446,41 @@ genFMA3Code w signs x y z = do -- -- Currently we follow neither of these optimisations, -- opting to always use fmadd213 for simplicity. + -- + let rep = floatFormat w (y_reg, y_code) <- getNonClobberedReg y - (z_reg, z_code) <- getNonClobberedReg z + (z_op, z_code) <- getNonClobberedOperand z x_code <- getAnyReg x + x_tmp <- getNewRegNat rep let - fma213 = FMA3 rep signs FMA213 - code dst - = y_code `appOL` + code, code_direct, code_mov :: Reg -> InstrBlock + -- Ideal: Compute the result directly into dst + code_direct dst = x_code dst `snocOL` + fma213 z_op y_reg dst + -- Fallback: Compute the result into a tmp reg and then move it. + code_mov dst = x_code x_tmp `snocOL` + fma213 z_op y_reg x_tmp `snocOL` + MOV rep (OpReg x_tmp) (OpReg dst) + + code dst = + y_code `appOL` z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_reg dst + ( if arg_regs_conflict then code_mov dst else code_direct dst ) + + where + -- We would like to compute `x` into `dst`, however if `dst` overlapps + -- with the other arguments we would produce garbage. See #24496 + arg_regs_conflict = + y_reg == dst || + case z_op of + OpReg z_reg -> z_reg == dst + OpAddr amode -> dst `elem` addrModeRegs amode + OpImm {} -> False + + + -- NB: Computing the result into a desired register using Any can be tricky. + -- So for now keep it simple. (See #24496). return (Any rep code) ----------- ===================================== testsuite/tests/primops/should_run/T24496.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) +{-# NOINLINE twoProductFloat# #-} + +twoProductDouble# :: Double# -> Double# -> (# Double#, Double# #) +twoProductDouble# x y = let !r = x *## y + in (# r, fmsubDouble# x y r #) +{-# NOINLINE twoProductDouble# #-} + +main :: IO () +main = do + print $ case twoProductFloat# 2.0# 3.0# of (# r, s #) -> (F# r, F# s) + print $ case twoProductDouble# 2.0## 3.0## of (# r, s #) -> (D# r, D# s) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,3 +77,11 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) +test('T24496', normal, compile_and_run, ['']) +test('T24496' + , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) + , js_skip # JS backend doesn't have an FMA implementation + , when(arch('wasm32'), skip) + , when(have_llvm(), extra_ways(["optllvm"])) + ] + , compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c24db25d1c178352e57fa6ae797ab317e0cdfaf8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c24db25d1c178352e57fa6ae797ab317e0cdfaf8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 01:44:10 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 29 Feb 2024 20:44:10 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] x86-ncg: Fix fma codegen when arguments are globals. Message-ID: <65e132ea1cf1c_1da952552b5981016f8@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: 8e1b0f2c by Andreas Klebinger at 2024-03-01T02:31:03+01:00 x86-ncg: Fix fma codegen when arguments are globals. Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 3 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - + testsuite/tests/primops/should_run/T24496.hs - testsuite/tests/primops/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3424,6 +3424,7 @@ genFMA3Code :: Width -> FMASign -> CmmExpr -> CmmExpr -> CmmExpr -> NatM Register genFMA3Code w signs x y z = do + -- platform <- getPlatform -- For the FMA instruction, we want to compute x * y + z -- @@ -3445,17 +3446,44 @@ genFMA3Code w signs x y z = do -- -- Currently we follow neither of these optimisations, -- opting to always use fmadd213 for simplicity. + -- + -- We would like to compute the result directly into the requested register. + -- To do so we must first compute `x` into the destination register. This is + -- only possible if the other arguments don't use the destination register. + -- We check for this and if there is a conflict we move the result only after + -- the computation. See #24496 how this went wrong in the past. let rep = floatFormat w (y_reg, y_code) <- getNonClobberedReg y - (z_reg, z_code) <- getNonClobberedReg z + (z_op, z_code) <- getNonClobberedOperand z x_code <- getAnyReg x + x_tmp <- getNewRegNat rep let - fma213 = FMA3 rep signs FMA213 - code dst - = y_code `appOL` + code, code_direct, code_mov :: Reg -> InstrBlock + -- Ideal: Compute the result directly into dst + code_direct dst = x_code dst `snocOL` + fma213 z_op y_reg dst + -- Fallback: Compute the result into a tmp reg and then move it. + code_mov dst = x_code x_tmp `snocOL` + fma213 z_op y_reg x_tmp `snocOL` + MOV rep (OpReg x_tmp) (OpReg dst) + + code dst = + y_code `appOL` z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_reg dst + ( if arg_regs_conflict then code_mov dst else code_direct dst ) + + where + + arg_regs_conflict = + y_reg == dst || + case z_op of + OpReg z_reg -> z_reg == dst + OpAddr amode -> dst `elem` addrModeRegs amode + OpImm {} -> False + + + -- NB: Computing the result into a desired register using Any can be tricky. + -- So for now keep it simple. (See #24496). return (Any rep code) ----------- ===================================== testsuite/tests/primops/should_run/T24496.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) +{-# NOINLINE twoProductFloat# #-} + +twoProductDouble# :: Double# -> Double# -> (# Double#, Double# #) +twoProductDouble# x y = let !r = x *## y + in (# r, fmsubDouble# x y r #) +{-# NOINLINE twoProductDouble# #-} + +main :: IO () +main = do + print $ case twoProductFloat# 2.0# 3.0# of (# r, s #) -> (F# r, F# s) + print $ case twoProductDouble# 2.0## 3.0## of (# r, s #) -> (D# r, D# s) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,3 +77,11 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) +test('T24496', normal, compile_and_run, ['']) +test('T24496' + , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) + , js_skip # JS backend doesn't have an FMA implementation + , when(arch('wasm32'), skip) + , when(have_llvm(), extra_ways(["optllvm"])) + ] + , compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e1b0f2cd214f57bdd7320e78c8fddd8c3631120 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e1b0f2cd214f57bdd7320e78c8fddd8c3631120 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 02:26:18 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 29 Feb 2024 21:26:18 -0500 Subject: [Git][ghc/ghc][master] testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e13cca6e51e_1da9526710880109196@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 4 changed files: - compiler/GHC/Iface/Ext/Utils.hs - testsuite/tests/hiefile/should_run/T23540.stdout - testsuite/tests/hiefile/should_run/TestUtils.hs - testsuite/tests/hiefile/should_run/all.T Changes: ===================================== compiler/GHC/Iface/Ext/Utils.hs ===================================== @@ -107,7 +107,13 @@ data EvidenceInfo a , evidenceSpan :: RealSrcSpan , evidenceType :: a , evidenceDetails :: Maybe (EvVarSource, Scope, Maybe Span) - } deriving (Eq,Ord,Functor) + } deriving (Eq, Functor) + +instance Ord a => Ord (EvidenceInfo a) where + compare (EvidenceInfo name span typ dets) (EvidenceInfo name' span' typ' dets') = + case stableNameCmp name name' of + EQ -> compare (span, typ, dets) (span', typ', dets') + r -> r instance (Outputable a) => Outputable (EvidenceInfo a) where ppr (EvidenceInfo name span typ dets) = ===================================== testsuite/tests/hiefile/should_run/T23540.stdout ===================================== @@ -124,35 +124,35 @@ At point (49,14), we found: At point (61,7), we found: ========================== ┌ -│ $dFunctor at T23540.hs:1:1, of type: Functor Identity' -│ is an evidence variable bound by a let, depending on: [$fFunctorIdentity'] +│ $dApplicative at T23540.hs:1:1, of type: Applicative Identity' +│ is an evidence variable bound by a let, depending on: [$fApplicativeIdentity'] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fFunctorIdentity' at T23540.hs:54:10-26, of type: Functor Identity' - │ is an evidence variable bound by an instance of class Functor + │ $fApplicativeIdentity' at T23540.hs:56:10-30, of type: Applicative Identity' + │ is an evidence variable bound by an instance of class Applicative │ with scope: ModuleScope │ - │ Defined at T23540.hs:54:10 + │ Defined at T23540.hs:56:10 └ ┌ -│ $dApplicative at T23540.hs:1:1, of type: Applicative Identity' -│ is an evidence variable bound by a let, depending on: [$fApplicativeIdentity'] +│ $dFunctor at T23540.hs:1:1, of type: Functor Identity' +│ is an evidence variable bound by a let, depending on: [$fFunctorIdentity'] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fApplicativeIdentity' at T23540.hs:56:10-30, of type: Applicative Identity' - │ is an evidence variable bound by an instance of class Applicative + │ $fFunctorIdentity' at T23540.hs:54:10-26, of type: Functor Identity' + │ is an evidence variable bound by an instance of class Functor │ with scope: ModuleScope │ - │ Defined at T23540.hs:56:10 + │ Defined at T23540.hs:54:10 └ ========================== @@ -202,33 +202,34 @@ At point (69,4), we found: At point (82,6), we found: ========================== ┌ -│ $dOrd at T23540.hs:1:1, of type: Ord Modulo1 -│ is an evidence variable bound by a let, depending on: [$fOrdModulo1] +│ $dNum at T23540.hs:1:1, of type: Num Modulo1 +│ is an evidence variable bound by a let, depending on: [$fNumModulo1] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fOrdModulo1 at T23540.hs:8:35-37, of type: Ord Modulo1 - │ is an evidence variable bound by an instance of class Ord + │ $fNumModulo1 at T23540.hs:10:10-20, of type: Num Modulo1 + │ is an evidence variable bound by an instance of class Num │ with scope: ModuleScope │ - │ Defined at T23540.hs:8:35 + │ Defined at T23540.hs:10:10 └ ┌ -│ $dNum at T23540.hs:1:1, of type: Num Modulo1 -│ is an evidence variable bound by a let, depending on: [$fNumModulo1] +│ $dOrd at T23540.hs:1:1, of type: Ord Modulo1 +│ is an evidence variable bound by a let, depending on: [$fOrdModulo1] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fNumModulo1 at T23540.hs:10:10-20, of type: Num Modulo1 - │ is an evidence variable bound by an instance of class Num + │ $fOrdModulo1 at T23540.hs:8:35-37, of type: Ord Modulo1 + │ is an evidence variable bound by an instance of class Ord │ with scope: ModuleScope │ - │ Defined at T23540.hs:10:10 - └ \ No newline at end of file + │ Defined at T23540.hs:8:35 + └ + ===================================== testsuite/tests/hiefile/should_run/TestUtils.hs ===================================== @@ -10,6 +10,7 @@ module TestUtils ) where import System.Environment +import Data.List (sort) import Data.Tree import GHC.Types.Name.Cache import GHC.Types.SrcLoc @@ -20,13 +21,13 @@ import qualified GHC.Utils.Outputable as O import GHC.Iface.Ext.Binary import GHC.Iface.Ext.Types import GHC.Iface.Ext.Utils - + import GHC.Driver.Session import GHC.SysTools makeNc :: IO NameCache makeNc = initNameCache 'z' [] - + dynFlagsForPrinting :: String -> IO DynFlags dynFlagsForPrinting libdir = do systemSettings <- initSysTools libdir @@ -53,7 +54,7 @@ explainEv df hf refmap point = do putStrLn $ replicate 26 '=' putStr $ drawForest ptrees where - trees = getEvidenceTreesAtPoint hf refmap point + trees = sort $ getEvidenceTreesAtPoint hf refmap point ptrees = fmap (pprint . fmap expandType) <$> trees ===================================== testsuite/tests/hiefile/should_run/all.T ===================================== @@ -5,5 +5,5 @@ test('T23492', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUti test('RecordDotTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('SpliceTypes', [req_th, extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('HieVdq', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) -test('T23540', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs']), when(arch('i386'), fragile(24449))], compile_and_run, ['-package ghc -fwrite-ide-info']) +test('T23540', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('T23120', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3836a110577b5c9343915fd96c1b2c64217e0082 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3836a110577b5c9343915fd96c1b2c64217e0082 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 02:26:57 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 29 Feb 2024 21:26:57 -0500 Subject: [Git][ghc/ghc][master] Reduce AtomicModifyIORef increment count Message-ID: <65e13cf14b4ae_1da95269b70701122b1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2 changed files: - libraries/base/tests/AtomicModifyIORef.hs - libraries/base/tests/AtomicModifyIORef.stdout Changes: ===================================== libraries/base/tests/AtomicModifyIORef.hs ===================================== @@ -5,7 +5,7 @@ import Data.IORef main :: IO () main = do let nThreads = 10 - nIncrs = 10000000 + nIncrs = 10000 ref <- newIORef (42 :: Int) dones <- replicateM nThreads $ do ===================================== libraries/base/tests/AtomicModifyIORef.stdout ===================================== @@ -8,4 +8,4 @@ . . . -100000042 +100042 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/960c8d47f064644617a605b1225a18e9350be995 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/960c8d47f064644617a605b1225a18e9350be995 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 02:57:39 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 29 Feb 2024 21:57:39 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e144239d151_1da9527b8494c11585a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 3e18a9e3 by Matthew Pickering at 2024-02-29T21:57:23-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - 95683a46 by Matthew Pickering at 2024-02-29T21:57:23-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 223e8608 by Matthew Pickering at 2024-02-29T21:57:23-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - 2e1eabdc by Matthew Pickering at 2024-02-29T21:57:23-05:00 Bump minimum bootstrap version to 9.6 - - - - - 8b2fa205 by Matthew Pickering at 2024-02-29T21:57:23-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - bdb8d342 by Matthew Pickering at 2024-02-29T21:57:23-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - 14 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Iface/Ext/Utils.hs - configure.ac - hadrian/src/Rules/BinaryDist.hs - libraries/base/tests/AtomicModifyIORef.hs - libraries/base/tests/AtomicModifyIORef.stdout - testsuite/tests/hiefile/should_run/T23540.stdout - testsuite/tests/hiefile/should_run/TestUtils.hs - testsuite/tests/hiefile/should_run/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 08bdbb85d6711e4df23d97e1cbdb557fe752b0a4 + DOCKER_REV: 7f63b34ac87b85470eef9c668e9528e8e2f5b46a # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. @@ -101,8 +101,6 @@ workflow: # which versions of GHC to allow bootstrap with .bootstrap_matrix : &bootstrap_matrix matrix: - - GHC_VERSION: 9.4.8 - DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_4:$DOCKER_REV" - GHC_VERSION: 9.6.4 DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_6:$DOCKER_REV" - GHC_VERSION: 9.8.1 ===================================== .gitlab/ci.sh ===================================== @@ -151,6 +151,8 @@ function mingw_init() { # We always use mingw64 Python to avoid path length issues like #17483. export PYTHON="/mingw64/bin/python3" + # And need to use sphinx-build from the environment + export SPHINXBUILD="/mingw64/bin/sphinx-build.exe" } # This will contain GHC's local native toolchain @@ -305,7 +307,7 @@ function fetch_cabal() { fail "neither CABAL nor CABAL_INSTALL_VERSION are not set" fi - start_section "fetch GHC" + start_section "fetch cabal" case "$(uname)" in # N.B. Windows uses zip whereas all others use .tar.xz MSYS_*|MINGW*) @@ -332,7 +334,7 @@ function fetch_cabal() { mv cabal "$toolchain/bin" ;; esac - end_section "fetch GHC" + end_section "fetch cabal" fi } ===================================== .gitlab/darwin/nix/sources.json ===================================== @@ -12,15 +12,15 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { - "branch": "master", + "branch": "nixos-unstable", "description": "Nix Packages collection", "homepage": "", "owner": "nixos", "repo": "nixpkgs", - "rev": "ce1aa29621356706746c53e2d480da7c68f6c972", - "sha256": "sha256:1sbs3gi1nf4rcbmnw69fw0fpvb3qvlsa84hqimv78vkpd6xb0bgg", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "sha256": "1v9sy2i2dy3qksx4mf81gwzfl0jzpqccfkzq7fjxgq832f9d255i", "type": "tarball", - "url": "https://github.com/nixos/nixpkgs/archive/ce1aa29621356706746c53e2d480da7c68f6c972.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/73de017ef2d18a04ac4bfd0c02650007ccb31c2a.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -4,6 +4,7 @@ let sources = import ./nix/sources.nix; nixpkgsSrc = sources.nixpkgs; pkgs = import nixpkgsSrc { inherit system; }; + hostPkgs = import nixpkgsSrc { }; in let @@ -13,23 +14,26 @@ let targetTriple = pkgs.stdenv.targetPlatform.config; ghcBindists = let version = ghc.version; in { - aarch64-darwin = pkgs.fetchurl { + aarch64-darwin = hostPkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "sha256-tQUHsingxBizLktswGAoi6lJf92RKWLjsHB9CisANlg="; + sha256 = "sha256-c1GTMJf3/yiW/t4QL532EswD5JVlgA4getkfsxj4TaA="; }; - x86_64-darwin = pkgs.fetchurl { + x86_64-darwin = hostPkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "sha256-OjXjVe+ZODDCc/hqtihqqz6CX25TKI0ZgORzkR5O3pQ="; + sha256 = "sha256-LrYniMG0phsvyW6dhQC+3ompvzcxnwAe6GezEqqzoTQ="; }; + }; ghc = pkgs.stdenv.mkDerivation rec { - version = "9.4.4"; + # Using 9.6.2 because of #24050 + version = "9.6.2"; name = "ghc"; src = ghcBindists.${pkgs.stdenv.hostPlatform.system}; configureFlags = [ "CC=/usr/bin/clang" "CLANG=/usr/bin/clang" + "AR=/usr/bin/ar" "LLC=${llvm}/bin/llc" "OPT=${llvm}/bin/opt" "CONF_CC_OPTS_STAGE2=--target=${targetTriple}" @@ -92,7 +96,7 @@ let }; fonts = with pkgs; makeFontsConf { fontDirectories = [ dejavu_fonts ]; }; - llvm = pkgs.llvm_11; + llvm = pkgs.llvm_15; in pkgs.writeTextFile { name = "toolchain"; ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -397,8 +397,8 @@ opsysVariables _ FreeBSD13 = mconcat -- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" , "HADRIAN_ARGS" =: "--docs=no-sphinx" - , "GHC_VERSION" =: "9.4.3" - , "CABAL_INSTALL_VERSION" =: "3.8.1.0" + , "GHC_VERSION" =: "9.6.4" + , "CABAL_INSTALL_VERSION" =: "3.10.2.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -407,7 +407,7 @@ opsysVariables AArch64 (Darwin {}) = , "LANG" =: "en_US.UTF-8" , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi" -- Fonts can't be installed on darwin - , "HADRIAN_ARGS" =: "--docs=no-sphinx" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" ] opsysVariables Amd64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "x86_64-darwin" @@ -421,22 +421,21 @@ opsysVariables Amd64 (Darwin {}) = , "LANG" =: "en_US.UTF-8" , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi" -- Fonts can't be installed on darwin - , "HADRIAN_ARGS" =: "--docs=no-sphinx" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" ] opsysVariables _ (Windows {}) = mconcat [ "MSYSTEM" =: "CLANG64" - , "HADRIAN_ARGS" =: "--docs=no-sphinx" , "LANG" =: "en_US.UTF-8" - , "CABAL_INSTALL_VERSION" =: "3.8.1.0" - , "GHC_VERSION" =: "9.4.3" ] + , "CABAL_INSTALL_VERSION" =: "3.10.2.0" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" + , "GHC_VERSION" =: "9.6.4" ] opsysVariables _ _ = mempty alpineVariables = mconcat [ -- Due to #20266 "CONFIGURE_ARGS" =: "--disable-ld-override" , "INSTALL_CONFIGURE_ARGS" =: "--disable-ld-override" - , "HADRIAN_ARGS" =: "--docs=no-sphinx" -- encoding004: due to lack of locale support -- T10458, ghcilink002: due to #17869 , "BROKEN_TESTS" =: "encoding004 T10458" @@ -450,9 +449,6 @@ distroVariables Centos7 = mconcat [ "HADRIAN_ARGS" =: "--docs=no-sphinx" , "BROKEN_TESTS" =: "T22012" -- due to #23979 ] -distroVariables Rocky8 = mconcat [ - "HADRIAN_ARGS" =: "--docs=no-sphinx" - ] distroVariables Fedora33 = mconcat -- LLC/OPT do not work for some reason in our fedora images -- These tests fail with this error: T11649 T5681 T7571 T8131b ===================================== .gitlab/jobs.yaml ===================================== @@ -57,7 +57,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", "NIX_SYSTEM": "aarch64-darwin", @@ -305,7 +305,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", "NIX_SYSTEM": "aarch64-darwin", @@ -372,7 +372,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "aarch64-linux-alpine3_18-validate", @@ -684,7 +683,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", "NIX_SYSTEM": "x86_64-darwin", @@ -751,9 +750,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", + "GHC_VERSION": "9.6.4", "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-freebsd13-validate", @@ -818,7 +817,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-int_native-validate+fully_static", @@ -883,7 +881,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate", @@ -948,7 +945,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static", @@ -1013,7 +1009,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_18-validate", @@ -2526,7 +2521,6 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-rocky8-validate", "XZ_OPT": "-9" @@ -2707,10 +2701,10 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", @@ -2769,10 +2763,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", @@ -2837,7 +2831,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", @@ -2905,7 +2899,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3162,7 +3156,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", @@ -3233,7 +3227,7 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3299,7 +3293,7 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "release+fully_static+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3365,7 +3359,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3431,7 +3425,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -4143,7 +4137,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-rocky8-release", @@ -4329,10 +4323,10 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", @@ -4392,10 +4386,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", @@ -4461,7 +4455,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", "NIX_SYSTEM": "x86_64-darwin", @@ -4527,9 +4521,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", + "GHC_VERSION": "9.6.4", "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-freebsd13-validate" @@ -4593,7 +4587,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static" @@ -5585,10 +5578,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", ===================================== compiler/GHC/Iface/Ext/Utils.hs ===================================== @@ -107,7 +107,13 @@ data EvidenceInfo a , evidenceSpan :: RealSrcSpan , evidenceType :: a , evidenceDetails :: Maybe (EvVarSource, Scope, Maybe Span) - } deriving (Eq,Ord,Functor) + } deriving (Eq, Functor) + +instance Ord a => Ord (EvidenceInfo a) where + compare (EvidenceInfo name span typ dets) (EvidenceInfo name' span' typ' dets') = + case stableNameCmp name name' of + EQ -> compare (span, typ, dets) (span', typ', dets') + r -> r instance (Outputable a) => Outputable (EvidenceInfo a) where ppr (EvidenceInfo name span typ dets) = ===================================== configure.ac ===================================== @@ -205,7 +205,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.4" +MinBootGhcVersion="9.6" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -145,12 +145,7 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - -- We 'need' all binaries and libraries - all_pkgs <- stagePackages Stage1 - (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs - cross <- flag CrossCompiling - iserv_targets <- if cross then pure [] else iservBins - need (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) + version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull @@ -164,6 +159,22 @@ bindistRules = do rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir -/- "include" + -- We 'need' all binaries and libraries + all_pkgs <- stagePackages Stage1 + (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs + cross <- flag CrossCompiling + iserv_targets <- if cross then pure [] else iservBins + + let lib_exe_targets = (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) + + let doc_target = if cross then [] else ["docs"] + + let other_targets = map (bindistFilesDir -/-) (["configure", "Makefile"] ++ bindistInstallFiles) + let all_targets = lib_exe_targets ++ doc_target ++ other_targets + + -- Better parallelism if everything is needed together. + need all_targets + -- We create the bindist directory at /bindist/ghc-X.Y.Z-platform/ -- and populate it with Stage2 build results createDirectory bindistFilesDir @@ -232,7 +243,6 @@ bindistRules = do cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache"] - unless cross $ need ["docs"] -- TODO: we should only embed the docs that have been generated -- depending on the current settings (flavours' "ghcDocs" field and @@ -274,8 +284,6 @@ bindistRules = do -- We then 'need' all the files necessary to configure and install -- (as in, './configure [...] && make install') this build on some -- other machine. - need $ map (bindistFilesDir -/-) - (["configure", "Makefile"] ++ bindistInstallFiles) copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in") generateBuildMk >>= writeFile' (bindistFilesDir -/- "build.mk") copyFile ("hadrian" -/- "cfg" -/- "default.target.in") (bindistFilesDir -/- "default.target.in") ===================================== libraries/base/tests/AtomicModifyIORef.hs ===================================== @@ -5,7 +5,7 @@ import Data.IORef main :: IO () main = do let nThreads = 10 - nIncrs = 10000000 + nIncrs = 10000 ref <- newIORef (42 :: Int) dones <- replicateM nThreads $ do ===================================== libraries/base/tests/AtomicModifyIORef.stdout ===================================== @@ -8,4 +8,4 @@ . . . -100000042 +100042 ===================================== testsuite/tests/hiefile/should_run/T23540.stdout ===================================== @@ -124,35 +124,35 @@ At point (49,14), we found: At point (61,7), we found: ========================== ┌ -│ $dFunctor at T23540.hs:1:1, of type: Functor Identity' -│ is an evidence variable bound by a let, depending on: [$fFunctorIdentity'] +│ $dApplicative at T23540.hs:1:1, of type: Applicative Identity' +│ is an evidence variable bound by a let, depending on: [$fApplicativeIdentity'] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fFunctorIdentity' at T23540.hs:54:10-26, of type: Functor Identity' - │ is an evidence variable bound by an instance of class Functor + │ $fApplicativeIdentity' at T23540.hs:56:10-30, of type: Applicative Identity' + │ is an evidence variable bound by an instance of class Applicative │ with scope: ModuleScope │ - │ Defined at T23540.hs:54:10 + │ Defined at T23540.hs:56:10 └ ┌ -│ $dApplicative at T23540.hs:1:1, of type: Applicative Identity' -│ is an evidence variable bound by a let, depending on: [$fApplicativeIdentity'] +│ $dFunctor at T23540.hs:1:1, of type: Functor Identity' +│ is an evidence variable bound by a let, depending on: [$fFunctorIdentity'] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fApplicativeIdentity' at T23540.hs:56:10-30, of type: Applicative Identity' - │ is an evidence variable bound by an instance of class Applicative + │ $fFunctorIdentity' at T23540.hs:54:10-26, of type: Functor Identity' + │ is an evidence variable bound by an instance of class Functor │ with scope: ModuleScope │ - │ Defined at T23540.hs:56:10 + │ Defined at T23540.hs:54:10 └ ========================== @@ -202,33 +202,34 @@ At point (69,4), we found: At point (82,6), we found: ========================== ┌ -│ $dOrd at T23540.hs:1:1, of type: Ord Modulo1 -│ is an evidence variable bound by a let, depending on: [$fOrdModulo1] +│ $dNum at T23540.hs:1:1, of type: Num Modulo1 +│ is an evidence variable bound by a let, depending on: [$fNumModulo1] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fOrdModulo1 at T23540.hs:8:35-37, of type: Ord Modulo1 - │ is an evidence variable bound by an instance of class Ord + │ $fNumModulo1 at T23540.hs:10:10-20, of type: Num Modulo1 + │ is an evidence variable bound by an instance of class Num │ with scope: ModuleScope │ - │ Defined at T23540.hs:8:35 + │ Defined at T23540.hs:10:10 └ ┌ -│ $dNum at T23540.hs:1:1, of type: Num Modulo1 -│ is an evidence variable bound by a let, depending on: [$fNumModulo1] +│ $dOrd at T23540.hs:1:1, of type: Ord Modulo1 +│ is an evidence variable bound by a let, depending on: [$fOrdModulo1] │ with scope: ModuleScope │ │ Defined at └ | `- ┌ - │ $fNumModulo1 at T23540.hs:10:10-20, of type: Num Modulo1 - │ is an evidence variable bound by an instance of class Num + │ $fOrdModulo1 at T23540.hs:8:35-37, of type: Ord Modulo1 + │ is an evidence variable bound by an instance of class Ord │ with scope: ModuleScope │ - │ Defined at T23540.hs:10:10 - └ \ No newline at end of file + │ Defined at T23540.hs:8:35 + └ + ===================================== testsuite/tests/hiefile/should_run/TestUtils.hs ===================================== @@ -10,6 +10,7 @@ module TestUtils ) where import System.Environment +import Data.List (sort) import Data.Tree import GHC.Types.Name.Cache import GHC.Types.SrcLoc @@ -20,13 +21,13 @@ import qualified GHC.Utils.Outputable as O import GHC.Iface.Ext.Binary import GHC.Iface.Ext.Types import GHC.Iface.Ext.Utils - + import GHC.Driver.Session import GHC.SysTools makeNc :: IO NameCache makeNc = initNameCache 'z' [] - + dynFlagsForPrinting :: String -> IO DynFlags dynFlagsForPrinting libdir = do systemSettings <- initSysTools libdir @@ -53,7 +54,7 @@ explainEv df hf refmap point = do putStrLn $ replicate 26 '=' putStr $ drawForest ptrees where - trees = getEvidenceTreesAtPoint hf refmap point + trees = sort $ getEvidenceTreesAtPoint hf refmap point ptrees = fmap (pprint . fmap expandType) <$> trees ===================================== testsuite/tests/hiefile/should_run/all.T ===================================== @@ -5,5 +5,5 @@ test('T23492', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUti test('RecordDotTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('SpliceTypes', [req_th, extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('HieVdq', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) -test('T23540', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs']), when(arch('i386'), fragile(24449))], compile_and_run, ['-package ghc -fwrite-ide-info']) +test('T23540', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('T23120', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/32bbeddf760ea20702cafd1a23d248b1c20af615...bdb8d342c63b7f2ea23a5a07587d39e76ea569a3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/32bbeddf760ea20702cafd1a23d248b1c20af615...bdb8d342c63b7f2ea23a5a07587d39e76ea569a3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 07:28:35 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 01 Mar 2024 02:28:35 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: hadrian: Improve parallelism in binary-dist-dir rule Message-ID: <65e183a369187_1e361e284ad1c560a2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5f63616f by Matthew Pickering at 2024-03-01T02:27:59-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - 90d7e879 by Matthew Pickering at 2024-03-01T02:28:00-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 598e3105 by Matthew Pickering at 2024-03-01T02:28:00-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - 882ad3b9 by Matthew Pickering at 2024-03-01T02:28:00-05:00 Bump minimum bootstrap version to 9.6 - - - - - 91a3b79b by Matthew Pickering at 2024-03-01T02:28:00-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 4cb5e8c9 by Matthew Pickering at 2024-03-01T02:28:00-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - 8 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - configure.ac - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 08bdbb85d6711e4df23d97e1cbdb557fe752b0a4 + DOCKER_REV: 7f63b34ac87b85470eef9c668e9528e8e2f5b46a # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. @@ -101,8 +101,6 @@ workflow: # which versions of GHC to allow bootstrap with .bootstrap_matrix : &bootstrap_matrix matrix: - - GHC_VERSION: 9.4.8 - DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_4:$DOCKER_REV" - GHC_VERSION: 9.6.4 DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_6:$DOCKER_REV" - GHC_VERSION: 9.8.1 ===================================== .gitlab/ci.sh ===================================== @@ -151,6 +151,8 @@ function mingw_init() { # We always use mingw64 Python to avoid path length issues like #17483. export PYTHON="/mingw64/bin/python3" + # And need to use sphinx-build from the environment + export SPHINXBUILD="/mingw64/bin/sphinx-build.exe" } # This will contain GHC's local native toolchain @@ -305,7 +307,7 @@ function fetch_cabal() { fail "neither CABAL nor CABAL_INSTALL_VERSION are not set" fi - start_section "fetch GHC" + start_section "fetch cabal" case "$(uname)" in # N.B. Windows uses zip whereas all others use .tar.xz MSYS_*|MINGW*) @@ -332,7 +334,7 @@ function fetch_cabal() { mv cabal "$toolchain/bin" ;; esac - end_section "fetch GHC" + end_section "fetch cabal" fi } ===================================== .gitlab/darwin/nix/sources.json ===================================== @@ -12,15 +12,15 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { - "branch": "master", + "branch": "nixos-unstable", "description": "Nix Packages collection", "homepage": "", "owner": "nixos", "repo": "nixpkgs", - "rev": "ce1aa29621356706746c53e2d480da7c68f6c972", - "sha256": "sha256:1sbs3gi1nf4rcbmnw69fw0fpvb3qvlsa84hqimv78vkpd6xb0bgg", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "sha256": "1v9sy2i2dy3qksx4mf81gwzfl0jzpqccfkzq7fjxgq832f9d255i", "type": "tarball", - "url": "https://github.com/nixos/nixpkgs/archive/ce1aa29621356706746c53e2d480da7c68f6c972.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/73de017ef2d18a04ac4bfd0c02650007ccb31c2a.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -4,6 +4,7 @@ let sources = import ./nix/sources.nix; nixpkgsSrc = sources.nixpkgs; pkgs = import nixpkgsSrc { inherit system; }; + hostPkgs = import nixpkgsSrc { }; in let @@ -13,23 +14,26 @@ let targetTriple = pkgs.stdenv.targetPlatform.config; ghcBindists = let version = ghc.version; in { - aarch64-darwin = pkgs.fetchurl { + aarch64-darwin = hostPkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "sha256-tQUHsingxBizLktswGAoi6lJf92RKWLjsHB9CisANlg="; + sha256 = "sha256-c1GTMJf3/yiW/t4QL532EswD5JVlgA4getkfsxj4TaA="; }; - x86_64-darwin = pkgs.fetchurl { + x86_64-darwin = hostPkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "sha256-OjXjVe+ZODDCc/hqtihqqz6CX25TKI0ZgORzkR5O3pQ="; + sha256 = "sha256-LrYniMG0phsvyW6dhQC+3ompvzcxnwAe6GezEqqzoTQ="; }; + }; ghc = pkgs.stdenv.mkDerivation rec { - version = "9.4.4"; + # Using 9.6.2 because of #24050 + version = "9.6.2"; name = "ghc"; src = ghcBindists.${pkgs.stdenv.hostPlatform.system}; configureFlags = [ "CC=/usr/bin/clang" "CLANG=/usr/bin/clang" + "AR=/usr/bin/ar" "LLC=${llvm}/bin/llc" "OPT=${llvm}/bin/opt" "CONF_CC_OPTS_STAGE2=--target=${targetTriple}" @@ -92,7 +96,7 @@ let }; fonts = with pkgs; makeFontsConf { fontDirectories = [ dejavu_fonts ]; }; - llvm = pkgs.llvm_11; + llvm = pkgs.llvm_15; in pkgs.writeTextFile { name = "toolchain"; ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -397,8 +397,8 @@ opsysVariables _ FreeBSD13 = mconcat -- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" , "HADRIAN_ARGS" =: "--docs=no-sphinx" - , "GHC_VERSION" =: "9.4.3" - , "CABAL_INSTALL_VERSION" =: "3.8.1.0" + , "GHC_VERSION" =: "9.6.4" + , "CABAL_INSTALL_VERSION" =: "3.10.2.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -407,7 +407,7 @@ opsysVariables AArch64 (Darwin {}) = , "LANG" =: "en_US.UTF-8" , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi" -- Fonts can't be installed on darwin - , "HADRIAN_ARGS" =: "--docs=no-sphinx" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" ] opsysVariables Amd64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "x86_64-darwin" @@ -421,22 +421,21 @@ opsysVariables Amd64 (Darwin {}) = , "LANG" =: "en_US.UTF-8" , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi" -- Fonts can't be installed on darwin - , "HADRIAN_ARGS" =: "--docs=no-sphinx" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" ] opsysVariables _ (Windows {}) = mconcat [ "MSYSTEM" =: "CLANG64" - , "HADRIAN_ARGS" =: "--docs=no-sphinx" , "LANG" =: "en_US.UTF-8" - , "CABAL_INSTALL_VERSION" =: "3.8.1.0" - , "GHC_VERSION" =: "9.4.3" ] + , "CABAL_INSTALL_VERSION" =: "3.10.2.0" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" + , "GHC_VERSION" =: "9.6.4" ] opsysVariables _ _ = mempty alpineVariables = mconcat [ -- Due to #20266 "CONFIGURE_ARGS" =: "--disable-ld-override" , "INSTALL_CONFIGURE_ARGS" =: "--disable-ld-override" - , "HADRIAN_ARGS" =: "--docs=no-sphinx" -- encoding004: due to lack of locale support -- T10458, ghcilink002: due to #17869 , "BROKEN_TESTS" =: "encoding004 T10458" @@ -450,9 +449,6 @@ distroVariables Centos7 = mconcat [ "HADRIAN_ARGS" =: "--docs=no-sphinx" , "BROKEN_TESTS" =: "T22012" -- due to #23979 ] -distroVariables Rocky8 = mconcat [ - "HADRIAN_ARGS" =: "--docs=no-sphinx" - ] distroVariables Fedora33 = mconcat -- LLC/OPT do not work for some reason in our fedora images -- These tests fail with this error: T11649 T5681 T7571 T8131b ===================================== .gitlab/jobs.yaml ===================================== @@ -57,7 +57,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", "NIX_SYSTEM": "aarch64-darwin", @@ -305,7 +305,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", "NIX_SYSTEM": "aarch64-darwin", @@ -372,7 +372,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "aarch64-linux-alpine3_18-validate", @@ -684,7 +683,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", "NIX_SYSTEM": "x86_64-darwin", @@ -751,9 +750,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", + "GHC_VERSION": "9.6.4", "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-freebsd13-validate", @@ -818,7 +817,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-int_native-validate+fully_static", @@ -883,7 +881,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate", @@ -948,7 +945,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static", @@ -1013,7 +1009,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_18-validate", @@ -2526,7 +2521,6 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-rocky8-validate", "XZ_OPT": "-9" @@ -2707,10 +2701,10 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", @@ -2769,10 +2763,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", @@ -2837,7 +2831,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", @@ -2905,7 +2899,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3162,7 +3156,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", @@ -3233,7 +3227,7 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3299,7 +3293,7 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "release+fully_static+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3365,7 +3359,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3431,7 +3425,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -4143,7 +4137,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-rocky8-release", @@ -4329,10 +4323,10 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", @@ -4392,10 +4386,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", @@ -4461,7 +4455,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", "NIX_SYSTEM": "x86_64-darwin", @@ -4527,9 +4521,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", + "GHC_VERSION": "9.6.4", "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-freebsd13-validate" @@ -4593,7 +4587,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static" @@ -5585,10 +5578,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", ===================================== configure.ac ===================================== @@ -205,7 +205,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.4" +MinBootGhcVersion="9.6" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -145,12 +145,7 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - -- We 'need' all binaries and libraries - all_pkgs <- stagePackages Stage1 - (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs - cross <- flag CrossCompiling - iserv_targets <- if cross then pure [] else iservBins - need (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) + version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull @@ -164,6 +159,22 @@ bindistRules = do rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir -/- "include" + -- We 'need' all binaries and libraries + all_pkgs <- stagePackages Stage1 + (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs + cross <- flag CrossCompiling + iserv_targets <- if cross then pure [] else iservBins + + let lib_exe_targets = (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) + + let doc_target = if cross then [] else ["docs"] + + let other_targets = map (bindistFilesDir -/-) (["configure", "Makefile"] ++ bindistInstallFiles) + let all_targets = lib_exe_targets ++ doc_target ++ other_targets + + -- Better parallelism if everything is needed together. + need all_targets + -- We create the bindist directory at /bindist/ghc-X.Y.Z-platform/ -- and populate it with Stage2 build results createDirectory bindistFilesDir @@ -232,7 +243,6 @@ bindistRules = do cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache"] - unless cross $ need ["docs"] -- TODO: we should only embed the docs that have been generated -- depending on the current settings (flavours' "ghcDocs" field and @@ -274,8 +284,6 @@ bindistRules = do -- We then 'need' all the files necessary to configure and install -- (as in, './configure [...] && make install') this build on some -- other machine. - need $ map (bindistFilesDir -/-) - (["configure", "Makefile"] ++ bindistInstallFiles) copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in") generateBuildMk >>= writeFile' (bindistFilesDir -/- "build.mk") copyFile ("hadrian" -/- "cfg" -/- "default.target.in") (bindistFilesDir -/- "default.target.in") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdb8d342c63b7f2ea23a5a07587d39e76ea569a3...4cb5e8c9f4a446c147f4c3d316852b135edae0cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdb8d342c63b7f2ea23a5a07587d39e76ea569a3...4cb5e8c9f4a446c147f4c3d316852b135edae0cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 09:35:20 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Fri, 01 Mar 2024 04:35:20 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] 3 commits: Linker: Add local labels to the GOT Message-ID: <65e1a15851fa2_cb85dcb6a1010263a@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: c0eb04d3 by Sven Tennie at 2024-03-01T10:01:58+01:00 Linker: Add local labels to the GOT - - - - - b5050132 by Sven Tennie at 2024-03-01T10:05:17+01:00 Linker: uint32_t addend This seems to be a good representation: - We're dealing with negative values as well (e.g. negative PC offset) - We cannot deal with more than 20 + 12 = 32 bits - - - - - 77b14c9a by Sven Tennie at 2024-03-01T10:12:03+01:00 Linker: Rework debug traces - - - - - 2 changed files: - rts/linker/elf_got.c - rts/linker/elf_reloc_riscv64.c Changes: ===================================== rts/linker/elf_got.c ===================================== @@ -9,22 +9,35 @@ * Check if we need a global offset table slot for a * given symbol */ -bool -needGotSlot(Elf_Sym * symbol) { - /* using global here should give an upper bound */ - /* I don't believe we need to relocate STB_LOCAL - * symbols via the GOT; however I'm unsure about - * STB_WEAK. - * - * Any more restrictive filter here would result - * in a smaller GOT, which is preferable. - */ - return ELF_ST_BIND(symbol->st_info) == STB_GLOBAL - || ELF_ST_BIND(symbol->st_info) == STB_WEAK - // Section symbols exist primarily for relocation - // and as such may need a GOT slot. - || ELF_ST_TYPE(symbol->st_info) == STT_SECTION; - +bool needGotSlot(Elf_Sym *symbol) { + /* using global here should give an upper bound */ + /* I don't believe we need to relocate STB_LOCAL + * symbols via the GOT; however I'm unsure about + * STB_WEAK. + * + * Any more restrictive filter here would result + * in a smaller GOT, which is preferable. + */ + return ELF_ST_BIND(symbol->st_info) == STB_GLOBAL || + ELF_ST_BIND(symbol->st_info) == STB_WEAK + // Section symbols exist primarily for relocation + // and as such may need a GOT slot. + || ELF_ST_TYPE(symbol->st_info) == STT_SECTION +#if defined(riscv64_HOST_ARCH) + // RISCV relies much on relocations and relaxations, leaving most of + // the addressing mode heavy lifting to the linker. We're using LA to + // load local label addresses (e.g. to access `*_closure`.) This + // implies (in the medany memory model) relocation via the GOT unless + // the instruction gets relaxed to e.g. direct or PC-relative + // addressing. So, for now, we've got the special case to add GOT + // symbols for all local labels here. This could be optimized by e.g. + // adding symbols to GOT on demand: I.e. if we spot a symbol related + // relocation which cannot be relaxed to direct or PC-relative + // addressing, then add it to GOT (otherwise not.) + || (ELF_ST_BIND(symbol->st_info) == STB_LOCAL && + ELF_ST_TYPE(symbol->st_info) == STT_NOTYPE && symbol->st_name != 0) +#endif + ; } bool ===================================== rts/linker/elf_reloc_riscv64.c ===================================== @@ -73,8 +73,8 @@ char *relocationTypeToString(Elf64_Xword type) { typedef uint64_t addr_t; -int64_t decodeAddendRISCV64(Section *section, Elf_Rel *rel) STG_NORETURN; -bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int64_t addend); +int32_t decodeAddendRISCV64(Section *section, Elf_Rel *rel) STG_NORETURN; +bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int32_t addend); /* regular instructions are 32bit */ typedef uint32_t inst_t; @@ -83,7 +83,7 @@ typedef uint32_t inst_t; typedef uint16_t cinst_t; // TODO: Decide which functions should be static and/or inlined. -int64_t decodeAddendRISCV64(Section *section STG_UNUSED, +int32_t decodeAddendRISCV64(Section *section STG_UNUSED, Elf_Rel *rel STG_UNUSED) { debugBelch("decodeAddendRISCV64: Relocations with explicit addend are not " "supported."); @@ -146,10 +146,11 @@ uint32_t setLO12_S(uint32_t insn, uint32_t imm) { (extractBits(imm, 4, 0) << 7); } -void setUType(inst_t *loc, uint32_t val) { +void setUType(inst_t *loc, int32_t val) { const unsigned bits = 32; - uint64_t hi = val + 0x800; + uint32_t hi = val + 0x800; checkInt(loc, SignExtend64(hi, bits) >> 12, 20); + debugBelch("setUType: hi 0x%x val 0x%x\n", hi, val); write32le(loc, (read32le(loc) & 0xFFF) | (hi & 0xFFFFF000)); } @@ -227,16 +228,15 @@ void setCJType(cinst_t *loc, uint32_t val) { write16le(loc, insn); } -bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int64_t addend) { +bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int32_t addend) { addr_t P = (addr_t)((uint8_t *)section->start + rel->r_offset); - IF_DEBUG( - linker, - debugBelch( - "Relocation type %s 0x%lx (%lu) symbol 0x%lx addend 0x%lx (%lu / " - "%ld) P 0x%lx\n", - relocationTypeToString(rel->r_info), ELF64_R_TYPE(rel->r_info), - ELF64_R_TYPE(rel->r_info), ELF64_R_SYM(rel->r_info), addend, addend, - addend, P)); + IF_DEBUG(linker, + debugBelch( + "Relocation type %s 0x%lx (%lu) symbol 0x%lx addend 0x%x (%u / " + "%d) P 0x%lx\n", + relocationTypeToString(rel->r_info), ELF64_R_TYPE(rel->r_info), + ELF64_R_TYPE(rel->r_info), ELF64_R_SYM(rel->r_info), addend, + addend, addend, P)); switch (ELF64_R_TYPE(rel->r_info)) { case R_RISCV_32_PCREL: case R_RISCV_32: @@ -352,7 +352,7 @@ bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int64_t addend) { * @param addend The existing addend. Either explicit or implicit. * @return The new computed addend. */ -int64_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, +int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, int64_t addend, ObjectCode *oc) { /* Position where something is relocated */ @@ -438,8 +438,11 @@ int64_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, relocationTypeToString(rel->r_info), P, S, symbol->name, relocationTypeToString(rel_prime->r_info), P_prime, symbol_prime->addr, symbol_prime->name)); - return computeAddend(targetSection, (Elf_Rel *)rel_prime, - symbol_prime, addend_prime, oc); + int32_t result = computeAddend(targetSection, (Elf_Rel *)rel_prime, + symbol_prime, addend_prime, oc); + IF_DEBUG(linker, + debugBelch("Result of computeAddend: 0x%x (%d)\n", result, result)); + return result; } } } @@ -462,10 +465,9 @@ int64_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, abort(/* could not find or make stub */); } } - IF_DEBUG( - linker, - debugBelch("S = 0x%lx A = 0x%lx P = 0x%lx (S + A) - P = 0x%lx \n", S, - A, P, (S + A) - P)); + IF_DEBUG(linker, debugBelch("R_RISCV_CALL_PLT: S = 0x%lx A = 0x%lx P = " + "0x%lx (S + A) - P = 0x%lx \n", + S, A, P, (S + A) - P)); return (S + A) - P; } case R_RISCV_ADD8: @@ -504,9 +506,11 @@ int64_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, return 0; case R_RISCV_32_PCREL: return S + A - P; - case R_RISCV_GOT_HI20: - // reduced G + GOT to GOT_S - This might be wrong! + case R_RISCV_GOT_HI20: { + // Ensure that the GOT entry is set up. + CHECK(0x0 != GOT_S); return GOT_S + A - P; + } default: debugBelch("Unimplemented relocation: 0x%lx\n (%lu)", ELF64_R_TYPE(rel->r_info), ELF64_R_TYPE(rel->r_info)); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c36bf10472d3243b25c4480dad55b9c7c7fb865c...77b14c9a1db2bf15b4a46443f7c5eb5e70257cd1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c36bf10472d3243b25c4480dad55b9c7c7fb865c...77b14c9a1db2bf15b4a46443f7c5eb5e70257cd1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 10:48:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 01 Mar 2024 05:48:36 -0500 Subject: [Git][ghc/ghc][master] 5 commits: hadrian: Improve parallelism in binary-dist-dir rule Message-ID: <65e1b284126c0_cb85d2ca8f801176e7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 8 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - configure.ac - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -101,8 +101,6 @@ workflow: # which versions of GHC to allow bootstrap with .bootstrap_matrix : &bootstrap_matrix matrix: - - GHC_VERSION: 9.4.8 - DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_4:$DOCKER_REV" - GHC_VERSION: 9.6.4 DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_6:$DOCKER_REV" - GHC_VERSION: 9.8.1 ===================================== .gitlab/ci.sh ===================================== @@ -151,6 +151,8 @@ function mingw_init() { # We always use mingw64 Python to avoid path length issues like #17483. export PYTHON="/mingw64/bin/python3" + # And need to use sphinx-build from the environment + export SPHINXBUILD="/mingw64/bin/sphinx-build.exe" } # This will contain GHC's local native toolchain @@ -305,7 +307,7 @@ function fetch_cabal() { fail "neither CABAL nor CABAL_INSTALL_VERSION are not set" fi - start_section "fetch GHC" + start_section "fetch cabal" case "$(uname)" in # N.B. Windows uses zip whereas all others use .tar.xz MSYS_*|MINGW*) @@ -332,7 +334,7 @@ function fetch_cabal() { mv cabal "$toolchain/bin" ;; esac - end_section "fetch GHC" + end_section "fetch cabal" fi } ===================================== .gitlab/darwin/nix/sources.json ===================================== @@ -12,15 +12,15 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { - "branch": "master", + "branch": "nixos-unstable", "description": "Nix Packages collection", "homepage": "", "owner": "nixos", "repo": "nixpkgs", - "rev": "ce1aa29621356706746c53e2d480da7c68f6c972", - "sha256": "sha256:1sbs3gi1nf4rcbmnw69fw0fpvb3qvlsa84hqimv78vkpd6xb0bgg", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "sha256": "1v9sy2i2dy3qksx4mf81gwzfl0jzpqccfkzq7fjxgq832f9d255i", "type": "tarball", - "url": "https://github.com/nixos/nixpkgs/archive/ce1aa29621356706746c53e2d480da7c68f6c972.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/73de017ef2d18a04ac4bfd0c02650007ccb31c2a.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -4,6 +4,7 @@ let sources = import ./nix/sources.nix; nixpkgsSrc = sources.nixpkgs; pkgs = import nixpkgsSrc { inherit system; }; + hostPkgs = import nixpkgsSrc { }; in let @@ -13,23 +14,26 @@ let targetTriple = pkgs.stdenv.targetPlatform.config; ghcBindists = let version = ghc.version; in { - aarch64-darwin = pkgs.fetchurl { + aarch64-darwin = hostPkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "sha256-tQUHsingxBizLktswGAoi6lJf92RKWLjsHB9CisANlg="; + sha256 = "sha256-c1GTMJf3/yiW/t4QL532EswD5JVlgA4getkfsxj4TaA="; }; - x86_64-darwin = pkgs.fetchurl { + x86_64-darwin = hostPkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "sha256-OjXjVe+ZODDCc/hqtihqqz6CX25TKI0ZgORzkR5O3pQ="; + sha256 = "sha256-LrYniMG0phsvyW6dhQC+3ompvzcxnwAe6GezEqqzoTQ="; }; + }; ghc = pkgs.stdenv.mkDerivation rec { - version = "9.4.4"; + # Using 9.6.2 because of #24050 + version = "9.6.2"; name = "ghc"; src = ghcBindists.${pkgs.stdenv.hostPlatform.system}; configureFlags = [ "CC=/usr/bin/clang" "CLANG=/usr/bin/clang" + "AR=/usr/bin/ar" "LLC=${llvm}/bin/llc" "OPT=${llvm}/bin/opt" "CONF_CC_OPTS_STAGE2=--target=${targetTriple}" @@ -92,7 +96,7 @@ let }; fonts = with pkgs; makeFontsConf { fontDirectories = [ dejavu_fonts ]; }; - llvm = pkgs.llvm_11; + llvm = pkgs.llvm_15; in pkgs.writeTextFile { name = "toolchain"; ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -397,8 +397,8 @@ opsysVariables _ FreeBSD13 = mconcat -- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" , "HADRIAN_ARGS" =: "--docs=no-sphinx" - , "GHC_VERSION" =: "9.4.3" - , "CABAL_INSTALL_VERSION" =: "3.8.1.0" + , "GHC_VERSION" =: "9.6.4" + , "CABAL_INSTALL_VERSION" =: "3.10.2.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -407,7 +407,7 @@ opsysVariables AArch64 (Darwin {}) = , "LANG" =: "en_US.UTF-8" , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi" -- Fonts can't be installed on darwin - , "HADRIAN_ARGS" =: "--docs=no-sphinx" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" ] opsysVariables Amd64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "x86_64-darwin" @@ -421,22 +421,21 @@ opsysVariables Amd64 (Darwin {}) = , "LANG" =: "en_US.UTF-8" , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi" -- Fonts can't be installed on darwin - , "HADRIAN_ARGS" =: "--docs=no-sphinx" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" ] opsysVariables _ (Windows {}) = mconcat [ "MSYSTEM" =: "CLANG64" - , "HADRIAN_ARGS" =: "--docs=no-sphinx" , "LANG" =: "en_US.UTF-8" - , "CABAL_INSTALL_VERSION" =: "3.8.1.0" - , "GHC_VERSION" =: "9.4.3" ] + , "CABAL_INSTALL_VERSION" =: "3.10.2.0" + , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs" + , "GHC_VERSION" =: "9.6.4" ] opsysVariables _ _ = mempty alpineVariables = mconcat [ -- Due to #20266 "CONFIGURE_ARGS" =: "--disable-ld-override" , "INSTALL_CONFIGURE_ARGS" =: "--disable-ld-override" - , "HADRIAN_ARGS" =: "--docs=no-sphinx" -- encoding004: due to lack of locale support -- T10458, ghcilink002: due to #17869 , "BROKEN_TESTS" =: "encoding004 T10458" @@ -450,9 +449,6 @@ distroVariables Centos7 = mconcat [ "HADRIAN_ARGS" =: "--docs=no-sphinx" , "BROKEN_TESTS" =: "T22012" -- due to #23979 ] -distroVariables Rocky8 = mconcat [ - "HADRIAN_ARGS" =: "--docs=no-sphinx" - ] distroVariables Fedora33 = mconcat -- LLC/OPT do not work for some reason in our fedora images -- These tests fail with this error: T11649 T5681 T7571 T8131b ===================================== .gitlab/jobs.yaml ===================================== @@ -57,7 +57,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", "NIX_SYSTEM": "aarch64-darwin", @@ -305,7 +305,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", "NIX_SYSTEM": "aarch64-darwin", @@ -372,7 +372,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "aarch64-linux-alpine3_18-validate", @@ -684,7 +683,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", "NIX_SYSTEM": "x86_64-darwin", @@ -751,9 +750,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", + "GHC_VERSION": "9.6.4", "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-freebsd13-validate", @@ -818,7 +817,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-int_native-validate+fully_static", @@ -883,7 +881,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate", @@ -948,7 +945,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static", @@ -1013,7 +1009,6 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_18-validate", @@ -2526,7 +2521,6 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-rocky8-validate", "XZ_OPT": "-9" @@ -2707,10 +2701,10 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", @@ -2769,10 +2763,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", @@ -2837,7 +2831,7 @@ "BIN_DIST_NAME": "ghc-aarch64-darwin-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "11.0", @@ -2905,7 +2899,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3162,7 +3156,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", @@ -3233,7 +3227,7 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3299,7 +3293,7 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "release+fully_static+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3365,7 +3359,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -3431,7 +3425,7 @@ "BROKEN_TESTS": "encoding004 T10458", "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", @@ -4143,7 +4137,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "HADRIAN_ARGS": "--hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-rocky8-release", @@ -4329,10 +4323,10 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", @@ -4392,10 +4386,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", @@ -4461,7 +4455,7 @@ "BIN_DIST_NAME": "ghc-x86_64-darwin-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MACOSX_DEPLOYMENT_TARGET": "10.13", "NIX_SYSTEM": "x86_64-darwin", @@ -4527,9 +4521,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", + "GHC_VERSION": "9.6.4", "HADRIAN_ARGS": "--docs=no-sphinx", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-freebsd13-validate" @@ -4593,7 +4587,6 @@ "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458", "BUILD_FLAVOUR": "validate+fully_static", "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=no-sphinx", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static" @@ -5585,10 +5578,10 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.8.1.0", + "CABAL_INSTALL_VERSION": "3.10.2.0", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "GHC_VERSION": "9.4.3", - "HADRIAN_ARGS": "--docs=no-sphinx", + "GHC_VERSION": "9.6.4", + "HADRIAN_ARGS": "--docs=no-sphinx-pdfs", "LANG": "en_US.UTF-8", "MSYSTEM": "CLANG64", "RUNTEST_ARGS": "", ===================================== configure.ac ===================================== @@ -205,7 +205,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.4" +MinBootGhcVersion="9.6" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -145,12 +145,7 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - -- We 'need' all binaries and libraries - all_pkgs <- stagePackages Stage1 - (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs - cross <- flag CrossCompiling - iserv_targets <- if cross then pure [] else iservBins - need (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) + version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull @@ -164,6 +159,22 @@ bindistRules = do rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir -/- "include" + -- We 'need' all binaries and libraries + all_pkgs <- stagePackages Stage1 + (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs + cross <- flag CrossCompiling + iserv_targets <- if cross then pure [] else iservBins + + let lib_exe_targets = (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) + + let doc_target = if cross then [] else ["docs"] + + let other_targets = map (bindistFilesDir -/-) (["configure", "Makefile"] ++ bindistInstallFiles) + let all_targets = lib_exe_targets ++ doc_target ++ other_targets + + -- Better parallelism if everything is needed together. + need all_targets + -- We create the bindist directory at /bindist/ghc-X.Y.Z-platform/ -- and populate it with Stage2 build results createDirectory bindistFilesDir @@ -232,7 +243,6 @@ bindistRules = do cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache"] - unless cross $ need ["docs"] -- TODO: we should only embed the docs that have been generated -- depending on the current settings (flavours' "ghcDocs" field and @@ -274,8 +284,6 @@ bindistRules = do -- We then 'need' all the files necessary to configure and install -- (as in, './configure [...] && make install') this build on some -- other machine. - need $ map (bindistFilesDir -/-) - (["configure", "Makefile"] ++ bindistInstallFiles) copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in") generateBuildMk >>= writeFile' (bindistFilesDir -/- "build.mk") copyFile ("hadrian" -/- "cfg" -/- "default.target.in") (bindistFilesDir -/- "default.target.in") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/960c8d47f064644617a605b1225a18e9350be995...67ace1c59dd582919bceb4fdadbefc1d98d3449a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/960c8d47f064644617a605b1225a18e9350be995...67ace1c59dd582919bceb4fdadbefc1d98d3449a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 10:49:24 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 01 Mar 2024 05:49:24 -0500 Subject: [Git][ghc/ghc][master] ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 Message-ID: <65e1b2b4af544_cb85d31e280c12207a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 08bdbb85d6711e4df23d97e1cbdb557fe752b0a4 + DOCKER_REV: 7f63b34ac87b85470eef9c668e9528e8e2f5b46a # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39583c399193b3dedc399f4dccbd222640581956 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39583c399193b3dedc399f4dccbd222640581956 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 11:08:49 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 01 Mar 2024 06:08:49 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-prim-docs Message-ID: <65e1b74193fc1_cb85d3ad711012427e@gitlab.mail> Matthew Pickering pushed new branch wip/ghc-prim-docs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-prim-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 Mar 1 13:09:05 2024 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Fri, 01 Mar 2024 08:09:05 -0500 Subject: [Git][ghc/ghc][wip/torsten.schmits/0475-tuple-syntax-2] JS linker: filter unboxed tuples Message-ID: <65e1d371c60b7_1e05a12504a2c1498e@gitlab.mail> Sylvain Henry pushed to branch wip/torsten.schmits/0475-tuple-syntax-2 at Glasgow Haskell Compiler / GHC Commits: 2825d289 by Sylvain Henry at 2024-03-01T14:08:19+01:00 JS linker: filter unboxed tuples - - - - - 1 changed file: - compiler/GHC/StgToJS/Utils.hs Changes: ===================================== compiler/GHC/StgToJS/Utils.hs ===================================== @@ -341,10 +341,16 @@ collectIds unfloated b = in seqList xs `seq` xs where acceptId i = all ($ i) [not . isForbidden] -- fixme test this: [isExported[isGlobalId, not.isForbidden] - -- the GHC.Prim module has no js source file isForbidden i - | Just m <- nameModule_maybe (getName i) = m == gHC_PRIM - | otherwise = False + -- the GHC.Prim module has no js source file + | Just m <- nameModule_maybe (getName i) + , m == gHC_PRIM + = True + -- unboxed tuples have no definition + | isUnboxedTupleDataConLikeName (getName i) + = True + | otherwise + = False ----------------------------------------------------- -- Live vars View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2825d28912ab1134a606f12f74734b1add9bdbd5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2825d28912ab1134a606f12f74734b1add9bdbd5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 14:02:49 2024 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Fri, 01 Mar 2024 09:02:49 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] Apply 1 suggestion(s) to 1 file(s) Message-ID: <65e1e009c6f7a_1e05a13eb6e8425454@gitlab.mail> sheaf pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: 6638884a by sheaf at 2024-03-01T14:02:27+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/X86/CodeGen.hs Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3458,6 +3458,8 @@ genFMA3Code w signs x y z = do x_code <- getAnyReg x x_tmp <- getNewRegNat rep let + fma213 = FMA3 rep signs FMA213 + code, code_direct, code_mov :: Reg -> InstrBlock -- Ideal: Compute the result directly into dst code_direct dst = x_code dst `snocOL` View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6638884acef42c037e214be5cb1aa27f7f2efacf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6638884acef42c037e214be5cb1aa27f7f2efacf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 15:16:48 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 01 Mar 2024 10:16:48 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/home-unit-closure-fast Message-ID: <65e1f1607cc7c_1e05a15da1fec319ae@gitlab.mail> Zubin pushed new branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/home-unit-closure-fast You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 15:19:11 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 01 Mar 2024 10:19:11 -0500 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65e1f1ef50910_1e05a15e99c24355f4@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: 44f5a0ed by Zubin Duggal at 2024-03-01T20:49:00+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,20 +1714,20 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) @@ -1737,47 +1736,50 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] +checkHomeUnitsClosed ue home_id_set + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId [UnitId] + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + addToUniqMap external_depends this (homeUnitDepends this_units) + `mappend` rest + where + external_depends = mapUniqMap unitDepends (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = ((Set.fromList depends) Set.\\ done) `Set.union` todo' + in DigraphNode uid uid depends : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44f5a0ed5cc2c7780ba7d1ad94c93305b5675a29 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44f5a0ed5cc2c7780ba7d1ad94c93305b5675a29 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 15:44:50 2024 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Fri, 01 Mar 2024 10:44:50 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] Apply 1 suggestion(s) to 1 file(s) Message-ID: <65e1f7f267ccf_1e05a16abd76c4538a@gitlab.mail> sheaf pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: 33f74e4b by sheaf at 2024-03-01T15:44:46+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - testsuite/tests/primops/should_run/all.T Changes: ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,7 +77,6 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) -test('T24496', normal, compile_and_run, ['']) test('T24496' , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) , js_skip # JS backend doesn't have an FMA implementation View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33f74e4bb268b55d9d0d1575528dc4bd0a217542 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33f74e4bb268b55d9d0d1575528dc4bd0a217542 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 16:06:44 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 01 Mar 2024 11:06:44 -0500 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65e1fd148c2bb_1e05a17670cf848124@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: ce768e98 by Zubin Duggal at 2024-03-01T21:35:55+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,20 +1714,20 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) @@ -1737,47 +1736,52 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] +checkHomeUnitsClosed ue home_id_set + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce768e98395dfe3f29d1dfee25e386e1b1a0d399 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce768e98395dfe3f29d1dfee25e386e1b1a0d399 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 16:29:25 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 01 Mar 2024 11:29:25 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/global-package-db Message-ID: <65e20265df421_1e05a17e62c90507bc@gitlab.mail> Matthew Pickering pushed new branch wip/global-package-db at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/global-package-db You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 16:30:59 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 01 Mar 2024 11:30:59 -0500 Subject: [Git][ghc/ghc][wip/global-package-db] Read global package database from settings file Message-ID: <65e202c3e6eec_1e05a180cab5452531@gitlab.mail> Matthew Pickering pushed to branch wip/global-package-db at Glasgow Haskell Compiler / GHC Commits: 187b4a53 by Matthew Pickering at 2024-03-01T16:30:43+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage2 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage2 package database. * Stage 2 cross compilers need to use stage3 libraries, so likewise, we should set to stage * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. - - - - - 4 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Rules/Generate.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3607,7 +3607,8 @@ compilerInfo dflags ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), ("LibDir", topDir dflags), - -- The path of the global package database used by GHC + -- This is always an absolute path, unlike "Raw Global Package DB" which is + -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ] where ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -112,8 +112,14 @@ initSettings top_dir = do ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" - let globalpkgdb_path = installed "package.conf.d" - ghc_usage_msg_path = installed "ghc-usage.txt" + + -- The package database is either a relative path to the location of the settings file + -- OR an absolute path. + -- In case the path is absolute then top_dir abs_path == abs_path + -- the path is relative then top_dir rel_path == top_dir rel_path + globalpkgdb_path <- installed <$> getSetting "Raw Global Package DB" + + let ghc_usage_msg_path = installed "ghc-usage.txt" ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities ===================================== hadrian/bindist/Makefile ===================================== @@ -141,6 +141,7 @@ lib/settings : config.mk @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@ @echo ',("RTS expects libdw", "$(GhcRtsWithLibdw)")' >> $@ + @echo ',("Raw Global Package DB", "package.conf.d")' >> $@ @echo "]" >> $@ # We need to install binaries relative to libraries. ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -421,6 +421,7 @@ generateSettings = do , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("Raw Global Package DB", return "package.conf.d" ) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/187b4a5310600331c4c54177143b4c46df9d641f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/187b4a5310600331c4c54177143b4c46df9d641f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 16:40:17 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 01 Mar 2024 11:40:17 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/improve-Word32ToInteger-on-64bit Message-ID: <65e204f1bd02f_1e05a185fdd105318e@gitlab.mail> Matthew Craven pushed new branch wip/improve-Word32ToInteger-on-64bit at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/improve-Word32ToInteger-on-64bit You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 16:51:54 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 01 Mar 2024 11:51:54 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: hadrian: Improve parallelism in binary-dist-dir rule Message-ID: <65e207aa1d22c_1e05a18c16134570ba@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - 4b1bc181 by Torsten Schmits at 2024-03-01T11:51:32-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - c9e3fc6d by Sylvain Henry at 2024-03-01T11:51:32-05:00 JS linker: filter unboxed tuples - - - - - d42fea6e by Arnaud Spiwack at 2024-03-01T11:51:44-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - fefb63f1 by Arnaud Spiwack at 2024-03-01T11:51:44-05:00 Adjust documentation of linear lets according to committee decision - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Instance/Typeable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4cb5e8c9f4a446c147f4c3d316852b135edae0cb...fefb63f1fad3c66f8984636bbaad541de6c28137 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4cb5e8c9f4a446c147f4c3d316852b135edae0cb...fefb63f1fad3c66f8984636bbaad541de6c28137 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 16:54:11 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 01 Mar 2024 11:54:11 -0500 Subject: [Git][ghc/ghc][wip/T24466] Restore preinlineUnconditinoally Message-ID: <65e20833779ab_1e05a18cf3ca06294a@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24466 at Glasgow Haskell Compiler / GHC Commits: 70ed9a0c by Simon Peyton Jones at 2024-03-01T16:53:13+00:00 Restore preinlineUnconditinoally See ghc log for 1 March and wheel-sieve1 - - - - - 2 changed files: - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Pipeline.hs Changes: ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -25,14 +25,14 @@ import GHC.Core import GHC.Core.Unfold( ExprSize(..), sizeExpr, UnfoldingOpts(..), defaultUnfoldingOpts ) import GHC.Core.Opt.Arity( isOneShotBndr ) -import GHC.Core.Opt.Simplify.Inline( smallEnoughToInline ) +-- import GHC.Core.Opt.Simplify.Inline( smallEnoughToInline ) import GHC.Core.Make hiding ( wrapFloats ) import GHC.Core.Utils import GHC.Core.FVs import GHC.Core.Type import GHC.Types.Basic ( RecFlag(..), isRec ) -import GHC.Types.Id ( idType, isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id ( idType, isJoinId, idJoinPointHood ) import GHC.Types.Tickish import GHC.Types.Var import GHC.Types.Var.Set @@ -792,7 +792,7 @@ sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | otherwise = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where - n_alts = length fork_fvs +-- n_alts = length fork_fvs go :: RevFloatInBinds -> DropBox -> [DropBox] -> (RevFloatInBinds, [RevFloatInBinds]) @@ -831,9 +831,9 @@ sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs -- See Note [Duplicating floats into case alternatives] dont_float_into_alts - = (n_used_alts == n_alts) + = -- (n_used_alts == n_alts) || -- Don't float in if used in all alternatives - || (n_used_alts > 1 && not (floatIsDupable platform bind)) + (n_used_alts > 1 && not (floatIsDupable platform bind)) -- Nor if used in multiple alts and not small new_fork_boxes = zipWithEqual "FloatIn.sepBinds" insert_maybe @@ -874,17 +874,22 @@ wrapFloats (FB _ _ fl : bs) e = wrapFloats bs (wrapFloat fl e) floatIsDupable :: Platform -> FloatBind -> Bool floatIsDupable _ (FloatCase scrut _ _ _) = small_enough_e scrut -floatIsDupable _ (FloatLet (Rec prs)) = all small_enough_b prs -floatIsDupable _ (FloatLet (NonRec b r)) = small_enough_b (b,r) +floatIsDupable _ (FloatLet bind) = bindIsDupable bind + +bindIsDupable :: CoreBind -> Bool +bindIsDupable bind + | isJoinBind bind = False -- No point in duplicating join points +bindIsDupable (Rec prs) = all small_enough_b prs +bindIsDupable (NonRec b r) = small_enough_b (b,r) small_enough_b :: (Id,CoreExpr) -> Bool -small_enough_b (b,_) = smallEnoughToInline defaultUnfoldingOpts (idUnfolding b) +small_enough_b (_,rhs) = small_enough_e rhs small_enough_e :: CoreExpr -> Bool small_enough_e e - = case sizeExpr opts (unfoldingCreationThreshold opts) [] e of - TooBig -> False - SizeIs n _ _ -> n < unfoldingUseThreshold opts + = case sizeExpr opts (unfoldingUseThreshold opts) [] e of + TooBig -> False + SizeIs {} -> True where opts = defaultUnfoldingOpts ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -324,8 +324,12 @@ getCoreToDo dflags hpt_rule_base extra_vars -- 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" ], + runWhen cse $ CoreCSE, + + -- New opportunities for float-in + runWhen do_float_in CoreDoFloatInwards, + + simplify "post-O2", --------- End of -O2 passes -------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/70ed9a0ccbed39a58121f60e16afb403cab52ff6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/70ed9a0ccbed39a58121f60e16afb403cab52ff6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 17:43:17 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 01 Mar 2024 12:43:17 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24471 Message-ID: <65e213b5c30a_325b45186381863778@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24471 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24471 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 18:54:42 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 01 Mar 2024 13:54:42 -0500 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65e22472c9877_325b453908eb076265@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: 1ec70543 by Zubin Duggal at 2024-03-02T00:24:32+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,20 +1714,20 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) @@ -1737,47 +1736,52 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] +checkHomeUnitsClosed ue home_id_set + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ec70543a6001afb34b33f67036d4492a1cd78b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ec70543a6001afb34b33f67036d4492a1cd78b7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 19:00:42 2024 From: gitlab at gitlab.haskell.org (Bodigrim (@Bodigrim)) Date: Fri, 01 Mar 2024 14:00:42 -0500 Subject: [Git][ghc/ghc][wip/data-list-nonempty-unzip] Data.List.NonEmpty.unzip: use WARNING with category insted of DEPRECATED Message-ID: <65e225dad1c5_325b453a4ac74779e8@gitlab.mail> Bodigrim pushed to branch wip/data-list-nonempty-unzip at Glasgow Haskell Compiler / GHC Commits: 08060313 by Andrew Lelechenko at 2024-03-01T20:00:34+01:00 Data.List.NonEmpty.unzip: use WARNING with category insted of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 4 changed files: - compiler/GHC/Data/Bag.hs - compiler/GHC/HsToCore/Match/Constructor.hs - libraries/base/changelog.md - libraries/base/src/Data/List/NonEmpty.hs Changes: ===================================== compiler/GHC/Data/Bag.hs ===================================== @@ -7,7 +7,7 @@ Bag: an unordered collection with duplicates -} {-# LANGUAGE ScopedTypeVariables, DeriveTraversable, TypeFamilies #-} -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-data-list-nonempty-unzip #-} module GHC.Data.Bag ( Bag, -- abstract type ===================================== compiler/GHC/HsToCore/Match/Constructor.hs ===================================== @@ -2,7 +2,7 @@ {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-data-list-nonempty-unzip #-} {- (c) The University of Glasgow 2006 ===================================== libraries/base/changelog.md ===================================== @@ -17,7 +17,10 @@ * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). - * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) + * Add `{-# WARNING in "x-data-list-nonempty-unzip" #-}` to `Data.List.NonEmpty.unzip`. + Use `{-# OPTIONS_GHC -Wno-x-data-list-nonempty-unzip #-}` to disable it. + ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86) + and [CLC proposal #258](https://github.com/haskell/core-libraries-committee/issues/258)) * Add `System.Mem.performMajorGC` ([CLC proposal #230](https://github.com/haskell/core-libraries-committee/issues/230)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -534,7 +534,7 @@ zipWith f ~(x :| xs) ~(y :| ys) = f x y :| List.zipWith f xs ys -- | The 'unzip' function is the inverse of the 'zip' function. unzip :: Functor f => f (a,b) -> (f a, f b) unzip xs = (fst <$> xs, snd <$> xs) -{-# DEPRECATED unzip "This function will be made monomorphic in base-4.22, consider switching to GHC.Internal.Data.Functor.unzip" #-} +{-# WARNING in "x-data-list-nonempty-unzip" unzip "This function will be made monomorphic in base-4.22, consider switching to Data.Functor.unzip" #-} -- | The 'nub' function removes duplicate elements from a list. In -- particular, it keeps only the first occurrence of each element. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08060313be00f3e5d3fdc9d01c58520b5d640c14 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08060313be00f3e5d3fdc9d01c58520b5d640c14 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 20:02:19 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 01 Mar 2024 15:02:19 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Introduce ListTuplePuns extension Message-ID: <65e2344b6a096_325b455641284838a3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Name.hs - compiler/GHC/Types/Name/Cache.hs - compiler/GHC/Types/Name/Ppr.hs - compiler/GHC/Unit/Types.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/9.10.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/39583c399193b3dedc399f4dccbd222640581956...bbdb6286854dca442ab2b6aeebc734cfb7e0bd9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39583c399193b3dedc399f4dccbd222640581956...bbdb6286854dca442ab2b6aeebc734cfb7e0bd9a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 20:02:56 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 01 Mar 2024 15:02:56 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Improve error messages coming from non-linear patterns Message-ID: <65e23470be0d9_325b4557e39988722f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 13 changed files: - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Types/Origin.hs - docs/users_guide/exts/linear_types.rst - testsuite/tests/linear/should_fail/Linear9.stderr - testsuite/tests/linear/should_fail/LinearAsPat.stderr - testsuite/tests/linear/should_fail/LinearLazyPat.stderr - testsuite/tests/linear/should_fail/LinearLet6.stderr - testsuite/tests/linear/should_fail/LinearLet7.stderr - testsuite/tests/linear/should_fail/LinearPatSyn.stderr - testsuite/tests/linear/should_fail/LinearViewPattern.stderr - testsuite/tests/linear/should_fail/T20083.stderr Changes: ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -1175,7 +1175,7 @@ reportGroup mk_err ctxt items -- See Note [No deferring for multiplicity errors] nonDeferrableOrigin :: CtOrigin -> Bool -nonDeferrableOrigin NonLinearPatternOrigin = True +nonDeferrableOrigin (NonLinearPatternOrigin {}) = True nonDeferrableOrigin (UsageEnvironmentOf {}) = True nonDeferrableOrigin (FRROrigin {}) = True nonDeferrableOrigin _ = False ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -804,7 +804,7 @@ tcPolyInfer rec_tc prag_fn tc_sig_fn bind_list manyIfPat bind@(L _ (PatBind{pat_lhs=(L _ (VarPat{}))})) = return bind manyIfPat (L loc pat@(PatBind {pat_mult=mult_ann, pat_lhs=lhs, pat_ext =(pat_ty,_)})) - = do { mult_co_wrap <- tcSubMult NonLinearPatternOrigin ManyTy (getTcMultAnn mult_ann) + = do { mult_co_wrap <- tcSubMult (NonLinearPatternOrigin GeneralisedPatternReason nlWildPatName) ManyTy (getTcMultAnn mult_ann) -- The wrapper checks for correct multiplicities. -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; let lhs' = mkLHsWrapPat mult_co_wrap lhs pat_ty ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -114,14 +114,14 @@ tcLetPat sig_fn no_gen pat pat_ty thing_inside | xopt LangExt.Strict dflags = xstrict lpat | otherwise = not_xstrict lpat where - xstrict (L _ (LazyPat _ _)) = checkManyPattern pat_ty + xstrict p@(L _ (LazyPat _ _)) = checkManyPattern LazyPatternReason p pat_ty xstrict (L _ (ParPat _ p)) = xstrict p xstrict _ = return WpHole not_xstrict (L _ (BangPat _ _)) = return WpHole not_xstrict (L _ (VarPat _ _)) = return WpHole not_xstrict (L _ (ParPat _ p)) = not_xstrict p - not_xstrict _ = checkManyPattern pat_ty + not_xstrict p = checkManyPattern LazyPatternReason p pat_ty ----------------- tcMatchPats :: forall a. @@ -467,8 +467,8 @@ tc_lpats tys penv pats -------------------- -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -checkManyPattern :: Scaled a -> TcM HsWrapper -checkManyPattern pat_ty = tcSubMult NonLinearPatternOrigin ManyTy (scaledMult pat_ty) +checkManyPattern :: NonLinearPatternReason -> LPat GhcRn -> Scaled a -> TcM HsWrapper +checkManyPattern reason pat pat_ty = tcSubMult (NonLinearPatternOrigin reason pat) ManyTy (scaledMult pat_ty) tc_forall_lpat :: TcTyVar -> Checker (LPat GhcRn) (LPat GhcTc) @@ -582,7 +582,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of ; return (BangPat x pat', res) } LazyPat x pat -> do - { mult_wrap <- checkManyPattern pat_ty + { mult_wrap <- checkManyPattern LazyPatternReason (noLocA ps_pat) pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (pat', (res, pat_ct)) <- tc_lpat pat_ty (makeLazy penv) pat $ @@ -600,14 +600,14 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of ; return (mkHsWrapPat mult_wrap (LazyPat x pat') pat_ty, res) } WildPat _ -> do - { mult_wrap <- checkManyPattern pat_ty + { mult_wrap <- checkManyPattern OtherPatternReason (noLocA ps_pat) pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; res <- thing_inside ; pat_ty <- expTypeToType (scaledThing pat_ty) ; return (mkHsWrapPat mult_wrap (WildPat pat_ty) pat_ty, res) } AsPat x (L nm_loc name) pat -> do - { mult_wrap <- checkManyPattern pat_ty + { mult_wrap <- checkManyPattern OtherPatternReason (noLocA ps_pat) pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (wrap, bndr_id) <- setSrcSpanA nm_loc (tcPatBndr penv name pat_ty) ; (pat', res) <- tcExtendIdEnv1 name bndr_id $ @@ -624,7 +624,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of ; return (mkHsWrapPat (wrap <.> mult_wrap) (AsPat x (L nm_loc bndr_id) pat') pat_ty, res) } ViewPat _ expr pat -> do - { mult_wrap <- checkManyPattern pat_ty + { mult_wrap <- checkManyPattern ViewPatternReason (noLocA ps_pat) pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- It should be possible to have view patterns at linear (or otherwise @@ -790,7 +790,7 @@ Fortunately that's what matchActualFunTy returns anyway. -- -- When there is no negation, neg_lit_ty and lit_ty are the same NPat _ (L l over_lit) mb_neg eq -> do - { mult_wrap <- checkManyPattern pat_ty + { mult_wrap <- checkManyPattern OtherPatternReason (noLocA ps_pat) pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- It may be possible to refine linear pattern so that they work in @@ -843,7 +843,7 @@ AST is used for the subtraction operation. -- See Note [NPlusK patterns] NPlusKPat _ (L nm_loc name) (L loc lit) _ ge minus -> do - { mult_wrap <- checkManyPattern pat_ty + { mult_wrap <- checkManyPattern OtherPatternReason (noLocA ps_pat) pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; let pat_exp_ty = scaledThing pat_ty orig = LiteralOrigin lit @@ -1225,7 +1225,7 @@ tcPatSynPat (L con_span con_name) pat_syn pat_ty penv arg_pats thing_inside ; when (any isEqPred prov_theta) warnMonoLocalBinds - ; mult_wrap <- checkManyPattern pat_ty + ; mult_wrap <- checkManyPattern PatternSynonymReason nlWildPatName pat_ty -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (univ_ty_args, ex_ty_args) <- splitConTyArgs con_like arg_pats ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -22,7 +22,7 @@ module GHC.Tc.Types.Origin ( isVisibleOrigin, toInvisibleOrigin, pprCtOrigin, isGivenOrigin, isWantedWantedFunDepOrigin, isWantedSuperclassOrigin, - ClsInstOrQC(..), NakedScFlag(..), + ClsInstOrQC(..), NakedScFlag(..), NonLinearPatternReason(..), TypedThing(..), TyVarBndrs(..), @@ -621,7 +621,7 @@ data CtOrigin Module -- ^ Module in which the instance was declared ClsInst -- ^ The declared typeclass instance - | NonLinearPatternOrigin + | NonLinearPatternOrigin NonLinearPatternReason (LPat GhcRn) | UsageEnvironmentOf Name | CycleBreakerOrigin @@ -642,6 +642,12 @@ data CtOrigin Type -- the instantiated type of the method | AmbiguityCheckOrigin UserTypeCtxt +data NonLinearPatternReason + = LazyPatternReason + | GeneralisedPatternReason + | PatternSynonymReason + | ViewPatternReason + | OtherPatternReason -- | The number of superclass selections needed to get this Given. -- If @d :: C ty@ has @ScDepth=2@, then the evidence @d@ will look @@ -881,6 +887,10 @@ pprCtOrigin (ScOrigin (IsQC orig) nkd) , whenPprDebug (braces (text "sc-origin:" <> ppr nkd)) , pprCtOrigin orig ] +pprCtOrigin (NonLinearPatternOrigin reason pat) + = hang (ctoHerald <+> text "a non-linear pattern" <+> quotes (ppr pat)) + 2 (pprNonLinearPatternReason reason) + pprCtOrigin simple_origin = ctoHerald <+> pprCtO simple_origin @@ -921,7 +931,6 @@ pprCtO PatCheckOrigin = text "a pattern-match completeness check" pprCtO ListOrigin = text "an overloaded list" pprCtO IfThenElseOrigin = text "an if-then-else expression" pprCtO StaticOrigin = text "a static form" -pprCtO NonLinearPatternOrigin = text "a non-linear pattern" pprCtO (UsageEnvironmentOf x) = hsep [text "multiplicity of", quotes (ppr x)] pprCtO BracketOrigin = text "a quotation bracket" @@ -949,7 +958,14 @@ pprCtO (WantedSuperclassOrigin {}) = text "a superclass constraint" pprCtO (InstanceSigOrigin {}) = text "a type signature in an instance" pprCtO (AmbiguityCheckOrigin {}) = text "a type ambiguity check" pprCtO (ImpedanceMatching {}) = text "combining required constraints" - +pprCtO (NonLinearPatternOrigin _ pat) = hsep [text "a non-linear pattern" <+> quotes (ppr pat)] + +pprNonLinearPatternReason :: HasCallStack => NonLinearPatternReason -> SDoc +pprNonLinearPatternReason LazyPatternReason = parens (text "non-variable lazy pattern aren't linear") +pprNonLinearPatternReason GeneralisedPatternReason = parens (text "non-variable pattern bindings that have been generalised aren't linear") +pprNonLinearPatternReason PatternSynonymReason = parens (text "pattern synonyms aren't linear") +pprNonLinearPatternReason ViewPatternReason = parens (text "view patterns aren't linear") +pprNonLinearPatternReason OtherPatternReason = empty {- ********************************************************************* * * ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -119,7 +119,7 @@ multiplicity if: - The binding is a pattern binding (including a simple variable) ``p=e`` (you can't write ``let %1 f x = u``, instead write ``let %1 f = \x -> u``) -- Either ``p`` is of the form ``!p'`` or ``p`` is a variable. In +- Either ``p`` is strict (see infra) or ``p`` is a variable. In particular neither ``x at y`` nor ``(x)`` are covered by “is a variable” @@ -136,13 +136,79 @@ as follows: - In all other cases, including function bindings ``let f x1...xn = rhs``, the multiplicity is inferred from the term. -When ``-XMonoLocalBinds`` is on, the following also holds: +When ``-XMonoLocalBinds`` is off, the following also holds: - Multiplicity-annotated non-variable pattern-bindings (such as ``let %1 !(x,y) = rhs``) are never generalised. - Non-variable pattern bindings which are inferred as polymorphic or qualified are inferred as having multiplicity ``Many``. +Strict patterns +~~~~~~~~~~~~~~~ + +GHC considers that non-variable lazy patterns consume the scrutinee +with multiplicity ``Many``. In practice, a pattern is strict (hence +can be linear) if (otherwise the pattern is lazy): + +- The pattern is a case alternative and isn't annotated with a ``~`` +- The pattern is a let-binding, and is annotated with a ``!`` +- The pattern is a let-binding, :extension:`Strict` is on, and isn't + annotated with a ``~`` +- The pattern is nested inside a strict pattern + +Here are some examples of the impact on linear typing: + +Without ``-XStrict``:: + + -- good + let %1 x = u in … + + -- good + let %1 !x = u in … + + -- bad + let %1 (x, y) = u in … + + -- good + let %Many (x, y) = u in … + + -- good + let %1 !(x, y) = u in … + + -- good + let %1 (!(x, y)) = u in … + + -- inferred unrestricted + let (x, y) = u in … + + -- can be inferred linear + case u of (x, y) -> … + + -- inferred unrestricted + case u of ~(x, y) -> … + +With ``-XStrict``:: + -- good + let %1 x = u in … + + -- good + let %1 !x = u in … + + -- good + let %1 (x, y) = u in … + + -- bad + let %1 ~(x, y) = u in … + + -- good + let %Many ~(x, y) = u in … + + -- can be inferred linear + let (x, y) = u in … + + -- inferred unrestricted + let ~(x, y) = u in … + Data types ---------- By default, all fields in algebraic data types are linear (even if ===================================== testsuite/tests/linear/should_fail/Linear9.stderr ===================================== @@ -1,7 +1,7 @@ Linear9.hs:9:17: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ • In the pattern: _ In the pattern: (a, _) In an equation for ‘incorrectFst’: incorrectFst (a, _) = a @@ -21,14 +21,14 @@ Linear9.hs:15:20: error: [GHC-18872] Linear9.hs:18:21: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ • In the pattern: _ In the pattern: (a, _) In the pattern: ((a, _), _) Linear9.hs:18:24: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ • In the pattern: _ In the pattern: ((a, _), _) In an equation for ‘incorrectFstFst’: @@ -36,7 +36,7 @@ Linear9.hs:18:24: error: [GHC-18872] Linear9.hs:25:25: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ • In the pattern: _ In the pattern: Foo a _ In an equation for ‘incorrectTestFst’: ===================================== testsuite/tests/linear/should_fail/LinearAsPat.stderr ===================================== @@ -1,5 +1,5 @@ LinearAsPat.hs:6:12: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘x at True’ • In an equation for ‘shouldFail’: shouldFail x at True = x ===================================== testsuite/tests/linear/should_fail/LinearLazyPat.stderr ===================================== @@ -1,6 +1,7 @@ LinearLazyPat.hs:5:3: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘~(x, y)’ + (non-variable lazy pattern aren't linear) • In the pattern: ~(x, y) In an equation for ‘f’: f ~(x, y) = (y, x) ===================================== testsuite/tests/linear/should_fail/LinearLet6.stderr ===================================== @@ -15,7 +15,8 @@ LinearLet6.hs:10:3: error: [GHC-18872] LinearLet6.hs:15:14: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘Just y’ + (non-variable lazy pattern aren't linear) • In a pattern binding: (Just y) = x In the expression: let %1 (Just y) = x in y In an equation for ‘h’: h x = let %1 (Just y) = x in y ===================================== testsuite/tests/linear/should_fail/LinearLet7.stderr ===================================== @@ -8,6 +8,7 @@ LinearLet7.hs:6:14: error: [GHC-18872] LinearLet7.hs:6:14: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ + (non-variable pattern bindings that have been generalised aren't linear) • In the expression: let %1 g = \ y -> ... in g x In an equation for ‘f’: f x = let %1 g = ... in g x ===================================== testsuite/tests/linear/should_fail/LinearPatSyn.stderr ===================================== @@ -1,6 +1,7 @@ LinearPatSyn.hs:13:4: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ + (pattern synonyms aren't linear) • In the pattern: P y x In an equation for ‘s’: s (P y x) = (y, x) ===================================== testsuite/tests/linear/should_fail/LinearViewPattern.stderr ===================================== @@ -1,6 +1,7 @@ LinearViewPattern.hs:11:4: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘not -> True’ + (view patterns aren't linear) • In the pattern: not -> True In an equation for ‘f’: f (not -> True) = True ===================================== testsuite/tests/linear/should_fail/T20083.stderr ===================================== @@ -13,6 +13,6 @@ T20083.hs:6:6: error: [GHC-25897] T20083.hs:9:5: error: [GHC-18872] • Couldn't match type ‘Many’ with ‘One’ - arising from a non-linear pattern + arising from a non-linear pattern ‘_’ • In the pattern: _ In an equation for ‘ap2’: ap2 _ = () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bbdb6286854dca442ab2b6aeebc734cfb7e0bd9a...6612388e0e360bd4f6eaddee3f632deed8616a5e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bbdb6286854dca442ab2b6aeebc734cfb7e0bd9a...6612388e0e360bd4f6eaddee3f632deed8616a5e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 22:06:04 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 01 Mar 2024 17:06:04 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/weird-sign-extends Message-ID: <65e2514cc8670_3cfa0d35198b8369e1@gitlab.mail> Matthew Craven pushed new branch wip/weird-sign-extends at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/weird-sign-extends You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 1 22:33:26 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 01 Mar 2024 17:33:26 -0500 Subject: [Git][ghc/ghc][wip/T24471] 13 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e257b69d9ac_3cfa0d4130ca040428@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - e85fa5a8 by Simon Peyton Jones at 2024-03-01T22:33:18+00:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 3.5%, and much more in artificial cases. Metric Decrease: CoOpt_Read - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors.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/f4e4ecd37911431b15349d39ea4bd948ca6fd386...e85fa5a8daedafa2304290ef803bdfa5edf53d9c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f4e4ecd37911431b15349d39ea4bd948ca6fd386...e85fa5a8daedafa2304290ef803bdfa5edf53d9c You're receiving 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 Mar 2 02:21:40 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 01 Mar 2024 21:21:40 -0500 Subject: [Git][ghc/ghc][wip/weird-sign-extends] Work around untracked dependencies Message-ID: <65e28d3450255_3cfa0da1d58e4577a6@gitlab.mail> Matthew Craven pushed to branch wip/weird-sign-extends at Glasgow Haskell Compiler / GHC Commits: afec6c32 by Matthew Craven at 2024-03-01T21:21:17-05:00 Work around untracked dependencies This is a temporary hack, until ghc properly reports the implicit dependency of every module outside of ghc-bignum or ghc-prim on GHC.Num.BigNat. Otherwise we see CI failures. See also #23942. - - - - - 3 changed files: - compiler/GHC/Utils/Containers/Internal/StrictPair.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs Changes: ===================================== compiler/GHC/Utils/Containers/Internal/StrictPair.hs ===================================== @@ -4,6 +4,10 @@ module GHC.Utils.Containers.Internal.StrictPair (StrictPair(..), toPair) where +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () + + -- | The same as a regular Haskell pair, but -- -- @ ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -81,3 +81,6 @@ module Data.Sum.Experimental ( ) where import GHC.Types + +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,6 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes + +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afec6c32dca543203068ff5029d453ae52db1ccf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afec6c32dca543203068ff5029d453ae52db1ccf You're receiving 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 Mar 2 03:31:44 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 01 Mar 2024 22:31:44 -0500 Subject: [Git][ghc/ghc][wip/weird-sign-extends] Work around untracked dependencies Message-ID: <65e29da05d804_3cfa0dc29032c580ed@gitlab.mail> Matthew Craven pushed to branch wip/weird-sign-extends at Glasgow Haskell Compiler / GHC Commits: b3069ef5 by Matthew Craven at 2024-03-01T22:31:18-05:00 Work around untracked dependencies This is a temporary hack, until ghc properly reports the implicit dependency of every module outside of ghc-bignum or ghc-prim on GHC.Num.BigNat. Otherwise we see CI failures. See also #23942. - - - - - 4 changed files: - compiler/GHC/Utils/Containers/Internal/StrictPair.hs - libraries/base/src/GHC/IO/Encoding/Iconv.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs Changes: ===================================== compiler/GHC/Utils/Containers/Internal/StrictPair.hs ===================================== @@ -4,6 +4,10 @@ module GHC.Utils.Containers.Internal.StrictPair (StrictPair(..), toPair) where +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () + + -- | The same as a regular Haskell pair, but -- -- @ ===================================== libraries/base/src/GHC/IO/Encoding/Iconv.hs ===================================== @@ -27,4 +27,7 @@ import GHC.Internal.IO.Encoding.Iconv #else ( ) where +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () + #endif ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -81,3 +81,6 @@ module Data.Sum.Experimental ( ) where import GHC.Types + +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,6 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes + +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3069ef5d89a8d6d2a36f2166b327fd8d0582064 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3069ef5d89a8d6d2a36f2166b327fd8d0582064 You're receiving 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 Mar 2 04:34:22 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 01 Mar 2024 23:34:22 -0500 Subject: [Git][ghc/ghc][wip/weird-sign-extends] Work around untracked dependencies Message-ID: <65e2ac4e11a51_3cfa0dddc1560585f@gitlab.mail> Matthew Craven pushed to branch wip/weird-sign-extends at Glasgow Haskell Compiler / GHC Commits: 0bb5001f by Matthew Craven at 2024-03-01T23:33:20-05:00 Work around untracked dependencies This is a temporary hack, until ghc properly reports the implicit dependency of every module outside of ghc-bignum or ghc-prim on GHC.Num.BigNat. Otherwise we see CI failures. See also #23942. - - - - - 4 changed files: - compiler/GHC/Utils/Containers/Internal/StrictPair.hs - libraries/base/src/GHC/IO/Encoding/Iconv.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs Changes: ===================================== compiler/GHC/Utils/Containers/Internal/StrictPair.hs ===================================== @@ -4,6 +4,10 @@ module GHC.Utils.Containers.Internal.StrictPair (StrictPair(..), toPair) where +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () + + -- | The same as a regular Haskell pair, but -- -- @ ===================================== libraries/base/src/GHC/IO/Encoding/Iconv.hs ===================================== @@ -27,4 +27,7 @@ import GHC.Internal.IO.Encoding.Iconv #else ( ) where +-- stupid build-order workaround until #23942 is properly fixed +import Prelude () + #endif ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -81,3 +81,6 @@ module Data.Sum.Experimental ( ) where import GHC.Types + +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,6 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes + +-- stupid build-order workaround until #23942 is properly fixed +import GHC.Base () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bb5001f5263b9b986877ccd0da9b21a8ac1f91b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bb5001f5263b9b986877ccd0da9b21a8ac1f91b You're receiving 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 Mar 2 10:01:32 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 02 Mar 2024 05:01:32 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Ensure __clzdi2 builtin is around Message-ID: <65e2f8fcc1b2b_245adb7211694966c4@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: a528db71 by Sven Tennie at 2024-03-02T11:00:57+01:00 Ensure __clzdi2 builtin is around - - - - - 1 changed file: - rts/RtsSymbols.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -971,6 +971,13 @@ extern char **environ; #define RTS_LIBGCC_SYMBOLS #endif +#if defined(riscv64_HOST_ARCH) +#define RTS_ARCH_LIBGCC_SYMBOLS \ + SymI_NeedsProto(__clzdi2) +#else +#define RTS_ARCH_LIBGCC_SYMBOLS +#endif + // Symbols defined by libgcc/compiler-rt for AArch64's outline atomics. #if defined(HAVE_ARM_OUTLINE_ATOMICS) #include "ARMOutlineAtomicsSymbols.h" @@ -1023,6 +1030,7 @@ RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBC_SYMBOLS RTS_LIBGCC_SYMBOLS +RTS_ARCH_LIBGCC_SYMBOLS RTS_FINI_ARRAY_SYMBOLS RTS_LIBFFI_SYMBOLS RTS_ARM_OUTLINE_ATOMIC_SYMBOLS @@ -1065,6 +1073,7 @@ RtsSymbolVal rtsSyms[] = { RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS + RTS_ARCH_LIBGCC_SYMBOLS RTS_FINI_ARRAY_SYMBOLS RTS_LIBFFI_SYMBOLS RTS_ARM_OUTLINE_ATOMIC_SYMBOLS View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a528db715df4e8ecb7062ed05780da031e6c92ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a528db715df4e8ecb7062ed05780da031e6c92ce You're receiving 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 Mar 2 16:42:08 2024 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Sat, 02 Mar 2024 11:42:08 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] Add .stdout for T24496 test Message-ID: <65e356dfe63b0_16b1d16134cb8967ef@gitlab.mail> sheaf pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: b3e9e352 by sheaf at 2024-03-02T17:37:05+01:00 Add .stdout for T24496 test - - - - - 1 changed file: - + testsuite/tests/primops/should_run/T24496.stdout Changes: ===================================== testsuite/tests/primops/should_run/T24496.stdout ===================================== @@ -0,0 +1,2 @@ +(6.0,0.0) +(6.0,0.0) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3e9e3520c83481fc426e54d9ead53f8510e603c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3e9e3520c83481fc426e54d9ead53f8510e603c You're receiving 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 Mar 2 16:54:32 2024 From: gitlab at gitlab.haskell.org (Bodigrim (@Bodigrim)) Date: Sat, 02 Mar 2024 11:54:32 -0500 Subject: [Git][ghc/ghc][wip/data-list-nonempty-unzip] 13 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e359c8dffd1_16b1d1686cf5810081a@gitlab.mail> Bodigrim pushed to branch wip/data-list-nonempty-unzip at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - e4c9fc80 by Andrew Lelechenko at 2024-03-02T17:54:22+01:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Bind.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08060313be00f3e5d3fdc9d01c58520b5d640c14...e4c9fc80011e54fc1f9bb1c117c138c2fd484644 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08060313be00f3e5d3fdc9d01c58520b5d640c14...e4c9fc80011e54fc1f9bb1c117c138c2fd484644 You're receiving 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 Mar 2 19:11:16 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 02 Mar 2024 14:11:16 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Introduce ListTuplePuns extension Message-ID: <65e379d4ae6eb_16b1d1a4e27e411005e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 338b923b by Cheng Shao at 2024-03-02T14:11:12-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - df863128 by Andrew Lelechenko at 2024-03-02T14:11:13-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Validity.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fefb63f1fad3c66f8984636bbaad541de6c28137...df8631287d4fa20ca2f19619c289c630e3e1c040 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fefb63f1fad3c66f8984636bbaad541de6c28137...df8631287d4fa20ca2f19619c289c630e3e1c040 You're receiving 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 Mar 2 20:00:24 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Sat, 02 Mar 2024 15:00:24 -0500 Subject: [Git][ghc/ghc][wip/T17879] 21 commits: Fix formatting in whereFrom docstring Message-ID: <65e385586422c_16b1d1bad1640116914@gitlab.mail> Jade pushed to branch wip/T17879 at Glasgow Haskell Compiler / GHC Commits: 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 33606b27 by Jade at 2024-03-02T21:04:30+01:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/Cmm/Reducibility.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/4f5bc9caf745aacf77beabb93490c7c3f2e2ba99...33606b27ece6ace0eb314b195b04d63232efc5cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f5bc9caf745aacf77beabb93490c7c3f2e2ba99...33606b27ece6ace0eb314b195b04d63232efc5cb You're receiving 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 Mar 2 21:26:20 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 02 Mar 2024 16:26:20 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Add symbol prototype for __ctzdi2 Message-ID: <65e3997cb0a93_16b1d1dc8530412371c@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: a4742d26 by Sven Tennie at 2024-03-02T22:25:45+01:00 Add symbol prototype for __ctzdi2 - - - - - 1 changed file: - rts/RtsSymbols.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -972,8 +972,11 @@ extern char **environ; #endif #if defined(riscv64_HOST_ARCH) +// See https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html +// as reference for the following built-ins. #define RTS_ARCH_LIBGCC_SYMBOLS \ - SymI_NeedsProto(__clzdi2) + SymI_NeedsProto(__clzdi2) \ + SymI_NeedsProto(__ctzdi2) #else #define RTS_ARCH_LIBGCC_SYMBOLS #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4742d26bceb2f76e01b94238c2b5c0dc4695656 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4742d26bceb2f76e01b94238c2b5c0dc4695656 You're receiving 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 Mar 2 22:11:41 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 02 Mar 2024 17:11:41 -0500 Subject: [Git][ghc/ghc][master] compiler: start deprecating cmmToRawCmmHook Message-ID: <65e3a41dc1f24_16b1d1f7533981306f6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 2 changed files: - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs Changes: ===================================== compiler/GHC/Driver/Hooks.hs ===================================== @@ -154,6 +154,8 @@ data Hooks = Hooks -> IO (Stream IO RawCmmGroup a))) } +{-# DEPRECATED cmmToRawCmmHook "cmmToRawCmmHook is being deprecated. If you do use it in your project, please raise a GHC issue!" #-} + class HasHooks m where getHooks :: m Hooks ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -6,6 +6,9 @@ {-# OPTIONS_GHC -fprof-auto-top #-} +-- Remove this after cmmToRawCmmHook removal +{-# OPTIONS_GHC -Wno-deprecations #-} + ------------------------------------------------------------------------------- -- -- | Main API for compiling plain Haskell source code. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c064ef1f3e1aa2afc996e962ad53effa99ec5f4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c064ef1f3e1aa2afc996e962ad53effa99ec5f4 You're receiving 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 Mar 2 22:12:22 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 02 Mar 2024 17:12:22 -0500 Subject: [Git][ghc/ghc][master] Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED Message-ID: <65e3a446a7ba6_16b1d1f8e2164133560@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 4 changed files: - compiler/GHC/Data/Bag.hs - compiler/GHC/HsToCore/Match/Constructor.hs - libraries/base/changelog.md - libraries/base/src/Data/List/NonEmpty.hs Changes: ===================================== compiler/GHC/Data/Bag.hs ===================================== @@ -7,7 +7,7 @@ Bag: an unordered collection with duplicates -} {-# LANGUAGE ScopedTypeVariables, DeriveTraversable, TypeFamilies #-} -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-data-list-nonempty-unzip #-} module GHC.Data.Bag ( Bag, -- abstract type ===================================== compiler/GHC/HsToCore/Match/Constructor.hs ===================================== @@ -2,7 +2,7 @@ {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-data-list-nonempty-unzip #-} {- (c) The University of Glasgow 2006 ===================================== libraries/base/changelog.md ===================================== @@ -17,7 +17,10 @@ * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). - * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) + * Add `{-# WARNING in "x-data-list-nonempty-unzip" #-}` to `Data.List.NonEmpty.unzip`. + Use `{-# OPTIONS_GHC -Wno-x-data-list-nonempty-unzip #-}` to disable it. + ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86) + and [CLC proposal #258](https://github.com/haskell/core-libraries-committee/issues/258)) * Add `System.Mem.performMajorGC` ([CLC proposal #230](https://github.com/haskell/core-libraries-committee/issues/230)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -534,7 +534,7 @@ zipWith f ~(x :| xs) ~(y :| ys) = f x y :| List.zipWith f xs ys -- | The 'unzip' function is the inverse of the 'zip' function. unzip :: Functor f => f (a,b) -> (f a, f b) unzip xs = (fst <$> xs, snd <$> xs) -{-# DEPRECATED unzip "This function will be made monomorphic in base-4.22, consider switching to GHC.Internal.Data.Functor.unzip" #-} +{-# WARNING in "x-data-list-nonempty-unzip" unzip "This function will be made monomorphic in base-4.22, consider switching to Data.Functor.unzip" #-} -- | The 'nub' function removes duplicate elements from a list. In -- particular, it keeps only the first occurrence of each element. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b74845f740785744ea5a22e2b0677d1bab2a92c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b74845f740785744ea5a22e2b0677d1bab2a92c You're receiving 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 Mar 3 01:22:21 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 02 Mar 2024 20:22:21 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] 3 commits: Add comment Message-ID: <65e3d0cd7eadc_16b1d114eff5c41465e3@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: bd2e505d by Sven Tennie at 2024-03-03T02:05:50+01:00 Add comment - - - - - 4df27780 by Sven Tennie at 2024-03-03T02:07:01+01:00 Only trace message on flag - - - - - 05121e86 by Sven Tennie at 2024-03-03T02:20:01+01:00 Check int size on 32 bit width We're handing around 32bit integers. - - - - - 2 changed files: - rts/RtsSymbols.c - rts/linker/elf_reloc_riscv64.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -972,8 +972,9 @@ extern char **environ; #endif #if defined(riscv64_HOST_ARCH) -// See https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html -// as reference for the following built-ins. +// See https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html as +// reference for the following built-ins. __clzdi2 and __ctzdi2 probably relate +// to __builtin-s in libraries/ghc-prim/cbits/ctz.c. #define RTS_ARCH_LIBGCC_SYMBOLS \ SymI_NeedsProto(__clzdi2) \ SymI_NeedsProto(__ctzdi2) ===================================== rts/linker/elf_reloc_riscv64.c ===================================== @@ -90,22 +90,24 @@ int32_t decodeAddendRISCV64(Section *section STG_UNUSED, abort(/* we don't support Rel locations yet. */); } -// Sign-extend the number in the bottom B bits of X to a 64-bit integer. -// Requires 0 < B <= 64. -int64_t SignExtend64(uint64_t X, unsigned B) { +// Sign-extend the number in the bottom B bits of X to a 32-bit integer. +// Requires 0 < B <= 32. (32 bit is sufficient as we can only encode 20 + 12 = +// 32 bit in a relocation pair.) +int32_t SignExtend32(uint32_t X, unsigned B) { assert(B > 0 && "Bit width can't be 0."); - assert(B <= 64 && "Bit width out of range."); - return (int64_t)(X << (64 - B)) >> (64 - B); + assert(B <= 32 && "Bit width out of range."); + return (int32_t)(X << (32 - B)) >> (32 - B); } // Make sure that V can be represented as an N bit signed integer. -void checkInt(inst_t *loc, int64_t v, int n) { - if (v != SignExtend64(v, n)) { - debugBelch("Relocation at 0x%x is out of range. value: 0x%lx (%ld), " - "sign-extended value: 0x%lx (%ld), max bits 0x%x (%d)\n", - *loc, v, v, SignExtend64(v, n), SignExtend64(v, n), n, n); +void checkInt(inst_t *loc, int32_t v, int n) { + if (v != SignExtend32(v, n)) { + debugBelch("Relocation at 0x%x is out of range. value: 0x%x (%d), " + "sign-extended value: 0x%x (%d), max bits 0x%x (%d)\n", + *loc, v, v, SignExtend32(v, n), SignExtend32(v, n), n, n); } } + // RISCV is little-endian by definition. void write8le(uint8_t *p, uint8_t v) { *p = v; } @@ -149,8 +151,8 @@ uint32_t setLO12_S(uint32_t insn, uint32_t imm) { void setUType(inst_t *loc, int32_t val) { const unsigned bits = 32; uint32_t hi = val + 0x800; - checkInt(loc, SignExtend64(hi, bits) >> 12, 20); - debugBelch("setUType: hi 0x%x val 0x%x\n", hi, val); + checkInt(loc, SignExtend32(hi, bits) >> 12, 20); + IF_DEBUG(linker, debugBelch("setUType: hi 0x%x val 0x%x\n", hi, val)); write32le(loc, (read32le(loc) & 0xFFF) | (hi & 0xFFFFF000)); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4742d26bceb2f76e01b94238c2b5c0dc4695656...05121e86e727168ef4ed5d9188e482e271d1d5d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4742d26bceb2f76e01b94238c2b5c0dc4695656...05121e86e727168ef4ed5d9188e482e271d1d5d9 You're receiving 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 Mar 3 18:34:00 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 03 Mar 2024 13:34:00 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/fix-showastdata Message-ID: <65e4c2986b665_2b6de341c803c84383@gitlab.mail> Alan Zimmerman pushed new branch wip/az/fix-showastdata at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/fix-showastdata You're receiving 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 Mar 3 20:21:52 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sun, 03 Mar 2024 15:21:52 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/supersven/aarch64-NEED_SYMBOL_EXTRAS Message-ID: <65e4dbe0db069_2b6de36d50a60845c1@gitlab.mail> Sven Tennie pushed new branch wip/supersven/aarch64-NEED_SYMBOL_EXTRAS at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/supersven/aarch64-NEED_SYMBOL_EXTRAS You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 04:07:07 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Sun, 03 Mar 2024 23:07:07 -0500 Subject: [Git][ghc/ghc][wip/fprof-overloaded] add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e548ebecde7_2b6de313190768932b9@gitlab.mail> Finley McIlwaine pushed to branch wip/fprof-overloaded at Glasgow Haskell Compiler / GHC Commits: 7da9a1c3 by Finley McIlwaine at 2024-03-03T20:06:03-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods - - - - - 26 changed files: - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -1,164 +1,90 @@ -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE TupleSections #-} +{-# LANGUAGE RecordWildCards #-} --- | Adds cost-centers after the core piple has run. +-- | Adds cost-centers after the core pipline has run. module GHC.Core.LateCC - ( addLateCostCentresMG - , addLateCostCentresPgm - , addLateCostCentres -- Might be useful for API users - , Env(..) + ( -- * Inserting cost centres + addLateCostCenters ) where -import Control.Applicative -import Control.Monad -import qualified Data.Set as S - import GHC.Prelude -import GHC.Types.CostCentre -import GHC.Types.CostCentre.State -import GHC.Types.Name hiding (varName) -import GHC.Types.Tickish -import GHC.Unit.Module.ModGuts -import GHC.Types.Var -import GHC.Unit.Types -import GHC.Data.FastString -import GHC.Core -import GHC.Core.Opt.Monad -import GHC.Core.Utils (mkTick) -import GHC.Types.Id -import GHC.Driver.DynFlags +import GHC.Core +import GHC.Core.LateCC.OverloadedCalls +import GHC.Core.LateCC.TopLevelBinds +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Seq +import qualified GHC.Data.Strict as Strict +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.SrcLoc +import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Utils.Misc -import GHC.Utils.Error (withTiming) -import GHC.Utils.Monad.State.Strict - - -{- Note [Collecting late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Usually cost centres defined by a module are collected -during tidy by collectCostCentres. However with `-fprof-late` -we insert cost centres after inlining. So we keep a list of -all the cost centres we inserted and combine that with the list -of cost centres found during tidy. - -To avoid overhead when using -fprof-inline there is a flag to stop -us from collecting them here when we run this pass before tidy. - -Note [Adding late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The basic idea is very simple. For every top level binder -`f = rhs` we compile it as if the user had written -`f = {-# SCC f #-} rhs`. - -If we do this after unfoldings for `f` have been created this -doesn't impact core-level optimizations at all. If we do it -before the cost centre will be included in the unfolding and -might inhibit optimizations at the call site. For this reason -we provide flags for both approaches as they have different -tradeoffs. - -We also don't add a cost centre for any binder that is a constructor -worker or wrapper. These will never meaningfully enrich the resulting -profile so we improve efficiency by omitting those. - --} - -addLateCostCentresMG :: ModGuts -> CoreM ModGuts -addLateCostCentresMG guts = do - dflags <- getDynFlags - let env :: Env - env = Env - { thisModule = mg_module guts - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = False -- See Note [Collecting late cost centres] - } - let guts' = guts { mg_binds = fstOf3 (addLateCostCentres env (mg_binds guts)) - } - return guts' - -addLateCostCentresPgm :: DynFlags -> Logger -> Module -> CoreProgram -> IO (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentresPgm dflags logger mod binds = - withTiming logger - (text "LateCC"<+>brackets (ppr mod)) - (\(a,b,c) -> a `seqList` (b `seq` (c `seq` ()))) $ do - let env = Env - { thisModule = mod - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = True -- See Note [Collecting late cost centres] - } - (binds', ccs, cc_state) = addLateCostCentres env binds - when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ - putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr binds')) - return (binds', ccs, cc_state) -addLateCostCentres :: Env -> CoreProgram -> (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentres env binds = - let (binds', state) = runState (mapM (doBind env) binds) initLateCCState - in (binds', lcs_ccs state, lcs_state state) - - -doBind :: Env -> CoreBind -> M CoreBind -doBind env (NonRec b rhs) = NonRec b <$> doBndr env b rhs -doBind env (Rec bs) = Rec <$> mapM doPair bs +-- | Late cost center insertion logic used by the driver +addLateCostCenters :: + Logger + -- ^ Logger + -> LateCCConfig + -- ^ Late cost center configuration + -> CoreProgram + -- ^ The program + -> IO (CoreProgram, LateCCState (Strict.Maybe SrcSpan)) +addLateCostCenters logger LateCCConfig{..} core_binds = do + + -- If top-level late CCs are enabled via either -fprof-late or + -- -fprof-late-overloaded, add them + (top_level_cc_binds, top_level_late_cc_state) <- + case lateCCConfig_whichBinds of + LateCCNone -> + return (core_binds, initLateCCState ()) + _ -> + withTiming + logger + (text "LateTopLevelCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateTopLevelCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (initLateCCState ()) + (topLevelBindsCC top_level_cc_pred) + core_binds + + -- If overloaded call CCs are enabled via -fprof-late-overloaded-calls, add + -- them + (late_cc_binds, late_cc_state) <- + if lateCCConfig_overloadedCalls then + withTiming + logger + (text "LateOverloadedCallsCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateoverloadedCallsCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (top_level_late_cc_state { lateCCState_extra = Strict.Nothing }) + overloadedCallsCC + top_level_cc_binds + else + return + ( top_level_cc_binds + , top_level_late_cc_state { lateCCState_extra = Strict.Nothing } + ) + + return (late_cc_binds, late_cc_state) where - doPair :: ((Id, CoreExpr) -> M (Id, CoreExpr)) - doPair (b,rhs) = (b,) <$> doBndr env b rhs - -doBndr :: Env -> Id -> CoreExpr -> M CoreExpr -doBndr env bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = doBndr' env bndr rhs - - --- We want to put the cost centre below the lambda as we only care about executions of the RHS. -doBndr' :: Env -> Id -> CoreExpr -> State LateCCState CoreExpr -doBndr' env bndr (Lam b rhs) = Lam b <$> doBndr' env bndr rhs -doBndr' env bndr rhs = do - let name = idName bndr - name_loc = nameSrcSpan name - cc_name = getOccFS name - count = countEntries env - cc_flavour <- getCCFlavour cc_name - let cc_mod = thisModule env - bndrCC = NormalCC cc_flavour cc_name cc_mod name_loc - note = ProfNote bndrCC count True - addCC env bndrCC - return $ mkTick note rhs - -data LateCCState = LateCCState - { lcs_state :: !CostCentreState - , lcs_ccs :: S.Set CostCentre - } -type M = State LateCCState - -initLateCCState :: LateCCState -initLateCCState = LateCCState newCostCentreState mempty - -getCCFlavour :: FastString -> M CCFlavour -getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name - -getCCIndex' :: FastString -> M CostCentreIndex -getCCIndex' name = do - state <- get - let (index,cc_state') = getCCIndex name (lcs_state state) - put (state { lcs_state = cc_state'}) - return index - -addCC :: Env -> CostCentre -> M () -addCC !env cc = do - state <- get - when (collectCCs env) $ do - let ccs' = S.insert cc (lcs_ccs state) - put (state { lcs_ccs = ccs'}) - -data Env = Env - { thisModule :: !Module - , countEntries:: !Bool - , collectCCs :: !Bool - } - + top_level_cc_pred :: CoreExpr -> Bool + top_level_cc_pred = + case lateCCConfig_whichBinds of + LateCCAllBinds -> + const True + LateCCOverloadedBinds -> + isOverloadedTy . exprType + LateCCNone -> + -- This is here for completeness, we won't actually use this + -- predicate in this case since we'll shortcut. + const False + + this_mod = lateCCEnv_module lateCCConfig_env ===================================== compiler/GHC/Core/LateCC/OverloadedCalls.hs ===================================== @@ -0,0 +1,204 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} + +module GHC.Core.LateCC.OverloadedCalls + ( overloadedCallsCC + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified GHC.Data.Strict as Strict + +import GHC.Data.FastString +import GHC.Core +import GHC.Core.LateCC.Utils +import GHC.Core.LateCC.Types +import GHC.Core.Make +import GHC.Core.Predicate +import GHC.Core.Type +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.Id +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Types.Tickish +import GHC.Types.Var +import GHC.Utils.Outputable + +type OverloadedCallsCCState = Strict.Maybe SrcSpan + +-- | Insert cost centres on function applications with dictionary arguments. The +-- source locations attached to the cost centres is approximated based on the +-- "closest" source note encountered in the traversal. +overloadedCallsCC :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind +overloadedCallsCC = + processBind + where + processBind :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind + processBind core_bind = + case core_bind of + NonRec b e -> + NonRec b <$> wrap_if_join b (processExpr e) + Rec es -> + Rec <$> mapM (\(b,e) -> (b,) <$> wrap_if_join b (processExpr e)) es + where + -- If an overloaded function is turned into a join point, we won't add + -- SCCs directly to calls since it makes them non-tail calls. Instead, + -- we look for join points here and add an SCC to their RHS if they are + -- overloaded. + wrap_if_join :: + CoreBndr + -> LateCCM OverloadedCallsCCState CoreExpr + -> LateCCM OverloadedCallsCCState CoreExpr + wrap_if_join b pexpr = do + expr <- pexpr + if isJoinId b && isOverloadedTy (exprType expr) then do + let + cc_name :: FastString + cc_name = fsLit "join-rhs-" `appendFS` getOccFS b + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan expr + else + return expr + + + processExpr :: CoreExpr -> LateCCM OverloadedCallsCCState CoreExpr + processExpr expr = + case expr of + -- The case we care about: Application + app at App{} -> do + -- Here we have some application like `f v1 ... vN`, where v1 ... vN + -- should be the function's type arguments followed by the value + -- arguments. To determine if the `f` is an overloaded function, we + -- check if any of the arguments v1 ... vN are dictionaries. + let + (f, xs) = collectArgs app + resultTy = applyTypeToArgs empty (exprType f) xs + + -- Recursively process the arguments first for no particular reason + args <- mapM processExpr xs + let app' = mkCoreApps f args + + if + -- Check if any of the arguments are dictionaries + any isDictExpr args + + -- Avoid instrumenting dictionary functions, which may be + -- overloaded if there are superclasses, by checking if the result + -- type of the function is a dictionary type. + && not (isDictTy resultTy) + + -- Avoid instrumenting constraint selectors like eq_sel + && (typeTypeOrConstraint resultTy /= ConstraintLike) + + -- Avoid instrumenting join points. + -- (See comment in processBind above) + && not (isJoinVarExpr f) + then do + -- Extract a name and source location from the function being + -- applied + let + cc_name :: FastString + cc_name = + fsLit $ maybe "" getOccString (exprName app) + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan app' + else + return app' + + -- For recursive constructors of Expr, we traverse the nested Exprs + Lam b e -> + mkCoreLams [b] <$> processExpr e + Let b e -> + mkCoreLet <$> processBind b <*> processExpr e + Case e b t alts -> + Case + <$> processExpr e + <*> pure b + <*> pure t + <*> mapM processAlt alts + Cast e co -> + mkCast <$> processExpr e <*> pure co + Tick t e -> do + trackSourceNote t $ + mkTick t <$> processExpr e + + -- For non-recursive constructors of Expr, we do nothing + x -> return x + + processAlt :: CoreAlt -> LateCCM OverloadedCallsCCState CoreAlt + processAlt (Alt c bs e) = Alt c bs <$> processExpr e + + trackSourceNote :: CoreTickish -> LateCCM OverloadedCallsCCState a -> LateCCM OverloadedCallsCCState a + trackSourceNote tick act = + case tick of + SourceNote rss _ -> do + -- Prefer source notes from the current file + in_current_file <- + maybe False ((== EQ) . lexicalCompareFS (srcSpanFile rss)) <$> + asks lateCCEnv_file + if not in_current_file then + act + else do + loc <- lift $ gets lateCCState_extra + lift . modify $ \s -> + s { lateCCState_extra = + Strict.Just $ RealSrcSpan rss mempty + } + x <- act + lift . modify $ \s -> + s { lateCCState_extra = loc + } + return x + _ -> + act + + -- Utility functions + + -- Extract a Name from an expression. If it is an application, attempt to + -- extract a name from the applied function. If it is a variable, return the + -- Name of the variable. If it is a tick/cast, attempt to extract a Name + -- from the expression held in the tick/cast. Otherwise return Nothing. + exprName :: CoreExpr -> Maybe Name + exprName = + \case + App f _ -> + exprName f + Var f -> + Just (idName f) + Tick _ e -> + exprName e + Cast e _ -> + exprName e + _ -> + Nothing + + -- Determine whether an expression is a dictionary + isDictExpr :: CoreExpr -> Bool + isDictExpr = + maybe False isDictTy . exprType' + where + exprType' :: CoreExpr -> Maybe Type + exprType' = \case + Type{} -> Nothing + expr -> Just $ exprType expr + + -- Determine whether an expression is a join variable + isJoinVarExpr :: CoreExpr -> Bool + isJoinVarExpr = + \case + Var var -> isJoinId var + Tick _ e -> isJoinVarExpr e + Cast e _ -> isJoinVarExpr e + _ -> False ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE TupleSections #-} +module GHC.Core.LateCC.TopLevelBinds where + +import GHC.Prelude + +import GHC.Core +-- import GHC.Core.LateCC +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Opt.Monad +import GHC.Driver.DynFlags +import GHC.Types.Id +import GHC.Types.Name +import GHC.Unit.Module.ModGuts + +{- Note [Collecting late cost centres] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Usually cost centres defined by a module are collected +during tidy by collectCostCentres. However with `-fprof-late` +we insert cost centres after inlining. So we keep a list of +all the cost centres we inserted and combine that with the list +of cost centres found during tidy. + +To avoid overhead when using -fprof-inline there is a flag to stop +us from collecting them here when we run this pass before tidy. + +Note [Adding late cost centres to top level bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The basic idea is very simple. For every top level binder +`f = rhs` we compile it as if the user had written +`f = {-# SCC f #-} rhs`. + +If we do this after unfoldings for `f` have been created this +doesn't impact core-level optimizations at all. If we do it +before the cost centre will be included in the unfolding and +might inhibit optimizations at the call site. For this reason +we provide flags for both approaches as they have different +tradeoffs. + +We also don't add a cost centre for any binder that is a constructor +worker or wrapper. These will never meaningfully enrich the resulting +profile so we improve efficiency by omitting those. + +-} + +-- | Add late cost centres directly to the 'ModGuts'. This is used inside the +-- core pipeline with the -fprof-late-inline flag. It should not be used after +-- tidy, since it does not manually track inserted cost centers. See +-- Note [Collecting late cost centres]. +topLevelBindsCCMG :: ModGuts -> CoreM ModGuts +topLevelBindsCCMG guts = do + dflags <- getDynFlags + let + env = + LateCCEnv + { lateCCEnv_module = mg_module guts + + -- We don't use this for topLevelBindsCC, so Nothing is okay + , lateCCEnv_file = Nothing + + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = False + } + guts' = + guts + { mg_binds = + fst + ( doLateCostCenters + env + (initLateCCState ()) + (topLevelBindsCC (const True)) + (mg_binds guts) + ) + } + return guts' + +-- | Insert cost centres on top-level bindings in the module, depending on +-- whether or not they satisfy the given predicate. +topLevelBindsCC :: (CoreExpr -> Bool) -> CoreBind -> LateCCM s CoreBind +topLevelBindsCC pred core_bind = + case core_bind of + NonRec b rhs -> + NonRec b <$> doBndr b rhs + Rec bs -> + Rec <$> mapM doPair bs + where + doPair :: ((Id, CoreExpr) -> LateCCM s (Id, CoreExpr)) + doPair (b,rhs) = (b,) <$> doBndr b rhs + + doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr + doBndr bndr rhs + -- Cost centres on constructor workers are pretty much useless + -- so we don't emit them if we are looking at the rhs of a constructor + -- binding. + | Just _ <- isDataConId_maybe bndr = pure rhs + | otherwise = if pred rhs then addCC bndr rhs else pure rhs + + -- We want to put the cost centre below the lambda as we only care about + -- executions of the RHS. + addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs + addCC bndr rhs = do + let name = idName bndr + cc_loc = nameSrcSpan name + cc_name = getOccFS name + insertCC cc_name cc_loc rhs \ No newline at end of file ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -0,0 +1,74 @@ +-- | Types related to late cost center insertion +module GHC.Core.LateCC.Types + ( LateCCConfig(..) + , LateCCBindSpec(..) + , LateCCEnv(..) + , LateCCState(..) + , initLateCCState + , LateCCM + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Unit.Types + +-- | Late cost center insertion configuration. +-- +-- Specifies whether cost centers are added to overloaded function call sites +-- and/or top-level bindings, and which top-level bindings they are added to. +-- Also holds the cost center insertion environment. +data LateCCConfig = + LateCCConfig + { lateCCConfig_whichBinds :: !LateCCBindSpec + , lateCCConfig_overloadedCalls :: !Bool + , lateCCConfig_env :: !LateCCEnv + } + +-- | The types of top-level bindings we support adding cost centers to. +data LateCCBindSpec = + LateCCNone + | LateCCAllBinds + | LateCCOverloadedBinds + +-- | Late cost centre insertion environment +data LateCCEnv = LateCCEnv + { lateCCEnv_module :: !Module + -- ^ Current module + , lateCCEnv_file :: Maybe FastString + -- ^ Current file, if we have one + , lateCCEnv_countEntries:: !Bool + -- ^ Whether the inserted cost centers should count entries + , lateCCEnv_collectCCs :: !Bool + -- ^ Whether to collect the cost centres we insert. See + -- Note [Collecting late cost centres] + + } + +-- | Late cost centre insertion state, indexed by some extra state type that an +-- insertion method may require. +data LateCCState s = LateCCState + { lateCCState_ccs :: !(S.Set CostCentre) + -- ^ Cost centres that have been inserted + , lateCCState_ccState :: !CostCentreState + -- ^ Per-module state tracking for cost centre indices + , lateCCState_extra :: !s + } + +-- | The empty late cost centre insertion state +initLateCCState :: s -> LateCCState s +initLateCCState s = + LateCCState + { lateCCState_ccState = newCostCentreState + , lateCCState_ccs = mempty + , lateCCState_extra = s + } + +-- | Late cost centre insertion monad +type LateCCM s = ReaderT LateCCEnv (State (LateCCState s)) ===================================== compiler/GHC/Core/LateCC/Utils.hs ===================================== @@ -0,0 +1,80 @@ +module GHC.Core.LateCC.Utils + ( -- * Inserting cost centres + doLateCostCenters -- Might be useful for API users + + -- ** Helpers for defining insertion methods + , getCCFlavour + , insertCC + ) where + +import GHC.Prelude + +import Control.Monad +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Core +import GHC.Core.LateCC.Types +import GHC.Core.Utils +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Types.SrcLoc +import GHC.Types.Tickish + +-- | Insert cost centres into the 'CoreProgram' using the provided environment, +-- initial state, and insertion method. +doLateCostCenters + :: LateCCEnv + -- ^ Environment to run the insertion in + -> LateCCState s + -- ^ Initial state to run the insertion with + -> (CoreBind -> LateCCM s CoreBind) + -- ^ Insertion method + -> CoreProgram + -- ^ Bindings to consider + -> (CoreProgram, LateCCState s) +doLateCostCenters env state method binds = + runLateCC env state $ mapM method binds + +-- | Evaluate late cost centre insertion +runLateCC :: LateCCEnv -> LateCCState s -> LateCCM s a -> (a, LateCCState s) +runLateCC env state = (`runState` state) . (`runReaderT` env) + +-- | Given the name of a cost centre, get its flavour +getCCFlavour :: FastString -> LateCCM s CCFlavour +getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name + where + getCCIndex' :: FastString -> LateCCM s CostCentreIndex + getCCIndex' name = do + cc_state <- lift $ gets lateCCState_ccState + let (index, cc_state') = getCCIndex name cc_state + lift . modify $ \s -> s { lateCCState_ccState = cc_state'} + return index + +-- | Insert a cost centre with the specified name and source span on the given +-- expression. The inserted cost centre will be appropriately tracked in the +-- late cost centre state. +insertCC + :: FastString + -- ^ Name of the cost centre to insert + -> SrcSpan + -- ^ Source location to associate with the cost centre + -> CoreExpr + -- ^ Expression to wrap in the cost centre + -> LateCCM s CoreExpr +insertCC cc_name cc_loc expr = do + cc_flavour <- getCCFlavour cc_name + env <- ask + let + cc_mod = lateCCEnv_module env + cc = NormalCC cc_flavour cc_name cc_mod cc_loc + note = ProfNote cc (lateCCEnv_countEntries env) True + when (lateCCEnv_collectCCs env) $ do + lift . modify $ \s -> + s { lateCCState_ccs = S.insert cc (lateCCState_ccs s) + } + return $ mkTick note expr + ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) import GHC.Core.Opt.CallerCC ( addCallerCostCentres ) -import GHC.Core.LateCC (addLateCostCentresMG) +import GHC.Core.LateCC.TopLevelBinds (topLevelBindsCCMG) import GHC.Core.Seq (seqBinds) import GHC.Core.FamInstEnv @@ -520,7 +520,7 @@ doCorePass pass guts = do addCallerCostCentres guts CoreAddLateCcs -> {-# SCC "AddLateCcs" #-} - addLateCostCentresMG guts + topLevelBindsCCMG guts CoreDoPrintCore -> {-# SCC "PrintCore" #-} liftIO $ printCore logger (mg_binds guts) >> return guts ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -341,6 +341,8 @@ data GeneralFlag | Opt_ProfCountEntries | Opt_ProfLateInlineCcs | Opt_ProfLateCcs + | Opt_ProfLateOverloadedCcs + | Opt_ProfLateoverloadedCallsCCs | Opt_ProfManualCcs -- ^ Ignore manual SCC annotations -- misc opts ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -172,7 +172,6 @@ import GHC.Iface.Ext.Debug ( diffFile, validateScopes ) import GHC.Core import GHC.Core.Lint.Interactive ( interactiveInScope ) import GHC.Core.Tidy ( tidyExpr ) -import GHC.Core.Type ( Type, Kind ) import GHC.Core.Utils ( exprType ) import GHC.Core.ConLike import GHC.Core.Opt.Pipeline @@ -182,7 +181,8 @@ import GHC.Core.InstEnv import GHC.Core.FamInstEnv import GHC.Core.Rules import GHC.Core.Stats -import GHC.Core.LateCC (addLateCostCentresPgm) +import GHC.Core.LateCC +import GHC.Core.LateCC.Types import GHC.CoreToStg.Prep @@ -194,6 +194,7 @@ import GHC.Parser.Lexer as Lexer import GHC.Tc.Module import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.TcType import GHC.Tc.Zonk.Env ( ZonkFlexi (DefaultFlexi) ) import GHC.Stg.Syntax @@ -294,7 +295,6 @@ import GHC.StgToCmm.Utils (IPEStats) import GHC.Types.Unique.FM import GHC.Types.Unique.DFM import GHC.Cmm.Config (CmmConfig) -import GHC.Types.CostCentre.State (newCostCentreState) {- ********************************************************************** @@ -1788,22 +1788,41 @@ hscGenHardCode hsc_env cgguts location output_filename = do ------------------- - -- Insert late cost centres if enabled. + -- Insert late cost centres on top level bindings if enabled. -- If `-fprof-late-inline` is enabled we can skip this, as it will have added -- a superset of cost centres we would add here already. - (late_cc_binds, late_local_ccs, cc_state) <- - if gopt Opt_ProfLateCcs dflags && not (gopt Opt_ProfLateInlineCcs dflags) - then - withTiming - logger - (text "LateCCs"<+>brackets (ppr this_mod)) - (const ()) - $ {-# SCC lateCC #-} do - (binds, late_ccs, cc_state) <- addLateCostCentresPgm dflags logger this_mod core_binds - return ( binds, (S.toList late_ccs `mappend` local_ccs ), cc_state) + -- If `-fprof-late-overloaded` is enabled, only add CCs to bindings for + -- overloaded functions. + let + late_cc_config :: LateCCConfig + late_cc_config = + LateCCConfig + { lateCCConfig_whichBinds = + if gopt Opt_ProfLateInlineCcs dflags then + LateCCNone + else if gopt Opt_ProfLateCcs dflags then + LateCCAllBinds + else if gopt Opt_ProfLateOverloadedCcs dflags then + LateCCOverloadedBinds else - return (core_binds, local_ccs, newCostCentreState) + LateCCNone + , lateCCConfig_overloadedCalls = + gopt Opt_ProfLateoverloadedCallsCCs dflags + , lateCCConfig_env = + LateCCEnv + { lateCCEnv_module = this_mod + , lateCCEnv_file = fsLit <$> ml_hs_file location + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = True + } + } + + (late_cc_binds, late_cc_state) <- + addLateCostCenters logger late_cc_config core_binds + + when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ + putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr late_cc_binds)) ------------------- -- Run late plugins @@ -1817,7 +1836,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do cg_hpc_info = hpc_info, cg_spt_entries = spt_entries, cg_binds = late_binds, - cg_ccs = late_local_ccs' + cg_ccs = late_local_ccs } , _ ) <- @@ -1830,9 +1849,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do (($ hsc_env) . latePlugin) ( cgguts { cg_binds = late_cc_binds - , cg_ccs = late_local_ccs + , cg_ccs = S.toList (lateCCState_ccs late_cc_state) ++ local_ccs } - , cc_state + , lateCCState_ccState late_cc_state ) let @@ -1873,7 +1892,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do let (stg_binds,_stg_deps) = unzip stg_binds_with_deps let cost_centre_info = - (late_local_ccs' ++ caf_ccs, caf_cc_stacks) + (late_local_ccs ++ caf_ccs, caf_cc_stacks) platform = targetPlatform dflags prof_init | sccProfilingEnabled dflags = profilingInitCode platform this_mod cost_centre_info ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2444,6 +2444,8 @@ fFlagsDeps = [ flagSpec "prof-cafs" Opt_AutoSccsOnIndividualCafs, flagSpec "prof-count-entries" Opt_ProfCountEntries, flagSpec "prof-late" Opt_ProfLateCcs, + flagSpec "prof-late-overloaded" Opt_ProfLateOverloadedCcs, + flagSpec "prof-late-overloaded-calls" Opt_ProfLateoverloadedCallsCCs, flagSpec "prof-manual" Opt_ProfManualCcs, flagSpec "prof-late-inline" Opt_ProfLateInlineCcs, flagSpec "regs-graph" Opt_RegsGraph, @@ -3762,6 +3764,10 @@ needSourceNotes :: DynFlags -> Bool needSourceNotes dflags = debugLevel dflags > 0 || gopt Opt_InfoTableMap dflags + -- Source ticks are used to approximate the location of + -- overloaded call cost centers + || gopt Opt_ProfLateoverloadedCallsCCs dflags + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1907,7 +1907,7 @@ isRhoExpTy (Infer {}) = True isOverloadedTy :: Type -> Bool -- Yes for a type of a function that might require evidence-passing --- Used only by bindLocalMethods +-- Used by bindLocalMethods and for -fprof-late-overloaded isOverloadedTy ty | Just ty' <- coreView ty = isOverloadedTy ty' isOverloadedTy (ForAllTy _ ty) = isOverloadedTy ty isOverloadedTy (FunTy { ft_af = af }) = isInvisibleFunArg af ===================================== compiler/ghc.cabal.in ===================================== @@ -336,6 +336,10 @@ Library GHC.Core.Lint GHC.Core.Lint.Interactive GHC.Core.LateCC + GHC.Core.LateCC.Types + GHC.Core.LateCC.TopLevelBinds + GHC.Core.LateCC.Utils + GHC.Core.LateCC.OverloadedCalls GHC.Core.Make GHC.Core.Map.Expr GHC.Core.Map.Type ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -174,6 +174,15 @@ Compiler This means that if you are using ``-fllvm`` you now need ``llc``, ``opt`` and ``clang`` available. +- The :ghc-flag:`-fprof-late-overloaded` flag has been introduced. It causes + cost centres to be added to *overloaded* top level bindings, unlike + :ghc-flag:`-fprof-late` which adds cost centres to all top level bindings. + +- The :ghc-flag:`-fprof-late-overloaded-calls` flag has been introduced. It + causes cost centres to be inserted at call sites including instance dictionary + arguments. This may be preferred over :ghc-flag:`-fprof-late-overloaded` since + it may reveal whether imported functions are called overloaded. + JavaScript backend ~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -518,6 +518,49 @@ of your profiled program will be different to that of the unprofiled one. You can try this mode if :ghc-flag:`-fprof-late` results in a profile that's too hard to interpret. +.. ghc-flag:: -fprof-late-overloaded + :shortdesc: Auto-add ``SCC``\\ s to all top level overloaded bindings *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all *overloaded* top level bindings + late in the compilation pipeline after the optimizer has run and unfoldings + have been created. This means these cost centres will not interfere with + core-level optimizations and the resulting profile will be closer to the + performance profile of an optimized non-profiled executable. + + This flag can help determine which top level bindings encountered during a + program's execution are still overloaded after inlining and specialization. + +.. ghc-flag:: -fprof-late-overloaded-calls + :shortdesc: Auto-add ``SCC``\\ s to all call sites that include dictionary arguments *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded-calls + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all call sites that include + dictionary arguments late in the compilation pipeline after the optimizer + has run and unfoldings have been created. This means these cost centres will + not interfere with core-level optimizations and the resulting profile will + be closer to the performance profile of an optimized non-profiled + executable. + + This flag is potentially more useful than :ghc-flag:`-fprof-late-overloaded` + since it will also add ``SCC`` annotations to call sites of imported + overloaded functions. + + Some overloaded calls may not be annotated, specifically in cases where the + optimizer turns an overloaded function into a join point. Calls to such + functions will not be wrapped in ``SCC`` annotations, since it would make + them non-tail calls, which is a requirement for join points. Instead, + ``SCC`` annotations are added around the body of overloaded join variables + and given distinct names (``join-rhs-``) to avoid confusion. + .. ghc-flag:: -fprof-cafs :shortdesc: Auto-add ``SCC``\\ s to all CAFs :type: dynamic ===================================== testsuite/tests/profiling/should_run/all.T ===================================== @@ -195,3 +195,30 @@ test('ignore_scc', [], compile_and_run, ['-fno-prof-manual']) test('T21446', [], makefile_test, ['T21446']) + + +test('scc-prof-overloaded001', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded002', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls001', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fno-full-laziness -fprof-late-overloaded-calls'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls002', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fprof-late-overloaded-calls'] +) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample ===================================== @@ -0,0 +1,26 @@ + Thu Jan 4 11:49 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,320 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded-calls001.hs:24:1-31 256 1 0.0 0.3 0.0 0.8 + f Main scc-prof-overloaded-calls001.hs:18:1-18 257 1 0.0 0.6 0.0 0.6 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample ===================================== @@ -0,0 +1,31 @@ + Fri Jan 5 11:06 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls002 +RTS -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 59,152 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 34.8 +CAF GHC.IO.Handle.FD 0.0 58.7 +CAF GHC.IO.Encoding 0.0 4.1 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 34.8 0.0 100.0 + CAF Main 255 0 0.0 0.6 0.0 0.9 + f Main scc-prof-overloaded-calls002.hs:52:1-25 262 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:48:1-25 261 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:44:1-25 260 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:40:1-25 259 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:36:1-25 258 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:32:1-25 257 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:28:1-25 256 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.1 0.0 4.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.3 0.0 0.3 + CAF GHC.IO.Handle.FD 208 0 0.0 58.7 0.0 58.7 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample ===================================== @@ -0,0 +1,25 @@ + Thu Jan 4 11:26 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,304 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded001.hs:18:1-6 256 1 0.0 0.8 0.0 0.8 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample ===================================== @@ -0,0 +1,23 @@ + Thu Jan 4 11:55 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded002 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 56,472 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 32.7 +CAF GHC.IO.Handle.FD 0.0 61.5 +CAF GHC.IO.Encoding 0.0 4.3 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 32.7 0.0 100.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.3 0.0 4.3 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 61.5 0.0 61.5 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7da9a1c3b403f1b9aa4e581ffbd4339b088f758d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7da9a1c3b403f1b9aa4e581ffbd4339b088f758d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 09:13:46 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 04 Mar 2024 04:13:46 -0500 Subject: [Git][ghc/ghc][wip/T24471] 3 commits: compiler: start deprecating cmmToRawCmmHook Message-ID: <65e590ca10ebd_381c1f771c42c696fe@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - fd5073c6 by Simon Peyton Jones at 2024-03-04T09:13:33+00:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 3.5%, and much more in artificial cases. Metric Decrease: CoOpt_Read - - - - - 9 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/HsToCore/Match/Constructor.hs - libraries/base/changelog.md - libraries/base/src/Data/List/NonEmpty.hs Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== compiler/GHC/Data/Bag.hs ===================================== @@ -7,7 +7,7 @@ Bag: an unordered collection with duplicates -} {-# LANGUAGE ScopedTypeVariables, DeriveTraversable, TypeFamilies #-} -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-data-list-nonempty-unzip #-} module GHC.Data.Bag ( Bag, -- abstract type ===================================== compiler/GHC/Driver/Hooks.hs ===================================== @@ -154,6 +154,8 @@ data Hooks = Hooks -> IO (Stream IO RawCmmGroup a))) } +{-# DEPRECATED cmmToRawCmmHook "cmmToRawCmmHook is being deprecated. If you do use it in your project, please raise a GHC issue!" #-} + class HasHooks m where getHooks :: m Hooks ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -6,6 +6,9 @@ {-# OPTIONS_GHC -fprof-auto-top #-} +-- Remove this after cmmToRawCmmHook removal +{-# OPTIONS_GHC -Wno-deprecations #-} + ------------------------------------------------------------------------------- -- -- | Main API for compiling plain Haskell source code. ===================================== compiler/GHC/HsToCore/Match/Constructor.hs ===================================== @@ -2,7 +2,7 @@ {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-data-list-nonempty-unzip #-} {- (c) The University of Glasgow 2006 ===================================== libraries/base/changelog.md ===================================== @@ -17,7 +17,10 @@ * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). - * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) + * Add `{-# WARNING in "x-data-list-nonempty-unzip" #-}` to `Data.List.NonEmpty.unzip`. + Use `{-# OPTIONS_GHC -Wno-x-data-list-nonempty-unzip #-}` to disable it. + ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86) + and [CLC proposal #258](https://github.com/haskell/core-libraries-committee/issues/258)) * Add `System.Mem.performMajorGC` ([CLC proposal #230](https://github.com/haskell/core-libraries-committee/issues/230)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -534,7 +534,7 @@ zipWith f ~(x :| xs) ~(y :| ys) = f x y :| List.zipWith f xs ys -- | The 'unzip' function is the inverse of the 'zip' function. unzip :: Functor f => f (a,b) -> (f a, f b) unzip xs = (fst <$> xs, snd <$> xs) -{-# DEPRECATED unzip "This function will be made monomorphic in base-4.22, consider switching to GHC.Internal.Data.Functor.unzip" #-} +{-# WARNING in "x-data-list-nonempty-unzip" unzip "This function will be made monomorphic in base-4.22, consider switching to Data.Functor.unzip" #-} -- | The 'nub' function removes duplicate elements from a list. In -- particular, it keeps only the first occurrence of each element. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e85fa5a8daedafa2304290ef803bdfa5edf53d9c...fd5073c699a3b4d2583437094683ac13f9f088da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e85fa5a8daedafa2304290ef803bdfa5edf53d9c...fd5073c699a3b4d2583437094683ac13f9f088da You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 10:39:01 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Mon, 04 Mar 2024 05:39:01 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Linker: Use SymbolExtras for GOT relative relocations to local symbols Message-ID: <65e5a4c5c76ba_381c1f9d945788873c@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: c482cd0f by Sven Tennie at 2024-03-04T11:37:16+01:00 Linker: Use SymbolExtras for GOT relative relocations to local symbols This is (hopefully!) faster than emitting real GOT entries for all local labels (which was implemented before.) - - - - - 5 changed files: - rts/LinkerInternals.h - rts/linker/SymbolExtras.c - rts/linker/SymbolExtras.h - rts/linker/elf_got.c - rts/linker/elf_reloc_riscv64.c Changes: ===================================== rts/LinkerInternals.h ===================================== @@ -208,7 +208,7 @@ typedef struct _Segment { int n_sections; } Segment; -#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) || defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH) +#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) || defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH) || defined(riscv64_HOST_ARCH) #define NEED_SYMBOL_EXTRAS 1 #endif @@ -237,6 +237,8 @@ typedef struct { uint8_t jumpIsland[8]; #elif defined(arm_HOST_ARCH) uint8_t jumpIsland[16]; +#elif defined(riscv64_HOST_ARCH) + uint64_t addr; #endif } SymbolExtra; ===================================== rts/linker/SymbolExtras.c ===================================== @@ -153,7 +153,7 @@ void ocProtectExtras(ObjectCode* oc) } -#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) +#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) || defined(riscv64_HOST_ARCH) SymbolExtra* makeSymbolExtra( ObjectCode const* oc, unsigned long symbolNumber, unsigned long target ) @@ -189,9 +189,12 @@ SymbolExtra* makeSymbolExtra( ObjectCode const* oc, extra->addr = target; memcpy(extra->jumpIsland, jmp, 8); #endif /* x86_64_HOST_ARCH */ - +#if defined(riscv64_HOST_ARCH) + // Fake GOT entry (used like GOT, but located in symbol extras) + extra->addr = target; +#endif return extra; } -#endif /* powerpc_HOST_ARCH || x86_64_HOST_ARCH */ +#endif /* powerpc_HOST_ARCH || x86_64_HOST_ARCH || riscv64_HOST_ARCH */ #endif /* !x86_64_HOST_ARCH) || !mingw32_HOST_OS */ #endif // NEED_SYMBOL_EXTRAS ===================================== rts/linker/SymbolExtras.h ===================================== @@ -16,7 +16,7 @@ SymbolExtra* makeArmSymbolExtra( ObjectCode const* oc, unsigned long target, bool fromThumb, bool toThumb ); -#elif defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) +#elif defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) || defined(riscv64_HOST_ARCH) SymbolExtra* makeSymbolExtra( ObjectCode const* oc, unsigned long symbolNumber, unsigned long target ); ===================================== rts/linker/elf_got.c ===================================== @@ -22,22 +22,7 @@ bool needGotSlot(Elf_Sym *symbol) { ELF_ST_BIND(symbol->st_info) == STB_WEAK // Section symbols exist primarily for relocation // and as such may need a GOT slot. - || ELF_ST_TYPE(symbol->st_info) == STT_SECTION -#if defined(riscv64_HOST_ARCH) - // RISCV relies much on relocations and relaxations, leaving most of - // the addressing mode heavy lifting to the linker. We're using LA to - // load local label addresses (e.g. to access `*_closure`.) This - // implies (in the medany memory model) relocation via the GOT unless - // the instruction gets relaxed to e.g. direct or PC-relative - // addressing. So, for now, we've got the special case to add GOT - // symbols for all local labels here. This could be optimized by e.g. - // adding symbols to GOT on demand: I.e. if we spot a symbol related - // relocation which cannot be relaxed to direct or PC-relative - // addressing, then add it to GOT (otherwise not.) - || (ELF_ST_BIND(symbol->st_info) == STB_LOCAL && - ELF_ST_TYPE(symbol->st_info) == STT_NOTYPE && symbol->st_name != 0) -#endif - ; + || ELF_ST_TYPE(symbol->st_info) == STT_SECTION; } bool ===================================== rts/linker/elf_reloc_riscv64.c ===================================== @@ -1,6 +1,8 @@ #include "elf_reloc_riscv64.h" +#include "LinkerInternals.h" #include "Rts.h" #include "Stg.h" +#include "SymbolExtras.h" #include "elf.h" #include "elf_plt.h" #include "elf_util.h" @@ -442,8 +444,8 @@ int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, symbol_prime->addr, symbol_prime->name)); int32_t result = computeAddend(targetSection, (Elf_Rel *)rel_prime, symbol_prime, addend_prime, oc); - IF_DEBUG(linker, - debugBelch("Result of computeAddend: 0x%x (%d)\n", result, result)); + IF_DEBUG(linker, debugBelch("Result of computeAddend: 0x%x (%d)\n", + result, result)); return result; } } @@ -509,9 +511,28 @@ int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, case R_RISCV_32_PCREL: return S + A - P; case R_RISCV_GOT_HI20: { - // Ensure that the GOT entry is set up. - CHECK(0x0 != GOT_S); - return GOT_S + A - P; + // TODO: Allocating extra memory for every symbol just to play this trick + // seems to be a bit obscene. (GOT relocations hitting local symbols + // happens, but not very often.) It would be better to allocate only what we + // really need. + + // There are two cases here: 1. The symbol is public and has an entry in the + // GOT. 2. It's local and has no corresponding GOT entry. The first case is + // easy: We simply calculate the addend with the GOT address. In the second + // case we create a symbol extra entry and pretend it's the GOT. + if (GOT_S != 0) { + // 1. Public symbol with GOT entry. + return GOT_S + A - P; + } else { + // 2. Fake GOT entry with symbol extra entry. + SymbolExtra *symbolExtra = makeSymbolExtra(oc, ELF_R_SYM(rel->r_info), S); + addr_t* FAKE_GOT_S = &symbolExtra->addr; + addr_t res = (addr_t) FAKE_GOT_S + A - P; + IF_DEBUG(linker, debugBelch("R_RISCV_GOT_HI20 w/ SymbolExtra = %p , " + "entry = 0x%lx , reloc-addend = 0x%lu ", + symbolExtra, FAKE_GOT_S, res)); + return res; + } } default: debugBelch("Unimplemented relocation: 0x%lx\n (%lu)", View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c482cd0f92ab04287357673d5e4253fc6795ec08 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c482cd0f92ab04287357673d5e4253fc6795ec08 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 10:56:47 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 04 Mar 2024 05:56:47 -0500 Subject: [Git][ghc/ghc][wip/T24466] Wibbles to pipeline Message-ID: <65e5a8efc4289_381c1fa64c8a0906c5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24466 at Glasgow Haskell Compiler / GHC Commits: 2663025f by Simon Peyton Jones at 2024-03-04T10:56:12+00:00 Wibbles to pipeline Accidentlly added an unnecessary pass - - - - - 1 changed file: - compiler/GHC/Core/Opt/Pipeline.hs Changes: ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -324,12 +324,11 @@ getCoreToDo dflags hpt_rule_base extra_vars -- 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 cse $ CoreCSE, - - -- New opportunities for float-in - runWhen do_float_in CoreDoFloatInwards, - - simplify "post-O2", + -- Also SpecConstr yields new FloatIn possibilities + runWhen (liberate_case || spec_constr) $ CoreDoPasses + [ runWhen cse CoreCSE + , runWhen do_float_in CoreDoFloatInwards + , runWhen (cse || do_float_in) $ simplify "post-O2" ], --------- End of -O2 passes -------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2663025f91cfbeb563a5865ea7f4f1e3ea965568 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2663025f91cfbeb563a5865ea7f4f1e3ea965568 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 13:07:05 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 08:07:05 -0500 Subject: [Git][ghc/ghc][wip/global-package-db] 8 commits: Introduce ListTuplePuns extension Message-ID: <65e5c7792522_a5db038dbce465969@gitlab.mail> Matthew Pickering pushed to branch wip/global-package-db at Glasgow Haskell Compiler / GHC Commits: d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 9fffd397 by Matthew Pickering at 2024-03-04T12:43:58+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage2 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage2 package database. * Stage 2 cross compilers need to use stage3 libraries, so likewise, we should set to stage * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. - - - - - 6a9a06de by Matthew Pickering at 2024-03-04T13:06:47+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Types/Origin.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/187b4a5310600331c4c54177143b4c46df9d641f...6a9a06debfc3acf933734c0b0e681e92e928e899 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/187b4a5310600331c4c54177143b4c46df9d641f...6a9a06debfc3acf933734c0b0e681e92e928e899 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 13:29:50 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 08:29:50 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 12 commits: Read global package database from settings file Message-ID: <65e5ccceaab67_a5db03fa07006872d@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 7a249c93 by Matthew Pickering at 2024-03-04T13:08:51+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage2 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage2 package database. * Stage 2 cross compilers need to use stage3 libraries, so likewise, we should set to stage * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. - - - - - 546d3e40 by Matthew Pickering at 2024-03-04T13:08:51+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 2bbfd538 by Matthew Pickering at 2024-03-04T13:08:51+00:00 Add missing req_interp modifier to T18441fail3 and T18441fail19 These tests require the interpreter but they were failing in a different way with the javascript backend because the interpreter was disabled and stderr is ignored by the test. - - - - - 06f05d06 by Matthew Pickering at 2024-03-04T13:08:51+00:00 Use explicit syntax rather than pure - - - - - dce68982 by Matthew Pickering at 2024-03-04T13:08:51+00:00 ci: Fail when bindist configure fails when installing bindist It is better to fail earlier if the configure step fails rather than carrying on for a more obscure error message. - - - - - c2f17b41 by Matthew Pickering at 2024-03-04T13:08:52+00:00 packaging: correctly propagate build/host/target to bindist configure script At the moment the host and target which we will produce a compiler for is fixed at the initial configure time. Therefore we need to persist the choice made at this time into the installation bindist as well so we look for the right tools, with the right prefixes at install time. In the future, we want to provide a bit more control about what kind of bindist we produce so the logic about what the host/target will have to be written by hadrian rather than persisted by the configure script. In particular with cross compilers we want to either build a normal stage 2 cross bindist or a stage 3 bindist, which creates a bindist which has a native compiler for the target platform. Fixes #21970 - - - - - f08041d3 by Matthew Pickering at 2024-03-04T13:08:52+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - 06f6d626 by Matthew Pickering at 2024-03-04T13:08:52+00:00 hadrian: Disable docs when cross compiling Before there were a variety of ad-hoc places where doc building was disabled when cross compiling. * Some CI jobs sets --docs=none in gen_ci.hs * Some CI jobs set --docs=none in .gitlab/ci.sh * There was some logic in hadrian to not need the ["docs"] target when making a bindist. Now the situation is simple: * If you are cross compiling then defaultDocsTargets is empty by default. In theory, there is no reason why we can't build documentation for cross compiler bindists, but this is left to future work to generalise the documentation building rules to allow this (#24289) - - - - - 6867f0b0 by Matthew Pickering at 2024-03-04T13:24:21+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 31665224 by Matthew Pickering at 2024-03-04T13:24:21+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - 717c2760 by Matthew Pickering at 2024-03-04T13:24:21+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - db2e4a50 by Matthew Pickering at 2024-03-04T13:24:21+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/hadrian.cabal - + hadrian/src/BindistConfig.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Expression.hs - hadrian/src/Hadrian/Haskell/Hash.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Flavour.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Documentation.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e514613a07b2e0e5ccea943a140db7a31595008b...db2e4a5093908219578157fde598ac6a6beff746 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e514613a07b2e0e5ccea943a140db7a31595008b...db2e4a5093908219578157fde598ac6a6beff746 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 13:40:14 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 08:40:14 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/cross-stage2-rebased Message-ID: <65e5cf3edb8ed_a5db0481dd9c71871@gitlab.mail> Matthew Pickering pushed new branch wip/cross-stage2-rebased at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/cross-stage2-rebased You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 13:44:46 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 08:44:46 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-ghci-multi Message-ID: <65e5d04ec2608_a5db049be28c72040@gitlab.mail> Matthew Pickering pushed new branch wip/hadrian-ghci-multi at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-ghci-multi You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 13:45:01 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 08:45:01 -0500 Subject: [Git][ghc/ghc][wip/hadrian-ghci-multi] ci: Try using multi repl in ghc-in-ghci test Message-ID: <65e5d05d877fb_a5db049f69fc72283@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-ghci-multi at Glasgow Haskell Compiler / GHC Commits: e196f1f0 by Matthew Pickering at 2024-03-04T13:44:54+00:00 ci: Try using multi repl in ghc-in-ghci test This should be quite a bit faster than the ./hadrian/ghci command as it doesn't properly build all the dependencies. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -401,7 +401,7 @@ hadrian-ghc-in-ghci: - "echo ' ghc-options: -Werror' >> hadrian/cabal.project.local" # Load ghc-in-ghci then immediately exit and check the modules loaded - export CORES="$(mk/detect-cpu-count.sh)" - - echo ":q" | HADRIAN_ARGS=-j$CORES hadrian/ghci -j$CORES | tail -n2 | grep "Ok," + - echo ":q" | HADRIAN_ARGS=-j$CORES hadrian/ghci-multi -j$CORES -Wno-error=deprecations | tail -n2 | grep "Ok," after_script: - .gitlab/ci.sh save_cache - cat ci-timings View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e196f1f02163d055db784048a5727dbf01c68f0f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e196f1f02163d055db784048a5727dbf01c68f0f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 14:03:52 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 09:03:52 -0500 Subject: [Git][ghc/ghc][wip/cross-stage2-rebased] Fix genapply Message-ID: <65e5d4c8747e8_a5db051e10407506a@gitlab.mail> Matthew Pickering pushed to branch wip/cross-stage2-rebased at Glasgow Haskell Compiler / GHC Commits: e32aa927 by Matthew Pickering at 2024-03-04T14:03:45+00:00 Fix genapply - - - - - 1 changed file: - hadrian/src/Builder.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -205,7 +205,7 @@ instance NFData Builder builderProvenance :: Builder -> Maybe Context builderProvenance = \case DeriveConstants -> context stage0Boot deriveConstants - GenApply -> context stage0Boot genapply + GenApply -> context stage0InTree genapply GenPrimopCode -> context stage0Boot genprimopcode Ghc _ (Stage0 {})-> Nothing Ghc _ stage -> context (predStage stage) ghc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e32aa9272229dfa7fa2b4bcb0cc5b361fc75060e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e32aa9272229dfa7fa2b4bcb0cc5b361fc75060e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 14:06:39 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 09:06:39 -0500 Subject: [Git][ghc/ghc][wip/cross-stage2-rebased] Remove unused Message-ID: <65e5d56f46ba2_a5db05441060752e1@gitlab.mail> Matthew Pickering pushed to branch wip/cross-stage2-rebased at Glasgow Haskell Compiler / GHC Commits: 3d13d08c by Matthew Pickering at 2024-03-04T14:06:33+00:00 Remove unused - - - - - 1 changed file: - hadrian/src/Oracles/TestSettings.hs Changes: ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -15,7 +15,6 @@ import Packages import Settings.Program (programContext) import Hadrian.Oracles.Path import System.Directory (makeAbsolute) -import Oracles.Flag testConfigFile :: Action FilePath testConfigFile = buildRoot <&> (-/- "test/ghcconfig") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d13d08c00296275d396d9ddf2caedade28e6f16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d13d08c00296275d396d9ddf2caedade28e6f16 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 14:30:44 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Mon, 04 Mar 2024 09:30:44 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T23160-teo Message-ID: <65e5db142e680_a5db05f0210c7606a@gitlab.mail> Teo Camarasu pushed new branch wip/T23160-teo at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T23160-teo You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 15:17:21 2024 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 04 Mar 2024 10:17:21 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] x86-ncg: Fix fma codegen when arguments are globals. Message-ID: <65e5e6017015f_a5db0763c9bc80898@gitlab.mail> sheaf pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: ad0ecb8d by Andreas Klebinger at 2024-03-04T16:17:12+01:00 x86-ncg: Fix fma codegen when arguments are globals. Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 4 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3424,6 +3424,7 @@ genFMA3Code :: Width -> FMASign -> CmmExpr -> CmmExpr -> CmmExpr -> NatM Register genFMA3Code w signs x y z = do + -- platform <- getPlatform -- For the FMA instruction, we want to compute x * y + z -- @@ -3445,17 +3446,46 @@ genFMA3Code w signs x y z = do -- -- Currently we follow neither of these optimisations, -- opting to always use fmadd213 for simplicity. + -- + -- We would like to compute the result directly into the requested register. + -- To do so we must first compute `x` into the destination register. This is + -- only possible if the other arguments don't use the destination register. + -- We check for this and if there is a conflict we move the result only after + -- the computation. See #24496 how this went wrong in the past. let rep = floatFormat w (y_reg, y_code) <- getNonClobberedReg y - (z_reg, z_code) <- getNonClobberedReg z + (z_op, z_code) <- getNonClobberedOperand z x_code <- getAnyReg x + x_tmp <- getNewRegNat rep let fma213 = FMA3 rep signs FMA213 - code dst - = y_code `appOL` + + code, code_direct, code_mov :: Reg -> InstrBlock + -- Ideal: Compute the result directly into dst + code_direct dst = x_code dst `snocOL` + fma213 z_op y_reg dst + -- Fallback: Compute the result into a tmp reg and then move it. + code_mov dst = x_code x_tmp `snocOL` + fma213 z_op y_reg x_tmp `snocOL` + MOV rep (OpReg x_tmp) (OpReg dst) + + code dst = + y_code `appOL` z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_reg dst + ( if arg_regs_conflict then code_mov dst else code_direct dst ) + + where + + arg_regs_conflict = + y_reg == dst || + case z_op of + OpReg z_reg -> z_reg == dst + OpAddr amode -> dst `elem` addrModeRegs amode + OpImm {} -> False + + + -- NB: Computing the result into a desired register using Any can be tricky. + -- So for now keep it simple. (See #24496). return (Any rep code) ----------- ===================================== testsuite/tests/primops/should_run/T24496.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) +{-# NOINLINE twoProductFloat# #-} + +twoProductDouble# :: Double# -> Double# -> (# Double#, Double# #) +twoProductDouble# x y = let !r = x *## y + in (# r, fmsubDouble# x y r #) +{-# NOINLINE twoProductDouble# #-} + +main :: IO () +main = do + print $ case twoProductFloat# 2.0# 3.0# of (# r, s #) -> (F# r, F# s) + print $ case twoProductDouble# 2.0## 3.0## of (# r, s #) -> (D# r, D# s) ===================================== testsuite/tests/primops/should_run/T24496.stdout ===================================== @@ -0,0 +1,2 @@ +(6.0,0.0) +(6.0,0.0) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,3 +77,10 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) +test('T24496' + , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) + , js_skip # JS backend doesn't have an FMA implementation + , when(arch('wasm32'), skip) + , when(have_llvm(), extra_ways(["optllvm"])) + ] + , compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ad0ecb8d48764e1fec76b4231355c4492cd219ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ad0ecb8d48764e1fec76b4231355c4492cd219ba You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 15:17:41 2024 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 04 Mar 2024 10:17:41 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] 15 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e5e615e66ff_a5db077072d4824b4@gitlab.mail> sheaf pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - c16b3df4 by Andreas Klebinger at 2024-03-04T15:17:37+00:00 x86-ncg: Fix fma codegen when arguments are globals. Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad0ecb8d48764e1fec76b4231355c4492cd219ba...c16b3df468de6a021da12fce4fa359776fec75ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad0ecb8d48764e1fec76b4231355c4492cd219ba...c16b3df468de6a021da12fce4fa359776fec75ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 15:19:54 2024 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 04 Mar 2024 10:19:54 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_globals] x86-ncg: Fix fma codegen when arguments are globals Message-ID: <65e5e69ac36cd_a5db077aff4c82891@gitlab.mail> sheaf pushed to branch wip/andreask/fma_globals at Glasgow Haskell Compiler / GHC Commits: 4af8ca2b by Andreas Klebinger at 2024-03-04T16:19:33+01:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 4 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3424,7 +3424,6 @@ genFMA3Code :: Width -> FMASign -> CmmExpr -> CmmExpr -> CmmExpr -> NatM Register genFMA3Code w signs x y z = do - -- For the FMA instruction, we want to compute x * y + z -- -- There are three possible instructions we could emit: @@ -3445,17 +3444,45 @@ genFMA3Code w signs x y z = do -- -- Currently we follow neither of these optimisations, -- opting to always use fmadd213 for simplicity. + -- + -- We would like to compute the result directly into the requested register. + -- To do so we must first compute `x` into the destination register. This is + -- only possible if the other arguments don't use the destination register. + -- We check for this and if there is a conflict we move the result only after + -- the computation. See #24496 how this went wrong in the past. let rep = floatFormat w (y_reg, y_code) <- getNonClobberedReg y - (z_reg, z_code) <- getNonClobberedReg z + (z_op, z_code) <- getNonClobberedOperand z x_code <- getAnyReg x + x_tmp <- getNewRegNat rep let fma213 = FMA3 rep signs FMA213 - code dst - = y_code `appOL` + + code, code_direct, code_mov :: Reg -> InstrBlock + -- Ideal: Compute the result directly into dst + code_direct dst = x_code dst `snocOL` + fma213 z_op y_reg dst + -- Fallback: Compute the result into a tmp reg and then move it. + code_mov dst = x_code x_tmp `snocOL` + fma213 z_op y_reg x_tmp `snocOL` + MOV rep (OpReg x_tmp) (OpReg dst) + + code dst = + y_code `appOL` z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_reg dst + ( if arg_regs_conflict then code_mov dst else code_direct dst ) + + where + + arg_regs_conflict = + y_reg == dst || + case z_op of + OpReg z_reg -> z_reg == dst + OpAddr amode -> dst `elem` addrModeRegs amode + OpImm {} -> False + + -- NB: Computing the result into a desired register using Any can be tricky. + -- So for now, we keep it simple. (See #24496). return (Any rep code) ----------- ===================================== testsuite/tests/primops/should_run/T24496.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) +{-# NOINLINE twoProductFloat# #-} + +twoProductDouble# :: Double# -> Double# -> (# Double#, Double# #) +twoProductDouble# x y = let !r = x *## y + in (# r, fmsubDouble# x y r #) +{-# NOINLINE twoProductDouble# #-} + +main :: IO () +main = do + print $ case twoProductFloat# 2.0# 3.0# of (# r, s #) -> (F# r, F# s) + print $ case twoProductDouble# 2.0## 3.0## of (# r, s #) -> (D# r, D# s) ===================================== testsuite/tests/primops/should_run/T24496.stdout ===================================== @@ -0,0 +1,2 @@ +(6.0,0.0) +(6.0,0.0) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,3 +77,10 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) +test('T24496' + , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) + , js_skip # JS backend doesn't have an FMA implementation + , when(arch('wasm32'), skip) + , when(have_llvm(), extra_ways(["optllvm"])) + ] + , compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4af8ca2bd52f2949c8fefa7b45fafddaee86d609 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4af8ca2bd52f2949c8fefa7b45fafddaee86d609 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 15:52:24 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 10:52:24 -0500 Subject: [Git][ghc/ghc][wip/cross-stage2-rebased] 4 commits: hadrian: Build stage 2 cross compilers Message-ID: <65e5ee38437a8_a5db0868dc30865c2@gitlab.mail> Matthew Pickering pushed to branch wip/cross-stage2-rebased at Glasgow Haskell Compiler / GHC Commits: 3c992958 by Matthew Pickering at 2024-03-04T15:52:14+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 5bf8fc3d by Matthew Pickering at 2024-03-04T15:52:14+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - c4d6c385 by Matthew Pickering at 2024-03-04T15:52:14+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 1ab5a430 by Matthew Pickering at 2024-03-04T15:52:14+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - distrib/configure.ac.in - hadrian/bindist/config.mk.in - hadrian/hadrian.cabal - + hadrian/src/BindistConfig.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Expression.hs - hadrian/src/Hadrian/Haskell/Hash.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Flavour.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Program.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3d13d08c00296275d396d9ddf2caedade28e6f16...1ab5a43080caeda93f969a61971a7aaeadb18098 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3d13d08c00296275d396d9ddf2caedade28e6f16...1ab5a43080caeda93f969a61971a7aaeadb18098 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 16:36:41 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 04 Mar 2024 11:36:41 -0500 Subject: [Git][ghc/ghc][wip/fprof-overloaded] 17 commits: rts: avoid checking bdescr of value outside of Haskell heap Message-ID: <65e5f899edc85_a5db0989534c87968@gitlab.mail> Finley McIlwaine pushed to branch wip/fprof-overloaded at Glasgow Haskell Compiler / GHC Commits: 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 5d7c7bb5 by Finley McIlwaine at 2024-03-04T08:36:31-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7da9a1c3b403f1b9aa4e581ffbd4339b088f758d...5d7c7bb5667e52a2e154e25c1eb13f1de010dd3b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7da9a1c3b403f1b9aa4e581ffbd4339b088f758d...5d7c7bb5667e52a2e154e25c1eb13f1de010dd3b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 16:46:55 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 04 Mar 2024 11:46:55 -0500 Subject: [Git][ghc/ghc][wip/fprof-overloaded] add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e5faffac158_a5db0a1ea9889131a@gitlab.mail> Finley McIlwaine pushed to branch wip/fprof-overloaded at Glasgow Haskell Compiler / GHC Commits: c3dac715 by Finley McIlwaine at 2024-03-04T08:46:19-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods - - - - - 26 changed files: - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -1,164 +1,90 @@ -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE TupleSections #-} +{-# LANGUAGE RecordWildCards #-} --- | Adds cost-centers after the core piple has run. +-- | Adds cost-centers after the core pipline has run. module GHC.Core.LateCC - ( addLateCostCentresMG - , addLateCostCentresPgm - , addLateCostCentres -- Might be useful for API users - , Env(..) + ( -- * Inserting cost centres + addLateCostCenters ) where -import Control.Applicative -import Control.Monad -import qualified Data.Set as S - import GHC.Prelude -import GHC.Types.CostCentre -import GHC.Types.CostCentre.State -import GHC.Types.Name hiding (varName) -import GHC.Types.Tickish -import GHC.Unit.Module.ModGuts -import GHC.Types.Var -import GHC.Unit.Types -import GHC.Data.FastString -import GHC.Core -import GHC.Core.Opt.Monad -import GHC.Core.Utils (mkTick) -import GHC.Types.Id -import GHC.Driver.DynFlags +import GHC.Core +import GHC.Core.LateCC.OverloadedCalls +import GHC.Core.LateCC.TopLevelBinds +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Seq +import qualified GHC.Data.Strict as Strict +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.SrcLoc +import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Utils.Misc -import GHC.Utils.Error (withTiming) -import GHC.Utils.Monad.State.Strict - - -{- Note [Collecting late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Usually cost centres defined by a module are collected -during tidy by collectCostCentres. However with `-fprof-late` -we insert cost centres after inlining. So we keep a list of -all the cost centres we inserted and combine that with the list -of cost centres found during tidy. - -To avoid overhead when using -fprof-inline there is a flag to stop -us from collecting them here when we run this pass before tidy. - -Note [Adding late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The basic idea is very simple. For every top level binder -`f = rhs` we compile it as if the user had written -`f = {-# SCC f #-} rhs`. - -If we do this after unfoldings for `f` have been created this -doesn't impact core-level optimizations at all. If we do it -before the cost centre will be included in the unfolding and -might inhibit optimizations at the call site. For this reason -we provide flags for both approaches as they have different -tradeoffs. - -We also don't add a cost centre for any binder that is a constructor -worker or wrapper. These will never meaningfully enrich the resulting -profile so we improve efficiency by omitting those. - --} - -addLateCostCentresMG :: ModGuts -> CoreM ModGuts -addLateCostCentresMG guts = do - dflags <- getDynFlags - let env :: Env - env = Env - { thisModule = mg_module guts - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = False -- See Note [Collecting late cost centres] - } - let guts' = guts { mg_binds = fstOf3 (addLateCostCentres env (mg_binds guts)) - } - return guts' - -addLateCostCentresPgm :: DynFlags -> Logger -> Module -> CoreProgram -> IO (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentresPgm dflags logger mod binds = - withTiming logger - (text "LateCC"<+>brackets (ppr mod)) - (\(a,b,c) -> a `seqList` (b `seq` (c `seq` ()))) $ do - let env = Env - { thisModule = mod - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = True -- See Note [Collecting late cost centres] - } - (binds', ccs, cc_state) = addLateCostCentres env binds - when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ - putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr binds')) - return (binds', ccs, cc_state) -addLateCostCentres :: Env -> CoreProgram -> (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentres env binds = - let (binds', state) = runState (mapM (doBind env) binds) initLateCCState - in (binds', lcs_ccs state, lcs_state state) - - -doBind :: Env -> CoreBind -> M CoreBind -doBind env (NonRec b rhs) = NonRec b <$> doBndr env b rhs -doBind env (Rec bs) = Rec <$> mapM doPair bs +-- | Late cost center insertion logic used by the driver +addLateCostCenters :: + Logger + -- ^ Logger + -> LateCCConfig + -- ^ Late cost center configuration + -> CoreProgram + -- ^ The program + -> IO (CoreProgram, LateCCState (Strict.Maybe SrcSpan)) +addLateCostCenters logger LateCCConfig{..} core_binds = do + + -- If top-level late CCs are enabled via either -fprof-late or + -- -fprof-late-overloaded, add them + (top_level_cc_binds, top_level_late_cc_state) <- + case lateCCConfig_whichBinds of + LateCCNone -> + return (core_binds, initLateCCState ()) + _ -> + withTiming + logger + (text "LateTopLevelCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateTopLevelCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (initLateCCState ()) + (topLevelBindsCC top_level_cc_pred) + core_binds + + -- If overloaded call CCs are enabled via -fprof-late-overloaded-calls, add + -- them + (late_cc_binds, late_cc_state) <- + if lateCCConfig_overloadedCalls then + withTiming + logger + (text "LateOverloadedCallsCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateoverloadedCallsCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (top_level_late_cc_state { lateCCState_extra = Strict.Nothing }) + overloadedCallsCC + top_level_cc_binds + else + return + ( top_level_cc_binds + , top_level_late_cc_state { lateCCState_extra = Strict.Nothing } + ) + + return (late_cc_binds, late_cc_state) where - doPair :: ((Id, CoreExpr) -> M (Id, CoreExpr)) - doPair (b,rhs) = (b,) <$> doBndr env b rhs - -doBndr :: Env -> Id -> CoreExpr -> M CoreExpr -doBndr env bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = doBndr' env bndr rhs - - --- We want to put the cost centre below the lambda as we only care about executions of the RHS. -doBndr' :: Env -> Id -> CoreExpr -> State LateCCState CoreExpr -doBndr' env bndr (Lam b rhs) = Lam b <$> doBndr' env bndr rhs -doBndr' env bndr rhs = do - let name = idName bndr - name_loc = nameSrcSpan name - cc_name = getOccFS name - count = countEntries env - cc_flavour <- getCCFlavour cc_name - let cc_mod = thisModule env - bndrCC = NormalCC cc_flavour cc_name cc_mod name_loc - note = ProfNote bndrCC count True - addCC env bndrCC - return $ mkTick note rhs - -data LateCCState = LateCCState - { lcs_state :: !CostCentreState - , lcs_ccs :: S.Set CostCentre - } -type M = State LateCCState - -initLateCCState :: LateCCState -initLateCCState = LateCCState newCostCentreState mempty - -getCCFlavour :: FastString -> M CCFlavour -getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name - -getCCIndex' :: FastString -> M CostCentreIndex -getCCIndex' name = do - state <- get - let (index,cc_state') = getCCIndex name (lcs_state state) - put (state { lcs_state = cc_state'}) - return index - -addCC :: Env -> CostCentre -> M () -addCC !env cc = do - state <- get - when (collectCCs env) $ do - let ccs' = S.insert cc (lcs_ccs state) - put (state { lcs_ccs = ccs'}) - -data Env = Env - { thisModule :: !Module - , countEntries:: !Bool - , collectCCs :: !Bool - } - + top_level_cc_pred :: CoreExpr -> Bool + top_level_cc_pred = + case lateCCConfig_whichBinds of + LateCCAllBinds -> + const True + LateCCOverloadedBinds -> + isOverloadedTy . exprType + LateCCNone -> + -- This is here for completeness, we won't actually use this + -- predicate in this case since we'll shortcut. + const False + + this_mod = lateCCEnv_module lateCCConfig_env ===================================== compiler/GHC/Core/LateCC/OverloadedCalls.hs ===================================== @@ -0,0 +1,204 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} + +module GHC.Core.LateCC.OverloadedCalls + ( overloadedCallsCC + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified GHC.Data.Strict as Strict + +import GHC.Data.FastString +import GHC.Core +import GHC.Core.LateCC.Utils +import GHC.Core.LateCC.Types +import GHC.Core.Make +import GHC.Core.Predicate +import GHC.Core.Type +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.Id +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Types.Tickish +import GHC.Types.Var +import GHC.Utils.Outputable + +type OverloadedCallsCCState = Strict.Maybe SrcSpan + +-- | Insert cost centres on function applications with dictionary arguments. The +-- source locations attached to the cost centres is approximated based on the +-- "closest" source note encountered in the traversal. +overloadedCallsCC :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind +overloadedCallsCC = + processBind + where + processBind :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind + processBind core_bind = + case core_bind of + NonRec b e -> + NonRec b <$> wrap_if_join b (processExpr e) + Rec es -> + Rec <$> mapM (\(b,e) -> (b,) <$> wrap_if_join b (processExpr e)) es + where + -- If an overloaded function is turned into a join point, we won't add + -- SCCs directly to calls since it makes them non-tail calls. Instead, + -- we look for join points here and add an SCC to their RHS if they are + -- overloaded. + wrap_if_join :: + CoreBndr + -> LateCCM OverloadedCallsCCState CoreExpr + -> LateCCM OverloadedCallsCCState CoreExpr + wrap_if_join b pexpr = do + expr <- pexpr + if isJoinId b && isOverloadedTy (exprType expr) then do + let + cc_name :: FastString + cc_name = fsLit "join-rhs-" `appendFS` getOccFS b + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan expr + else + return expr + + + processExpr :: CoreExpr -> LateCCM OverloadedCallsCCState CoreExpr + processExpr expr = + case expr of + -- The case we care about: Application + app at App{} -> do + -- Here we have some application like `f v1 ... vN`, where v1 ... vN + -- should be the function's type arguments followed by the value + -- arguments. To determine if the `f` is an overloaded function, we + -- check if any of the arguments v1 ... vN are dictionaries. + let + (f, xs) = collectArgs app + resultTy = applyTypeToArgs empty (exprType f) xs + + -- Recursively process the arguments first for no particular reason + args <- mapM processExpr xs + let app' = mkCoreApps f args + + if + -- Check if any of the arguments are dictionaries + any isDictExpr args + + -- Avoid instrumenting dictionary functions, which may be + -- overloaded if there are superclasses, by checking if the result + -- type of the function is a dictionary type. + && not (isDictTy resultTy) + + -- Avoid instrumenting constraint selectors like eq_sel + && (typeTypeOrConstraint resultTy /= ConstraintLike) + + -- Avoid instrumenting join points. + -- (See comment in processBind above) + && not (isJoinVarExpr f) + then do + -- Extract a name and source location from the function being + -- applied + let + cc_name :: FastString + cc_name = + fsLit $ maybe "" getOccString (exprName app) + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan app' + else + return app' + + -- For recursive constructors of Expr, we traverse the nested Exprs + Lam b e -> + mkCoreLams [b] <$> processExpr e + Let b e -> + mkCoreLet <$> processBind b <*> processExpr e + Case e b t alts -> + Case + <$> processExpr e + <*> pure b + <*> pure t + <*> mapM processAlt alts + Cast e co -> + mkCast <$> processExpr e <*> pure co + Tick t e -> do + trackSourceNote t $ + mkTick t <$> processExpr e + + -- For non-recursive constructors of Expr, we do nothing + x -> return x + + processAlt :: CoreAlt -> LateCCM OverloadedCallsCCState CoreAlt + processAlt (Alt c bs e) = Alt c bs <$> processExpr e + + trackSourceNote :: CoreTickish -> LateCCM OverloadedCallsCCState a -> LateCCM OverloadedCallsCCState a + trackSourceNote tick act = + case tick of + SourceNote rss _ -> do + -- Prefer source notes from the current file + in_current_file <- + maybe False ((== EQ) . lexicalCompareFS (srcSpanFile rss)) <$> + asks lateCCEnv_file + if not in_current_file then + act + else do + loc <- lift $ gets lateCCState_extra + lift . modify $ \s -> + s { lateCCState_extra = + Strict.Just $ RealSrcSpan rss mempty + } + x <- act + lift . modify $ \s -> + s { lateCCState_extra = loc + } + return x + _ -> + act + + -- Utility functions + + -- Extract a Name from an expression. If it is an application, attempt to + -- extract a name from the applied function. If it is a variable, return the + -- Name of the variable. If it is a tick/cast, attempt to extract a Name + -- from the expression held in the tick/cast. Otherwise return Nothing. + exprName :: CoreExpr -> Maybe Name + exprName = + \case + App f _ -> + exprName f + Var f -> + Just (idName f) + Tick _ e -> + exprName e + Cast e _ -> + exprName e + _ -> + Nothing + + -- Determine whether an expression is a dictionary + isDictExpr :: CoreExpr -> Bool + isDictExpr = + maybe False isDictTy . exprType' + where + exprType' :: CoreExpr -> Maybe Type + exprType' = \case + Type{} -> Nothing + expr -> Just $ exprType expr + + -- Determine whether an expression is a join variable + isJoinVarExpr :: CoreExpr -> Bool + isJoinVarExpr = + \case + Var var -> isJoinId var + Tick _ e -> isJoinVarExpr e + Cast e _ -> isJoinVarExpr e + _ -> False ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE TupleSections #-} +module GHC.Core.LateCC.TopLevelBinds where + +import GHC.Prelude + +import GHC.Core +-- import GHC.Core.LateCC +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Opt.Monad +import GHC.Driver.DynFlags +import GHC.Types.Id +import GHC.Types.Name +import GHC.Unit.Module.ModGuts + +{- Note [Collecting late cost centres] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Usually cost centres defined by a module are collected +during tidy by collectCostCentres. However with `-fprof-late` +we insert cost centres after inlining. So we keep a list of +all the cost centres we inserted and combine that with the list +of cost centres found during tidy. + +To avoid overhead when using -fprof-inline there is a flag to stop +us from collecting them here when we run this pass before tidy. + +Note [Adding late cost centres to top level bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The basic idea is very simple. For every top level binder +`f = rhs` we compile it as if the user had written +`f = {-# SCC f #-} rhs`. + +If we do this after unfoldings for `f` have been created this +doesn't impact core-level optimizations at all. If we do it +before the cost centre will be included in the unfolding and +might inhibit optimizations at the call site. For this reason +we provide flags for both approaches as they have different +tradeoffs. + +We also don't add a cost centre for any binder that is a constructor +worker or wrapper. These will never meaningfully enrich the resulting +profile so we improve efficiency by omitting those. + +-} + +-- | Add late cost centres directly to the 'ModGuts'. This is used inside the +-- core pipeline with the -fprof-late-inline flag. It should not be used after +-- tidy, since it does not manually track inserted cost centers. See +-- Note [Collecting late cost centres]. +topLevelBindsCCMG :: ModGuts -> CoreM ModGuts +topLevelBindsCCMG guts = do + dflags <- getDynFlags + let + env = + LateCCEnv + { lateCCEnv_module = mg_module guts + + -- We don't use this for topLevelBindsCC, so Nothing is okay + , lateCCEnv_file = Nothing + + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = False + } + guts' = + guts + { mg_binds = + fst + ( doLateCostCenters + env + (initLateCCState ()) + (topLevelBindsCC (const True)) + (mg_binds guts) + ) + } + return guts' + +-- | Insert cost centres on top-level bindings in the module, depending on +-- whether or not they satisfy the given predicate. +topLevelBindsCC :: (CoreExpr -> Bool) -> CoreBind -> LateCCM s CoreBind +topLevelBindsCC pred core_bind = + case core_bind of + NonRec b rhs -> + NonRec b <$> doBndr b rhs + Rec bs -> + Rec <$> mapM doPair bs + where + doPair :: ((Id, CoreExpr) -> LateCCM s (Id, CoreExpr)) + doPair (b,rhs) = (b,) <$> doBndr b rhs + + doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr + doBndr bndr rhs + -- Cost centres on constructor workers are pretty much useless + -- so we don't emit them if we are looking at the rhs of a constructor + -- binding. + | Just _ <- isDataConId_maybe bndr = pure rhs + | otherwise = if pred rhs then addCC bndr rhs else pure rhs + + -- We want to put the cost centre below the lambda as we only care about + -- executions of the RHS. + addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs + addCC bndr rhs = do + let name = idName bndr + cc_loc = nameSrcSpan name + cc_name = getOccFS name + insertCC cc_name cc_loc rhs \ No newline at end of file ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -0,0 +1,74 @@ +-- | Types related to late cost center insertion +module GHC.Core.LateCC.Types + ( LateCCConfig(..) + , LateCCBindSpec(..) + , LateCCEnv(..) + , LateCCState(..) + , initLateCCState + , LateCCM + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Unit.Types + +-- | Late cost center insertion configuration. +-- +-- Specifies whether cost centers are added to overloaded function call sites +-- and/or top-level bindings, and which top-level bindings they are added to. +-- Also holds the cost center insertion environment. +data LateCCConfig = + LateCCConfig + { lateCCConfig_whichBinds :: !LateCCBindSpec + , lateCCConfig_overloadedCalls :: !Bool + , lateCCConfig_env :: !LateCCEnv + } + +-- | The types of top-level bindings we support adding cost centers to. +data LateCCBindSpec = + LateCCNone + | LateCCAllBinds + | LateCCOverloadedBinds + +-- | Late cost centre insertion environment +data LateCCEnv = LateCCEnv + { lateCCEnv_module :: !Module + -- ^ Current module + , lateCCEnv_file :: Maybe FastString + -- ^ Current file, if we have one + , lateCCEnv_countEntries:: !Bool + -- ^ Whether the inserted cost centers should count entries + , lateCCEnv_collectCCs :: !Bool + -- ^ Whether to collect the cost centres we insert. See + -- Note [Collecting late cost centres] + + } + +-- | Late cost centre insertion state, indexed by some extra state type that an +-- insertion method may require. +data LateCCState s = LateCCState + { lateCCState_ccs :: !(S.Set CostCentre) + -- ^ Cost centres that have been inserted + , lateCCState_ccState :: !CostCentreState + -- ^ Per-module state tracking for cost centre indices + , lateCCState_extra :: !s + } + +-- | The empty late cost centre insertion state +initLateCCState :: s -> LateCCState s +initLateCCState s = + LateCCState + { lateCCState_ccState = newCostCentreState + , lateCCState_ccs = mempty + , lateCCState_extra = s + } + +-- | Late cost centre insertion monad +type LateCCM s = ReaderT LateCCEnv (State (LateCCState s)) ===================================== compiler/GHC/Core/LateCC/Utils.hs ===================================== @@ -0,0 +1,80 @@ +module GHC.Core.LateCC.Utils + ( -- * Inserting cost centres + doLateCostCenters -- Might be useful for API users + + -- ** Helpers for defining insertion methods + , getCCFlavour + , insertCC + ) where + +import GHC.Prelude + +import Control.Monad +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Core +import GHC.Core.LateCC.Types +import GHC.Core.Utils +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Types.SrcLoc +import GHC.Types.Tickish + +-- | Insert cost centres into the 'CoreProgram' using the provided environment, +-- initial state, and insertion method. +doLateCostCenters + :: LateCCEnv + -- ^ Environment to run the insertion in + -> LateCCState s + -- ^ Initial state to run the insertion with + -> (CoreBind -> LateCCM s CoreBind) + -- ^ Insertion method + -> CoreProgram + -- ^ Bindings to consider + -> (CoreProgram, LateCCState s) +doLateCostCenters env state method binds = + runLateCC env state $ mapM method binds + +-- | Evaluate late cost centre insertion +runLateCC :: LateCCEnv -> LateCCState s -> LateCCM s a -> (a, LateCCState s) +runLateCC env state = (`runState` state) . (`runReaderT` env) + +-- | Given the name of a cost centre, get its flavour +getCCFlavour :: FastString -> LateCCM s CCFlavour +getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name + where + getCCIndex' :: FastString -> LateCCM s CostCentreIndex + getCCIndex' name = do + cc_state <- lift $ gets lateCCState_ccState + let (index, cc_state') = getCCIndex name cc_state + lift . modify $ \s -> s { lateCCState_ccState = cc_state'} + return index + +-- | Insert a cost centre with the specified name and source span on the given +-- expression. The inserted cost centre will be appropriately tracked in the +-- late cost centre state. +insertCC + :: FastString + -- ^ Name of the cost centre to insert + -> SrcSpan + -- ^ Source location to associate with the cost centre + -> CoreExpr + -- ^ Expression to wrap in the cost centre + -> LateCCM s CoreExpr +insertCC cc_name cc_loc expr = do + cc_flavour <- getCCFlavour cc_name + env <- ask + let + cc_mod = lateCCEnv_module env + cc = NormalCC cc_flavour cc_name cc_mod cc_loc + note = ProfNote cc (lateCCEnv_countEntries env) True + when (lateCCEnv_collectCCs env) $ do + lift . modify $ \s -> + s { lateCCState_ccs = S.insert cc (lateCCState_ccs s) + } + return $ mkTick note expr + ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) import GHC.Core.Opt.CallerCC ( addCallerCostCentres ) -import GHC.Core.LateCC (addLateCostCentresMG) +import GHC.Core.LateCC.TopLevelBinds (topLevelBindsCCMG) import GHC.Core.Seq (seqBinds) import GHC.Core.FamInstEnv @@ -520,7 +520,7 @@ doCorePass pass guts = do addCallerCostCentres guts CoreAddLateCcs -> {-# SCC "AddLateCcs" #-} - addLateCostCentresMG guts + topLevelBindsCCMG guts CoreDoPrintCore -> {-# SCC "PrintCore" #-} liftIO $ printCore logger (mg_binds guts) >> return guts ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -341,6 +341,8 @@ data GeneralFlag | Opt_ProfCountEntries | Opt_ProfLateInlineCcs | Opt_ProfLateCcs + | Opt_ProfLateOverloadedCcs + | Opt_ProfLateoverloadedCallsCCs | Opt_ProfManualCcs -- ^ Ignore manual SCC annotations -- misc opts ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -175,7 +175,6 @@ import GHC.Iface.Ext.Debug ( diffFile, validateScopes ) import GHC.Core import GHC.Core.Lint.Interactive ( interactiveInScope ) import GHC.Core.Tidy ( tidyExpr ) -import GHC.Core.Type ( Type, Kind ) import GHC.Core.Utils ( exprType ) import GHC.Core.ConLike import GHC.Core.Opt.Pipeline @@ -185,7 +184,8 @@ import GHC.Core.InstEnv import GHC.Core.FamInstEnv import GHC.Core.Rules import GHC.Core.Stats -import GHC.Core.LateCC (addLateCostCentresPgm) +import GHC.Core.LateCC +import GHC.Core.LateCC.Types import GHC.CoreToStg.Prep @@ -197,6 +197,7 @@ import GHC.Parser.Lexer as Lexer import GHC.Tc.Module import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.TcType import GHC.Tc.Zonk.Env ( ZonkFlexi (DefaultFlexi) ) import GHC.Stg.Syntax @@ -297,7 +298,6 @@ import GHC.StgToCmm.Utils (IPEStats) import GHC.Types.Unique.FM import GHC.Types.Unique.DFM import GHC.Cmm.Config (CmmConfig) -import GHC.Types.CostCentre.State (newCostCentreState) {- ********************************************************************** @@ -1791,22 +1791,41 @@ hscGenHardCode hsc_env cgguts location output_filename = do ------------------- - -- Insert late cost centres if enabled. - -- If `-fprof-late-inline` is enabled we can skip this, as it will have added - -- a superset of cost centres we would add here already. - - (late_cc_binds, late_local_ccs, cc_state) <- - if gopt Opt_ProfLateCcs dflags && not (gopt Opt_ProfLateInlineCcs dflags) - then - withTiming - logger - (text "LateCCs"<+>brackets (ppr this_mod)) - (const ()) - $ {-# SCC lateCC #-} do - (binds, late_ccs, cc_state) <- addLateCostCentresPgm dflags logger this_mod core_binds - return ( binds, (S.toList late_ccs `mappend` local_ccs ), cc_state) + -- Insert late cost centres based on the provided flags. + -- + -- If -fprof-late-inline is enabled, we will skip adding CCs on any + -- top-level bindings here (via shortcut in `addLateCostCenters`), + -- since it will have already added a superset of the CCs we would add + -- here. + let + late_cc_config :: LateCCConfig + late_cc_config = + LateCCConfig + { lateCCConfig_whichBinds = + if gopt Opt_ProfLateInlineCcs dflags then + LateCCNone + else if gopt Opt_ProfLateCcs dflags then + LateCCAllBinds + else if gopt Opt_ProfLateOverloadedCcs dflags then + LateCCOverloadedBinds else - return (core_binds, local_ccs, newCostCentreState) + LateCCNone + , lateCCConfig_overloadedCalls = + gopt Opt_ProfLateoverloadedCallsCCs dflags + , lateCCConfig_env = + LateCCEnv + { lateCCEnv_module = this_mod + , lateCCEnv_file = fsLit <$> ml_hs_file location + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = True + } + } + + (late_cc_binds, late_cc_state) <- + addLateCostCenters logger late_cc_config core_binds + + when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ + putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr late_cc_binds)) ------------------- -- Run late plugins @@ -1820,7 +1839,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do cg_hpc_info = hpc_info, cg_spt_entries = spt_entries, cg_binds = late_binds, - cg_ccs = late_local_ccs' + cg_ccs = late_local_ccs } , _ ) <- @@ -1833,9 +1852,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do (($ hsc_env) . latePlugin) ( cgguts { cg_binds = late_cc_binds - , cg_ccs = late_local_ccs + , cg_ccs = S.toList (lateCCState_ccs late_cc_state) ++ local_ccs } - , cc_state + , lateCCState_ccState late_cc_state ) let @@ -1876,7 +1895,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do let (stg_binds,_stg_deps) = unzip stg_binds_with_deps let cost_centre_info = - (late_local_ccs' ++ caf_ccs, caf_cc_stacks) + (late_local_ccs ++ caf_ccs, caf_cc_stacks) platform = targetPlatform dflags prof_init | sccProfilingEnabled dflags = profilingInitCode platform this_mod cost_centre_info ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2444,6 +2444,8 @@ fFlagsDeps = [ flagSpec "prof-cafs" Opt_AutoSccsOnIndividualCafs, flagSpec "prof-count-entries" Opt_ProfCountEntries, flagSpec "prof-late" Opt_ProfLateCcs, + flagSpec "prof-late-overloaded" Opt_ProfLateOverloadedCcs, + flagSpec "prof-late-overloaded-calls" Opt_ProfLateoverloadedCallsCCs, flagSpec "prof-manual" Opt_ProfManualCcs, flagSpec "prof-late-inline" Opt_ProfLateInlineCcs, flagSpec "regs-graph" Opt_RegsGraph, @@ -3763,6 +3765,10 @@ needSourceNotes :: DynFlags -> Bool needSourceNotes dflags = debugLevel dflags > 0 || gopt Opt_InfoTableMap dflags + -- Source ticks are used to approximate the location of + -- overloaded call cost centers + || gopt Opt_ProfLateoverloadedCallsCCs dflags + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1907,7 +1907,7 @@ isRhoExpTy (Infer {}) = True isOverloadedTy :: Type -> Bool -- Yes for a type of a function that might require evidence-passing --- Used only by bindLocalMethods +-- Used by bindLocalMethods and for -fprof-late-overloaded isOverloadedTy ty | Just ty' <- coreView ty = isOverloadedTy ty' isOverloadedTy (ForAllTy _ ty) = isOverloadedTy ty isOverloadedTy (FunTy { ft_af = af }) = isInvisibleFunArg af ===================================== compiler/ghc.cabal.in ===================================== @@ -336,6 +336,10 @@ Library GHC.Core.Lint GHC.Core.Lint.Interactive GHC.Core.LateCC + GHC.Core.LateCC.Types + GHC.Core.LateCC.TopLevelBinds + GHC.Core.LateCC.Utils + GHC.Core.LateCC.OverloadedCalls GHC.Core.Make GHC.Core.Map.Expr GHC.Core.Map.Type ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -186,6 +186,15 @@ Compiler This means that if you are using ``-fllvm`` you now need ``llc``, ``opt`` and ``clang`` available. +- The :ghc-flag:`-fprof-late-overloaded` flag has been introduced. It causes + cost centres to be added to *overloaded* top level bindings, unlike + :ghc-flag:`-fprof-late` which adds cost centres to all top level bindings. + +- The :ghc-flag:`-fprof-late-overloaded-calls` flag has been introduced. It + causes cost centres to be inserted at call sites including instance dictionary + arguments. This may be preferred over :ghc-flag:`-fprof-late-overloaded` since + it may reveal whether imported functions are called overloaded. + JavaScript backend ~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -518,6 +518,49 @@ of your profiled program will be different to that of the unprofiled one. You can try this mode if :ghc-flag:`-fprof-late` results in a profile that's too hard to interpret. +.. ghc-flag:: -fprof-late-overloaded + :shortdesc: Auto-add ``SCC``\\ s to all top level overloaded bindings *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all *overloaded* top level bindings + late in the compilation pipeline after the optimizer has run and unfoldings + have been created. This means these cost centres will not interfere with + core-level optimizations and the resulting profile will be closer to the + performance profile of an optimized non-profiled executable. + + This flag can help determine which top level bindings encountered during a + program's execution are still overloaded after inlining and specialization. + +.. ghc-flag:: -fprof-late-overloaded-calls + :shortdesc: Auto-add ``SCC``\\ s to all call sites that include dictionary arguments *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded-calls + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all call sites that include + dictionary arguments late in the compilation pipeline after the optimizer + has run and unfoldings have been created. This means these cost centres will + not interfere with core-level optimizations and the resulting profile will + be closer to the performance profile of an optimized non-profiled + executable. + + This flag is potentially more useful than :ghc-flag:`-fprof-late-overloaded` + since it will also add ``SCC`` annotations to call sites of imported + overloaded functions. + + Some overloaded calls may not be annotated, specifically in cases where the + optimizer turns an overloaded function into a join point. Calls to such + functions will not be wrapped in ``SCC`` annotations, since it would make + them non-tail calls, which is a requirement for join points. Instead, + ``SCC`` annotations are added around the body of overloaded join variables + and given distinct names (``join-rhs-``) to avoid confusion. + .. ghc-flag:: -fprof-cafs :shortdesc: Auto-add ``SCC``\\ s to all CAFs :type: dynamic ===================================== testsuite/tests/profiling/should_run/all.T ===================================== @@ -195,3 +195,30 @@ test('ignore_scc', [], compile_and_run, ['-fno-prof-manual']) test('T21446', [], makefile_test, ['T21446']) + + +test('scc-prof-overloaded001', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded002', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls001', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fno-full-laziness -fprof-late-overloaded-calls'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls002', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fprof-late-overloaded-calls'] +) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample ===================================== @@ -0,0 +1,26 @@ + Thu Jan 4 11:49 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,320 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded-calls001.hs:24:1-31 256 1 0.0 0.3 0.0 0.8 + f Main scc-prof-overloaded-calls001.hs:18:1-18 257 1 0.0 0.6 0.0 0.6 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample ===================================== @@ -0,0 +1,31 @@ + Fri Jan 5 11:06 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls002 +RTS -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 59,152 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 34.8 +CAF GHC.IO.Handle.FD 0.0 58.7 +CAF GHC.IO.Encoding 0.0 4.1 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 34.8 0.0 100.0 + CAF Main 255 0 0.0 0.6 0.0 0.9 + f Main scc-prof-overloaded-calls002.hs:52:1-25 262 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:48:1-25 261 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:44:1-25 260 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:40:1-25 259 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:36:1-25 258 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:32:1-25 257 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:28:1-25 256 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.1 0.0 4.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.3 0.0 0.3 + CAF GHC.IO.Handle.FD 208 0 0.0 58.7 0.0 58.7 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample ===================================== @@ -0,0 +1,25 @@ + Thu Jan 4 11:26 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,304 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded001.hs:18:1-6 256 1 0.0 0.8 0.0 0.8 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample ===================================== @@ -0,0 +1,23 @@ + Thu Jan 4 11:55 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded002 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 56,472 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 32.7 +CAF GHC.IO.Handle.FD 0.0 61.5 +CAF GHC.IO.Encoding 0.0 4.3 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 32.7 0.0 100.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.3 0.0 4.3 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 61.5 0.0 61.5 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c3dac715b6b689772c739da695933148a2018896 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c3dac715b6b689772c739da695933148a2018896 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 16:59:32 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 11:59:32 -0500 Subject: [Git][ghc/ghc][wip/cross-stage2-rebased] Fix genapply Message-ID: <65e5fdf480050_a5db0a44490493723@gitlab.mail> Matthew Pickering pushed to branch wip/cross-stage2-rebased at Glasgow Haskell Compiler / GHC Commits: 8d15c356 by Matthew Pickering at 2024-03-04T16:59:24+00:00 Fix genapply - - - - - 1 changed file: - hadrian/src/Settings/Default.hs Changes: ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -73,6 +73,7 @@ stageBootPackages = return , deriveConstants , genprimopcode , unlit + , genapply ] -- | Packages built in 'Stage0' by default. You can change this in "UserSettings". @@ -112,7 +113,6 @@ stage0Packages = do , transformers , unlit , hp2ps - , genapply , if windowsHost then win32 else unix ] ++ [ terminfo | not windowsHost, not cross ] @@ -132,7 +132,6 @@ stage1Packages = do libraries0 <- filter good_stage0_package <$> stage0Packages cross <- flag CrossCompiling winTarget <- isWinTarget Stage1 - jsTarget <- isJsTarget Stage2 let when c xs = if c then xs else mempty @@ -164,8 +163,6 @@ stage1Packages = do , hpcBin , if winTarget then win32 else unix ] ++ - [ genapply | not jsTarget ] - ++ [ iserv , runGhc , ghcToolchainBin View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d15c356d39773c1257dfc89dfb4e72ba4f4ce29 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d15c356d39773c1257dfc89dfb4e72ba4f4ce29 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 17:02:53 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 04 Mar 2024 12:02:53 -0500 Subject: [Git][ghc/ghc][wip/fprof-overloaded] add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e5febdbb745_a5db0a70eea095710@gitlab.mail> Finley McIlwaine pushed to branch wip/fprof-overloaded at Glasgow Haskell Compiler / GHC Commits: 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 26 changed files: - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -1,164 +1,90 @@ -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE TupleSections #-} +{-# LANGUAGE RecordWildCards #-} --- | Adds cost-centers after the core piple has run. +-- | Adds cost-centers after the core pipline has run. module GHC.Core.LateCC - ( addLateCostCentresMG - , addLateCostCentresPgm - , addLateCostCentres -- Might be useful for API users - , Env(..) + ( -- * Inserting cost centres + addLateCostCenters ) where -import Control.Applicative -import Control.Monad -import qualified Data.Set as S - import GHC.Prelude -import GHC.Types.CostCentre -import GHC.Types.CostCentre.State -import GHC.Types.Name hiding (varName) -import GHC.Types.Tickish -import GHC.Unit.Module.ModGuts -import GHC.Types.Var -import GHC.Unit.Types -import GHC.Data.FastString -import GHC.Core -import GHC.Core.Opt.Monad -import GHC.Core.Utils (mkTick) -import GHC.Types.Id -import GHC.Driver.DynFlags +import GHC.Core +import GHC.Core.LateCC.OverloadedCalls +import GHC.Core.LateCC.TopLevelBinds +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Seq +import qualified GHC.Data.Strict as Strict +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.SrcLoc +import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Utils.Misc -import GHC.Utils.Error (withTiming) -import GHC.Utils.Monad.State.Strict - - -{- Note [Collecting late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Usually cost centres defined by a module are collected -during tidy by collectCostCentres. However with `-fprof-late` -we insert cost centres after inlining. So we keep a list of -all the cost centres we inserted and combine that with the list -of cost centres found during tidy. - -To avoid overhead when using -fprof-inline there is a flag to stop -us from collecting them here when we run this pass before tidy. - -Note [Adding late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The basic idea is very simple. For every top level binder -`f = rhs` we compile it as if the user had written -`f = {-# SCC f #-} rhs`. - -If we do this after unfoldings for `f` have been created this -doesn't impact core-level optimizations at all. If we do it -before the cost centre will be included in the unfolding and -might inhibit optimizations at the call site. For this reason -we provide flags for both approaches as they have different -tradeoffs. - -We also don't add a cost centre for any binder that is a constructor -worker or wrapper. These will never meaningfully enrich the resulting -profile so we improve efficiency by omitting those. - --} - -addLateCostCentresMG :: ModGuts -> CoreM ModGuts -addLateCostCentresMG guts = do - dflags <- getDynFlags - let env :: Env - env = Env - { thisModule = mg_module guts - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = False -- See Note [Collecting late cost centres] - } - let guts' = guts { mg_binds = fstOf3 (addLateCostCentres env (mg_binds guts)) - } - return guts' - -addLateCostCentresPgm :: DynFlags -> Logger -> Module -> CoreProgram -> IO (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentresPgm dflags logger mod binds = - withTiming logger - (text "LateCC"<+>brackets (ppr mod)) - (\(a,b,c) -> a `seqList` (b `seq` (c `seq` ()))) $ do - let env = Env - { thisModule = mod - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = True -- See Note [Collecting late cost centres] - } - (binds', ccs, cc_state) = addLateCostCentres env binds - when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ - putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr binds')) - return (binds', ccs, cc_state) -addLateCostCentres :: Env -> CoreProgram -> (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentres env binds = - let (binds', state) = runState (mapM (doBind env) binds) initLateCCState - in (binds', lcs_ccs state, lcs_state state) - - -doBind :: Env -> CoreBind -> M CoreBind -doBind env (NonRec b rhs) = NonRec b <$> doBndr env b rhs -doBind env (Rec bs) = Rec <$> mapM doPair bs +-- | Late cost center insertion logic used by the driver +addLateCostCenters :: + Logger + -- ^ Logger + -> LateCCConfig + -- ^ Late cost center configuration + -> CoreProgram + -- ^ The program + -> IO (CoreProgram, LateCCState (Strict.Maybe SrcSpan)) +addLateCostCenters logger LateCCConfig{..} core_binds = do + + -- If top-level late CCs are enabled via either -fprof-late or + -- -fprof-late-overloaded, add them + (top_level_cc_binds, top_level_late_cc_state) <- + case lateCCConfig_whichBinds of + LateCCNone -> + return (core_binds, initLateCCState ()) + _ -> + withTiming + logger + (text "LateTopLevelCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateTopLevelCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (initLateCCState ()) + (topLevelBindsCC top_level_cc_pred) + core_binds + + -- If overloaded call CCs are enabled via -fprof-late-overloaded-calls, add + -- them + (late_cc_binds, late_cc_state) <- + if lateCCConfig_overloadedCalls then + withTiming + logger + (text "LateOverloadedCallsCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateoverloadedCallsCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (top_level_late_cc_state { lateCCState_extra = Strict.Nothing }) + overloadedCallsCC + top_level_cc_binds + else + return + ( top_level_cc_binds + , top_level_late_cc_state { lateCCState_extra = Strict.Nothing } + ) + + return (late_cc_binds, late_cc_state) where - doPair :: ((Id, CoreExpr) -> M (Id, CoreExpr)) - doPair (b,rhs) = (b,) <$> doBndr env b rhs - -doBndr :: Env -> Id -> CoreExpr -> M CoreExpr -doBndr env bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = doBndr' env bndr rhs - - --- We want to put the cost centre below the lambda as we only care about executions of the RHS. -doBndr' :: Env -> Id -> CoreExpr -> State LateCCState CoreExpr -doBndr' env bndr (Lam b rhs) = Lam b <$> doBndr' env bndr rhs -doBndr' env bndr rhs = do - let name = idName bndr - name_loc = nameSrcSpan name - cc_name = getOccFS name - count = countEntries env - cc_flavour <- getCCFlavour cc_name - let cc_mod = thisModule env - bndrCC = NormalCC cc_flavour cc_name cc_mod name_loc - note = ProfNote bndrCC count True - addCC env bndrCC - return $ mkTick note rhs - -data LateCCState = LateCCState - { lcs_state :: !CostCentreState - , lcs_ccs :: S.Set CostCentre - } -type M = State LateCCState - -initLateCCState :: LateCCState -initLateCCState = LateCCState newCostCentreState mempty - -getCCFlavour :: FastString -> M CCFlavour -getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name - -getCCIndex' :: FastString -> M CostCentreIndex -getCCIndex' name = do - state <- get - let (index,cc_state') = getCCIndex name (lcs_state state) - put (state { lcs_state = cc_state'}) - return index - -addCC :: Env -> CostCentre -> M () -addCC !env cc = do - state <- get - when (collectCCs env) $ do - let ccs' = S.insert cc (lcs_ccs state) - put (state { lcs_ccs = ccs'}) - -data Env = Env - { thisModule :: !Module - , countEntries:: !Bool - , collectCCs :: !Bool - } - + top_level_cc_pred :: CoreExpr -> Bool + top_level_cc_pred = + case lateCCConfig_whichBinds of + LateCCAllBinds -> + const True + LateCCOverloadedBinds -> + isOverloadedTy . exprType + LateCCNone -> + -- This is here for completeness, we won't actually use this + -- predicate in this case since we'll shortcut. + const False + + this_mod = lateCCEnv_module lateCCConfig_env ===================================== compiler/GHC/Core/LateCC/OverloadedCalls.hs ===================================== @@ -0,0 +1,204 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} + +module GHC.Core.LateCC.OverloadedCalls + ( overloadedCallsCC + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified GHC.Data.Strict as Strict + +import GHC.Data.FastString +import GHC.Core +import GHC.Core.LateCC.Utils +import GHC.Core.LateCC.Types +import GHC.Core.Make +import GHC.Core.Predicate +import GHC.Core.Type +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.Id +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Types.Tickish +import GHC.Types.Var +import GHC.Utils.Outputable + +type OverloadedCallsCCState = Strict.Maybe SrcSpan + +-- | Insert cost centres on function applications with dictionary arguments. The +-- source locations attached to the cost centres is approximated based on the +-- "closest" source note encountered in the traversal. +overloadedCallsCC :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind +overloadedCallsCC = + processBind + where + processBind :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind + processBind core_bind = + case core_bind of + NonRec b e -> + NonRec b <$> wrap_if_join b (processExpr e) + Rec es -> + Rec <$> mapM (\(b,e) -> (b,) <$> wrap_if_join b (processExpr e)) es + where + -- If an overloaded function is turned into a join point, we won't add + -- SCCs directly to calls since it makes them non-tail calls. Instead, + -- we look for join points here and add an SCC to their RHS if they are + -- overloaded. + wrap_if_join :: + CoreBndr + -> LateCCM OverloadedCallsCCState CoreExpr + -> LateCCM OverloadedCallsCCState CoreExpr + wrap_if_join b pexpr = do + expr <- pexpr + if isJoinId b && isOverloadedTy (exprType expr) then do + let + cc_name :: FastString + cc_name = fsLit "join-rhs-" `appendFS` getOccFS b + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan expr + else + return expr + + + processExpr :: CoreExpr -> LateCCM OverloadedCallsCCState CoreExpr + processExpr expr = + case expr of + -- The case we care about: Application + app at App{} -> do + -- Here we have some application like `f v1 ... vN`, where v1 ... vN + -- should be the function's type arguments followed by the value + -- arguments. To determine if the `f` is an overloaded function, we + -- check if any of the arguments v1 ... vN are dictionaries. + let + (f, xs) = collectArgs app + resultTy = applyTypeToArgs empty (exprType f) xs + + -- Recursively process the arguments first for no particular reason + args <- mapM processExpr xs + let app' = mkCoreApps f args + + if + -- Check if any of the arguments are dictionaries + any isDictExpr args + + -- Avoid instrumenting dictionary functions, which may be + -- overloaded if there are superclasses, by checking if the result + -- type of the function is a dictionary type. + && not (isDictTy resultTy) + + -- Avoid instrumenting constraint selectors like eq_sel + && (typeTypeOrConstraint resultTy /= ConstraintLike) + + -- Avoid instrumenting join points. + -- (See comment in processBind above) + && not (isJoinVarExpr f) + then do + -- Extract a name and source location from the function being + -- applied + let + cc_name :: FastString + cc_name = + fsLit $ maybe "" getOccString (exprName app) + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan app' + else + return app' + + -- For recursive constructors of Expr, we traverse the nested Exprs + Lam b e -> + mkCoreLams [b] <$> processExpr e + Let b e -> + mkCoreLet <$> processBind b <*> processExpr e + Case e b t alts -> + Case + <$> processExpr e + <*> pure b + <*> pure t + <*> mapM processAlt alts + Cast e co -> + mkCast <$> processExpr e <*> pure co + Tick t e -> do + trackSourceNote t $ + mkTick t <$> processExpr e + + -- For non-recursive constructors of Expr, we do nothing + x -> return x + + processAlt :: CoreAlt -> LateCCM OverloadedCallsCCState CoreAlt + processAlt (Alt c bs e) = Alt c bs <$> processExpr e + + trackSourceNote :: CoreTickish -> LateCCM OverloadedCallsCCState a -> LateCCM OverloadedCallsCCState a + trackSourceNote tick act = + case tick of + SourceNote rss _ -> do + -- Prefer source notes from the current file + in_current_file <- + maybe False ((== EQ) . lexicalCompareFS (srcSpanFile rss)) <$> + asks lateCCEnv_file + if not in_current_file then + act + else do + loc <- lift $ gets lateCCState_extra + lift . modify $ \s -> + s { lateCCState_extra = + Strict.Just $ RealSrcSpan rss mempty + } + x <- act + lift . modify $ \s -> + s { lateCCState_extra = loc + } + return x + _ -> + act + + -- Utility functions + + -- Extract a Name from an expression. If it is an application, attempt to + -- extract a name from the applied function. If it is a variable, return the + -- Name of the variable. If it is a tick/cast, attempt to extract a Name + -- from the expression held in the tick/cast. Otherwise return Nothing. + exprName :: CoreExpr -> Maybe Name + exprName = + \case + App f _ -> + exprName f + Var f -> + Just (idName f) + Tick _ e -> + exprName e + Cast e _ -> + exprName e + _ -> + Nothing + + -- Determine whether an expression is a dictionary + isDictExpr :: CoreExpr -> Bool + isDictExpr = + maybe False isDictTy . exprType' + where + exprType' :: CoreExpr -> Maybe Type + exprType' = \case + Type{} -> Nothing + expr -> Just $ exprType expr + + -- Determine whether an expression is a join variable + isJoinVarExpr :: CoreExpr -> Bool + isJoinVarExpr = + \case + Var var -> isJoinId var + Tick _ e -> isJoinVarExpr e + Cast e _ -> isJoinVarExpr e + _ -> False ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE TupleSections #-} +module GHC.Core.LateCC.TopLevelBinds where + +import GHC.Prelude + +import GHC.Core +-- import GHC.Core.LateCC +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Opt.Monad +import GHC.Driver.DynFlags +import GHC.Types.Id +import GHC.Types.Name +import GHC.Unit.Module.ModGuts + +{- Note [Collecting late cost centres] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Usually cost centres defined by a module are collected +during tidy by collectCostCentres. However with `-fprof-late` +we insert cost centres after inlining. So we keep a list of +all the cost centres we inserted and combine that with the list +of cost centres found during tidy. + +To avoid overhead when using -fprof-inline there is a flag to stop +us from collecting them here when we run this pass before tidy. + +Note [Adding late cost centres to top level bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The basic idea is very simple. For every top level binder +`f = rhs` we compile it as if the user had written +`f = {-# SCC f #-} rhs`. + +If we do this after unfoldings for `f` have been created this +doesn't impact core-level optimizations at all. If we do it +before the cost centre will be included in the unfolding and +might inhibit optimizations at the call site. For this reason +we provide flags for both approaches as they have different +tradeoffs. + +We also don't add a cost centre for any binder that is a constructor +worker or wrapper. These will never meaningfully enrich the resulting +profile so we improve efficiency by omitting those. + +-} + +-- | Add late cost centres directly to the 'ModGuts'. This is used inside the +-- core pipeline with the -fprof-late-inline flag. It should not be used after +-- tidy, since it does not manually track inserted cost centers. See +-- Note [Collecting late cost centres]. +topLevelBindsCCMG :: ModGuts -> CoreM ModGuts +topLevelBindsCCMG guts = do + dflags <- getDynFlags + let + env = + LateCCEnv + { lateCCEnv_module = mg_module guts + + -- We don't use this for topLevelBindsCC, so Nothing is okay + , lateCCEnv_file = Nothing + + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = False + } + guts' = + guts + { mg_binds = + fst + ( doLateCostCenters + env + (initLateCCState ()) + (topLevelBindsCC (const True)) + (mg_binds guts) + ) + } + return guts' + +-- | Insert cost centres on top-level bindings in the module, depending on +-- whether or not they satisfy the given predicate. +topLevelBindsCC :: (CoreExpr -> Bool) -> CoreBind -> LateCCM s CoreBind +topLevelBindsCC pred core_bind = + case core_bind of + NonRec b rhs -> + NonRec b <$> doBndr b rhs + Rec bs -> + Rec <$> mapM doPair bs + where + doPair :: ((Id, CoreExpr) -> LateCCM s (Id, CoreExpr)) + doPair (b,rhs) = (b,) <$> doBndr b rhs + + doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr + doBndr bndr rhs + -- Cost centres on constructor workers are pretty much useless + -- so we don't emit them if we are looking at the rhs of a constructor + -- binding. + | Just _ <- isDataConId_maybe bndr = pure rhs + | otherwise = if pred rhs then addCC bndr rhs else pure rhs + + -- We want to put the cost centre below the lambda as we only care about + -- executions of the RHS. + addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs + addCC bndr rhs = do + let name = idName bndr + cc_loc = nameSrcSpan name + cc_name = getOccFS name + insertCC cc_name cc_loc rhs \ No newline at end of file ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -0,0 +1,74 @@ +-- | Types related to late cost center insertion +module GHC.Core.LateCC.Types + ( LateCCConfig(..) + , LateCCBindSpec(..) + , LateCCEnv(..) + , LateCCState(..) + , initLateCCState + , LateCCM + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Unit.Types + +-- | Late cost center insertion configuration. +-- +-- Specifies whether cost centers are added to overloaded function call sites +-- and/or top-level bindings, and which top-level bindings they are added to. +-- Also holds the cost center insertion environment. +data LateCCConfig = + LateCCConfig + { lateCCConfig_whichBinds :: !LateCCBindSpec + , lateCCConfig_overloadedCalls :: !Bool + , lateCCConfig_env :: !LateCCEnv + } + +-- | The types of top-level bindings we support adding cost centers to. +data LateCCBindSpec = + LateCCNone + | LateCCAllBinds + | LateCCOverloadedBinds + +-- | Late cost centre insertion environment +data LateCCEnv = LateCCEnv + { lateCCEnv_module :: !Module + -- ^ Current module + , lateCCEnv_file :: Maybe FastString + -- ^ Current file, if we have one + , lateCCEnv_countEntries:: !Bool + -- ^ Whether the inserted cost centers should count entries + , lateCCEnv_collectCCs :: !Bool + -- ^ Whether to collect the cost centres we insert. See + -- Note [Collecting late cost centres] + + } + +-- | Late cost centre insertion state, indexed by some extra state type that an +-- insertion method may require. +data LateCCState s = LateCCState + { lateCCState_ccs :: !(S.Set CostCentre) + -- ^ Cost centres that have been inserted + , lateCCState_ccState :: !CostCentreState + -- ^ Per-module state tracking for cost centre indices + , lateCCState_extra :: !s + } + +-- | The empty late cost centre insertion state +initLateCCState :: s -> LateCCState s +initLateCCState s = + LateCCState + { lateCCState_ccState = newCostCentreState + , lateCCState_ccs = mempty + , lateCCState_extra = s + } + +-- | Late cost centre insertion monad +type LateCCM s = ReaderT LateCCEnv (State (LateCCState s)) ===================================== compiler/GHC/Core/LateCC/Utils.hs ===================================== @@ -0,0 +1,80 @@ +module GHC.Core.LateCC.Utils + ( -- * Inserting cost centres + doLateCostCenters -- Might be useful for API users + + -- ** Helpers for defining insertion methods + , getCCFlavour + , insertCC + ) where + +import GHC.Prelude + +import Control.Monad +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Core +import GHC.Core.LateCC.Types +import GHC.Core.Utils +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Types.SrcLoc +import GHC.Types.Tickish + +-- | Insert cost centres into the 'CoreProgram' using the provided environment, +-- initial state, and insertion method. +doLateCostCenters + :: LateCCEnv + -- ^ Environment to run the insertion in + -> LateCCState s + -- ^ Initial state to run the insertion with + -> (CoreBind -> LateCCM s CoreBind) + -- ^ Insertion method + -> CoreProgram + -- ^ Bindings to consider + -> (CoreProgram, LateCCState s) +doLateCostCenters env state method binds = + runLateCC env state $ mapM method binds + +-- | Evaluate late cost centre insertion +runLateCC :: LateCCEnv -> LateCCState s -> LateCCM s a -> (a, LateCCState s) +runLateCC env state = (`runState` state) . (`runReaderT` env) + +-- | Given the name of a cost centre, get its flavour +getCCFlavour :: FastString -> LateCCM s CCFlavour +getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name + where + getCCIndex' :: FastString -> LateCCM s CostCentreIndex + getCCIndex' name = do + cc_state <- lift $ gets lateCCState_ccState + let (index, cc_state') = getCCIndex name cc_state + lift . modify $ \s -> s { lateCCState_ccState = cc_state'} + return index + +-- | Insert a cost centre with the specified name and source span on the given +-- expression. The inserted cost centre will be appropriately tracked in the +-- late cost centre state. +insertCC + :: FastString + -- ^ Name of the cost centre to insert + -> SrcSpan + -- ^ Source location to associate with the cost centre + -> CoreExpr + -- ^ Expression to wrap in the cost centre + -> LateCCM s CoreExpr +insertCC cc_name cc_loc expr = do + cc_flavour <- getCCFlavour cc_name + env <- ask + let + cc_mod = lateCCEnv_module env + cc = NormalCC cc_flavour cc_name cc_mod cc_loc + note = ProfNote cc (lateCCEnv_countEntries env) True + when (lateCCEnv_collectCCs env) $ do + lift . modify $ \s -> + s { lateCCState_ccs = S.insert cc (lateCCState_ccs s) + } + return $ mkTick note expr + ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) import GHC.Core.Opt.CallerCC ( addCallerCostCentres ) -import GHC.Core.LateCC (addLateCostCentresMG) +import GHC.Core.LateCC.TopLevelBinds (topLevelBindsCCMG) import GHC.Core.Seq (seqBinds) import GHC.Core.FamInstEnv @@ -520,7 +520,7 @@ doCorePass pass guts = do addCallerCostCentres guts CoreAddLateCcs -> {-# SCC "AddLateCcs" #-} - addLateCostCentresMG guts + topLevelBindsCCMG guts CoreDoPrintCore -> {-# SCC "PrintCore" #-} liftIO $ printCore logger (mg_binds guts) >> return guts ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -341,6 +341,8 @@ data GeneralFlag | Opt_ProfCountEntries | Opt_ProfLateInlineCcs | Opt_ProfLateCcs + | Opt_ProfLateOverloadedCcs + | Opt_ProfLateoverloadedCallsCCs | Opt_ProfManualCcs -- ^ Ignore manual SCC annotations -- misc opts ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -175,7 +175,6 @@ import GHC.Iface.Ext.Debug ( diffFile, validateScopes ) import GHC.Core import GHC.Core.Lint.Interactive ( interactiveInScope ) import GHC.Core.Tidy ( tidyExpr ) -import GHC.Core.Type ( Type, Kind ) import GHC.Core.Utils ( exprType ) import GHC.Core.ConLike import GHC.Core.Opt.Pipeline @@ -185,7 +184,8 @@ import GHC.Core.InstEnv import GHC.Core.FamInstEnv import GHC.Core.Rules import GHC.Core.Stats -import GHC.Core.LateCC (addLateCostCentresPgm) +import GHC.Core.LateCC +import GHC.Core.LateCC.Types import GHC.CoreToStg.Prep @@ -197,6 +197,7 @@ import GHC.Parser.Lexer as Lexer import GHC.Tc.Module import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.TcType import GHC.Tc.Zonk.Env ( ZonkFlexi (DefaultFlexi) ) import GHC.Stg.Syntax @@ -297,7 +298,6 @@ import GHC.StgToCmm.Utils (IPEStats) import GHC.Types.Unique.FM import GHC.Types.Unique.DFM import GHC.Cmm.Config (CmmConfig) -import GHC.Types.CostCentre.State (newCostCentreState) {- ********************************************************************** @@ -1791,22 +1791,41 @@ hscGenHardCode hsc_env cgguts location output_filename = do ------------------- - -- Insert late cost centres if enabled. - -- If `-fprof-late-inline` is enabled we can skip this, as it will have added - -- a superset of cost centres we would add here already. - - (late_cc_binds, late_local_ccs, cc_state) <- - if gopt Opt_ProfLateCcs dflags && not (gopt Opt_ProfLateInlineCcs dflags) - then - withTiming - logger - (text "LateCCs"<+>brackets (ppr this_mod)) - (const ()) - $ {-# SCC lateCC #-} do - (binds, late_ccs, cc_state) <- addLateCostCentresPgm dflags logger this_mod core_binds - return ( binds, (S.toList late_ccs `mappend` local_ccs ), cc_state) + -- Insert late cost centres based on the provided flags. + -- + -- If -fprof-late-inline is enabled, we will skip adding CCs on any + -- top-level bindings here (via shortcut in `addLateCostCenters`), + -- since it will have already added a superset of the CCs we would add + -- here. + let + late_cc_config :: LateCCConfig + late_cc_config = + LateCCConfig + { lateCCConfig_whichBinds = + if gopt Opt_ProfLateInlineCcs dflags then + LateCCNone + else if gopt Opt_ProfLateCcs dflags then + LateCCAllBinds + else if gopt Opt_ProfLateOverloadedCcs dflags then + LateCCOverloadedBinds else - return (core_binds, local_ccs, newCostCentreState) + LateCCNone + , lateCCConfig_overloadedCalls = + gopt Opt_ProfLateoverloadedCallsCCs dflags + , lateCCConfig_env = + LateCCEnv + { lateCCEnv_module = this_mod + , lateCCEnv_file = fsLit <$> ml_hs_file location + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = True + } + } + + (late_cc_binds, late_cc_state) <- + addLateCostCenters logger late_cc_config core_binds + + when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ + putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr late_cc_binds)) ------------------- -- Run late plugins @@ -1820,7 +1839,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do cg_hpc_info = hpc_info, cg_spt_entries = spt_entries, cg_binds = late_binds, - cg_ccs = late_local_ccs' + cg_ccs = late_local_ccs } , _ ) <- @@ -1833,9 +1852,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do (($ hsc_env) . latePlugin) ( cgguts { cg_binds = late_cc_binds - , cg_ccs = late_local_ccs + , cg_ccs = S.toList (lateCCState_ccs late_cc_state) ++ local_ccs } - , cc_state + , lateCCState_ccState late_cc_state ) let @@ -1876,7 +1895,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do let (stg_binds,_stg_deps) = unzip stg_binds_with_deps let cost_centre_info = - (late_local_ccs' ++ caf_ccs, caf_cc_stacks) + (late_local_ccs ++ caf_ccs, caf_cc_stacks) platform = targetPlatform dflags prof_init | sccProfilingEnabled dflags = profilingInitCode platform this_mod cost_centre_info ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2444,6 +2444,8 @@ fFlagsDeps = [ flagSpec "prof-cafs" Opt_AutoSccsOnIndividualCafs, flagSpec "prof-count-entries" Opt_ProfCountEntries, flagSpec "prof-late" Opt_ProfLateCcs, + flagSpec "prof-late-overloaded" Opt_ProfLateOverloadedCcs, + flagSpec "prof-late-overloaded-calls" Opt_ProfLateoverloadedCallsCCs, flagSpec "prof-manual" Opt_ProfManualCcs, flagSpec "prof-late-inline" Opt_ProfLateInlineCcs, flagSpec "regs-graph" Opt_RegsGraph, @@ -3763,6 +3765,10 @@ needSourceNotes :: DynFlags -> Bool needSourceNotes dflags = debugLevel dflags > 0 || gopt Opt_InfoTableMap dflags + -- Source ticks are used to approximate the location of + -- overloaded call cost centers + || gopt Opt_ProfLateoverloadedCallsCCs dflags + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1907,7 +1907,7 @@ isRhoExpTy (Infer {}) = True isOverloadedTy :: Type -> Bool -- Yes for a type of a function that might require evidence-passing --- Used only by bindLocalMethods +-- Used by bindLocalMethods and for -fprof-late-overloaded isOverloadedTy ty | Just ty' <- coreView ty = isOverloadedTy ty' isOverloadedTy (ForAllTy _ ty) = isOverloadedTy ty isOverloadedTy (FunTy { ft_af = af }) = isInvisibleFunArg af ===================================== compiler/ghc.cabal.in ===================================== @@ -336,6 +336,10 @@ Library GHC.Core.Lint GHC.Core.Lint.Interactive GHC.Core.LateCC + GHC.Core.LateCC.Types + GHC.Core.LateCC.TopLevelBinds + GHC.Core.LateCC.Utils + GHC.Core.LateCC.OverloadedCalls GHC.Core.Make GHC.Core.Map.Expr GHC.Core.Map.Type ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -186,6 +186,15 @@ Compiler This means that if you are using ``-fllvm`` you now need ``llc``, ``opt`` and ``clang`` available. +- The :ghc-flag:`-fprof-late-overloaded` flag has been introduced. It causes + cost centres to be added to *overloaded* top level bindings, unlike + :ghc-flag:`-fprof-late` which adds cost centres to all top level bindings. + +- The :ghc-flag:`-fprof-late-overloaded-calls` flag has been introduced. It + causes cost centres to be inserted at call sites including instance dictionary + arguments. This may be preferred over :ghc-flag:`-fprof-late-overloaded` since + it may reveal whether imported functions are called overloaded. + JavaScript backend ~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -518,6 +518,49 @@ of your profiled program will be different to that of the unprofiled one. You can try this mode if :ghc-flag:`-fprof-late` results in a profile that's too hard to interpret. +.. ghc-flag:: -fprof-late-overloaded + :shortdesc: Auto-add ``SCC``\\ s to all top level overloaded bindings *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all *overloaded* top level bindings + late in the compilation pipeline after the optimizer has run and unfoldings + have been created. This means these cost centres will not interfere with + core-level optimizations and the resulting profile will be closer to the + performance profile of an optimized non-profiled executable. + + This flag can help determine which top level bindings encountered during a + program's execution are still overloaded after inlining and specialization. + +.. ghc-flag:: -fprof-late-overloaded-calls + :shortdesc: Auto-add ``SCC``\\ s to all call sites that include dictionary arguments *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded-calls + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all call sites that include + dictionary arguments late in the compilation pipeline after the optimizer + has run and unfoldings have been created. This means these cost centres will + not interfere with core-level optimizations and the resulting profile will + be closer to the performance profile of an optimized non-profiled + executable. + + This flag is potentially more useful than :ghc-flag:`-fprof-late-overloaded` + since it will also add ``SCC`` annotations to call sites of imported + overloaded functions. + + Some overloaded calls may not be annotated, specifically in cases where the + optimizer turns an overloaded function into a join point. Calls to such + functions will not be wrapped in ``SCC`` annotations, since it would make + them non-tail calls, which is a requirement for join points. Instead, + ``SCC`` annotations are added around the body of overloaded join variables + and given distinct names (``join-rhs-``) to avoid confusion. + .. ghc-flag:: -fprof-cafs :shortdesc: Auto-add ``SCC``\\ s to all CAFs :type: dynamic ===================================== testsuite/tests/profiling/should_run/all.T ===================================== @@ -195,3 +195,30 @@ test('ignore_scc', [], compile_and_run, ['-fno-prof-manual']) test('T21446', [], makefile_test, ['T21446']) + + +test('scc-prof-overloaded001', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded002', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls001', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fno-full-laziness -fprof-late-overloaded-calls'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls002', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fprof-late-overloaded-calls'] +) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample ===================================== @@ -0,0 +1,26 @@ + Thu Jan 4 11:49 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,320 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded-calls001.hs:24:1-31 256 1 0.0 0.3 0.0 0.8 + f Main scc-prof-overloaded-calls001.hs:18:1-18 257 1 0.0 0.6 0.0 0.6 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample ===================================== @@ -0,0 +1,31 @@ + Fri Jan 5 11:06 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls002 +RTS -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 59,152 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 34.8 +CAF GHC.IO.Handle.FD 0.0 58.7 +CAF GHC.IO.Encoding 0.0 4.1 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 34.8 0.0 100.0 + CAF Main 255 0 0.0 0.6 0.0 0.9 + f Main scc-prof-overloaded-calls002.hs:52:1-25 262 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:48:1-25 261 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:44:1-25 260 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:40:1-25 259 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:36:1-25 258 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:32:1-25 257 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:28:1-25 256 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.1 0.0 4.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.3 0.0 0.3 + CAF GHC.IO.Handle.FD 208 0 0.0 58.7 0.0 58.7 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample ===================================== @@ -0,0 +1,25 @@ + Thu Jan 4 11:26 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,304 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded001.hs:18:1-6 256 1 0.0 0.8 0.0 0.8 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample ===================================== @@ -0,0 +1,23 @@ + Thu Jan 4 11:55 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded002 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 56,472 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 32.7 +CAF GHC.IO.Handle.FD 0.0 61.5 +CAF GHC.IO.Encoding 0.0 4.3 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 32.7 0.0 100.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.3 0.0 4.3 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 61.5 0.0 61.5 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61bb5ff68630c203eaae4baba554640246df5a63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61bb5ff68630c203eaae4baba554640246df5a63 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 17:51:54 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 04 Mar 2024 12:51:54 -0500 Subject: [Git][ghc/ghc][wip/T24466] Don't push non-thunks into all branches Message-ID: <65e60a3a3bad9_a5db0c0631d010377a@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24466 at Glasgow Haskell Compiler / GHC Commits: fe53f132 by Simon Peyton Jones at 2024-03-04T17:51:23+00:00 Don't push non-thunks into all branches - - - - - 1 changed file: - compiler/GHC/Core/Opt/FloatIn.hs Changes: ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -792,7 +792,7 @@ sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | otherwise = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where --- n_alts = length fork_fvs + n_alts = length fork_fvs go :: RevFloatInBinds -> DropBox -> [DropBox] -> (RevFloatInBinds, [RevFloatInBinds]) @@ -819,6 +819,11 @@ sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs n_used_alts = count id used_in_flags -- returns number of Trues in list. + not_thunky = case bind of + FloatCase{} -> True + FloatLet (NonRec _ r) -> exprIsHNF r + FloatLet (Rec prs) -> all (exprIsHNF . snd) prs + cant_push | is_case = -- The alternatives of a case expresison @@ -831,8 +836,8 @@ sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs -- See Note [Duplicating floats into case alternatives] dont_float_into_alts - = -- (n_used_alts == n_alts) || - -- Don't float in if used in all alternatives + = (n_used_alts == n_alts && not_thunky) || + -- Don't float in if used in all alternatives and not a thunk (n_used_alts > 1 && not (floatIsDupable platform bind)) -- Nor if used in multiple alts and not small View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fe53f1321c6d200c49dae5bc2d20bf2cc1c73841 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fe53f1321c6d200c49dae5bc2d20bf2cc1c73841 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 19:19:21 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 04 Mar 2024 14:19:21 -0500 Subject: [Git][ghc/ghc][wip/t24277] 276 commits: Late plugins Message-ID: <65e61eb983075_a5db0e7cdeb4123823@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 91bc61af by Finley McIlwaine at 2024-03-04T11:17:24-08:00 base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Stack` and `GHC.Exts`. Also add an opaque exposed type for cost center ids, `CostCentreId`, with appropriate instances. Implements CLC proposal 235 - - - - - 16 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitmodules - CODEOWNERS - 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/e8d17957031278affc5a155970ba8f8bf5281891...91bc61afdb39965b83f707cc1bed536f853f4a06 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8d17957031278affc5a155970ba8f8bf5281891...91bc61afdb39965b83f707cc1bed536f853f4a06 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 19:19:49 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 04 Mar 2024 14:19:49 -0500 Subject: [Git][ghc/ghc][wip/t24277] base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <65e61ed5bdb52_a5db0e92ab7c124125@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: f8217742 by Finley McIlwaine at 2024-03-04T11:19:20-08:00 base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Stack` and `GHC.Exts`. Also add an opaque exposed type for cost center ids, `CostCentreId`, with appropriate instances. Implements CLC proposal 235. Resolves #24277 - - - - - 9 changed files: - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -84,6 +84,7 @@ module GHC.Exts traceEvent, -- ** The call stack currentCallStack, + currentCallStackIds, -- * Ids with special behaviour inline, noinline, ===================================== libraries/base/src/GHC/Stack.hs ===================================== @@ -18,6 +18,7 @@ module GHC.Stack (errorWithStackTrace, -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks CallStack, @@ -37,16 +38,19 @@ module GHC.Stack -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where -import GHC.Internal.Stack \ No newline at end of file +import GHC.Internal.Stack ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -24,6 +25,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +40,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO Word32 +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Internal.Stack.CCS.CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9303,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9312,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11557,6 +11563,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11639,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12022,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12134,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12208,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12255,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12432,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12633,6 +12646,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12811,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -5727,6 +5727,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -12351,14 +12352,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -12380,14 +12384,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -5907,6 +5907,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9533,14 +9534,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9562,14 +9566,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9309,14 +9310,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9338,14 +9342,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f82177424b1cae2da4d5acd797ad15f83fab5145 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f82177424b1cae2da4d5acd797ad15f83fab5145 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 20:58:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 04 Mar 2024 15:58:36 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: compiler: start deprecating cmmToRawCmmHook Message-ID: <65e635fc9b592_a5db0114905dc130544@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 31be53b2 by Andreas Klebinger at 2024-03-04T15:58:32-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - libraries/base/changelog.md - libraries/base/src/Data/List/NonEmpty.hs - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df8631287d4fa20ca2f19619c289c630e3e1c040...31be53b2c08f1fe1d53917aeb227a3b8c49bbcf4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df8631287d4fa20ca2f19619c289c630e3e1c040...31be53b2c08f1fe1d53917aeb227a3b8c49bbcf4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 20:59:42 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 04 Mar 2024 15:59:42 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 229 commits: ci: bump ci-images for updated wasm image Message-ID: <65e6363e1e863_a5db0115e802413555d@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - d60b478e by Matthew Pickering at 2024-03-04T13:29:51+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage2 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage2 package database. * Stage 2 cross compilers need to use stage3 libraries, so likewise, we should set to stage * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. - - - - - 09460671 by Matthew Pickering at 2024-03-04T13:29:52+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 7adcb7f8 by Matthew Pickering at 2024-03-04T13:29:52+00:00 Add missing req_interp modifier to T18441fail3 and T18441fail19 These tests require the interpreter but they were failing in a different way with the javascript backend because the interpreter was disabled and stderr is ignored by the test. - - - - - 2158f919 by Matthew Pickering at 2024-03-04T13:29:52+00:00 Use explicit syntax rather than pure - - - - - 63e1ac91 by Matthew Pickering at 2024-03-04T13:29:52+00:00 ci: Fail when bindist configure fails when installing bindist It is better to fail earlier if the configure step fails rather than carrying on for a more obscure error message. - - - - - dfb541e9 by Matthew Pickering at 2024-03-04T13:29:52+00:00 packaging: correctly propagate build/host/target to bindist configure script At the moment the host and target which we will produce a compiler for is fixed at the initial configure time. Therefore we need to persist the choice made at this time into the installation bindist as well so we look for the right tools, with the right prefixes at install time. In the future, we want to provide a bit more control about what kind of bindist we produce so the logic about what the host/target will have to be written by hadrian rather than persisted by the configure script. In particular with cross compilers we want to either build a normal stage 2 cross bindist or a stage 3 bindist, which creates a bindist which has a native compiler for the target platform. Fixes #21970 - - - - - 955f4b56 by Matthew Pickering at 2024-03-04T13:29:52+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - e3d8d1ca by Matthew Pickering at 2024-03-04T13:32:38+00:00 hadrian: Disable docs when cross compiling Before there were a variety of ad-hoc places where doc building was disabled when cross compiling. * Some CI jobs sets --docs=none in gen_ci.hs * Some CI jobs set --docs=none in .gitlab/ci.sh * There was some logic in hadrian to not need the ["docs"] target when making a bindist. Now the situation is simple: * If you are cross compiling then defaultDocsTargets is empty by default. In theory, there is no reason why we can't build documentation for cross compiler bindists, but this is left to future work to generalise the documentation building rules to allow this (#24289) - - - - - f4244482 by Matthew Pickering at 2024-03-04T20:59:26+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 30dbe813 by Matthew Pickering at 2024-03-04T20:59:26+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - e61efae1 by Matthew Pickering at 2024-03-04T20:59:26+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 78f3bbdc by Matthew Pickering at 2024-03-04T20:59:26+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - 16 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitmodules - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/db2e4a5093908219578157fde598ac6a6beff746...78f3bbdc0b305fc29aff6dc6ee77359f50603ae5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/db2e4a5093908219578157fde598ac6a6beff746...78f3bbdc0b305fc29aff6dc6ee77359f50603ae5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 21:48:06 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Mon, 04 Mar 2024 16:48:06 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Linker: Optimize lookup of dependent relocation Message-ID: <65e64196db9d9_a5db01280eb901364f0@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 9b73cf29 by Sven Tennie at 2024-03-04T22:45:17+01:00 Linker: Optimize lookup of dependent relocation Always iteration over everything was a real performance issue. Now, start with the second relocation and go back to the first one. Expect it in the same section. - - - - - 1 changed file: - rts/linker/elf_reloc_riscv64.c Changes: ===================================== rts/linker/elf_reloc_riscv64.c ===================================== @@ -356,8 +356,9 @@ bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int32_t addend) { * @param addend The existing addend. Either explicit or implicit. * @return The new computed addend. */ -int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, +int32_t computeAddend(ElfRelocationATable * relaTab, unsigned relNo, Elf_Rel *rel, ElfSymbol *symbol, int64_t addend, ObjectCode *oc) { + Section * section = &oc->sections[relaTab->targetSectionIndex]; /* Position where something is relocated */ addr_t P = (addr_t)((uint8_t *)section->start + rel->r_offset); @@ -372,9 +373,9 @@ int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, int64_t A = addend; - IF_DEBUG(linker, debugBelch("%s: P 0x%lx S 0x%lx %s GOT_S 0x%lx A 0x%lx\n", + IF_DEBUG(linker, debugBelch("%s: P 0x%lx S 0x%lx %s GOT_S 0x%lx A 0x%lx relNo %u\n", relocationTypeToString(rel->r_info), P, S, - symbol->name, GOT_S, A)); + symbol->name, GOT_S, A, relNo)); switch (ELF64_R_TYPE(rel->r_info)) { case R_RISCV_32: return S + A; @@ -400,20 +401,11 @@ int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, // relocations aren't pure, but this is how LLVM does it. And, calculating // the lower 12 bit without any relation ship to the GOT entry's address // makes no sense either. - for (ElfRelocationATable *relaTab = oc->info->relaTable; relaTab != NULL; - relaTab = relaTab->next) { - /* only relocate interesting sections */ - if (SECTIONKIND_OTHER == oc->sections[relaTab->targetSectionIndex].kind) - continue; - - Section *targetSection = &oc->sections[relaTab->targetSectionIndex]; - - for (unsigned i = 0; i < relaTab->n_relocations; i++) { - + for (unsigned i = relNo; i >= 0 ; i--) { Elf_Rela *rel_prime = &relaTab->relocations[i]; addr_t P_prime = - (addr_t)((uint8_t *)targetSection->start + rel_prime->r_offset); + (addr_t)((uint8_t *)section->start + rel_prime->r_offset); if (P_prime != S) { // S points to the P of the corresponding *_HI20 relocation. @@ -438,17 +430,16 @@ int32_t computeAddend(Section *section, Elf_Rel *rel, ElfSymbol *symbol, IF_DEBUG(linker, debugBelch( "Found matching relocation: %s (P: 0x%lx, S: 0x%lx, " - "sym-name: %s) -> %s (P: 0x%lx, S: 0x%lx, sym-name: %s)", + "sym-name: %s) -> %s (P: 0x%lx, S: 0x%lx, sym-name: %s, relNo: %u)", relocationTypeToString(rel->r_info), P, S, symbol->name, relocationTypeToString(rel_prime->r_info), P_prime, - symbol_prime->addr, symbol_prime->name)); - int32_t result = computeAddend(targetSection, (Elf_Rel *)rel_prime, + symbol_prime->addr, symbol_prime->name, i)); + int32_t result = computeAddend(relaTab, i, (Elf_Rel *)rel_prime, symbol_prime, addend_prime, oc); IF_DEBUG(linker, debugBelch("Result of computeAddend: 0x%x (%d)\n", result, result)); return result; } - } } debugBelch("Missing HI relocation for %s: P 0x%lx S 0x%lx %s\n", relocationTypeToString(rel->r_info), P, S, symbol->name); @@ -566,7 +557,7 @@ bool relocateObjectCodeRISCV64(ObjectCode *oc) { /* decode implicit addend */ int64_t addend = decodeAddendRISCV64(targetSection, rel); - addend = computeAddend(targetSection, rel, symbol, addend, oc); + addend = computeAddend((ElfRelocationATable*) relTab, i, rel, symbol, addend, oc); encodeAddendRISCV64(targetSection, rel, addend); } } @@ -590,7 +581,7 @@ bool relocateObjectCodeRISCV64(ObjectCode *oc) { /* take explicit addend */ int64_t addend = rel->r_addend; - addend = computeAddend(targetSection, (Elf_Rel *)rel, symbol, addend, oc); + addend = computeAddend(relaTab, i, (Elf_Rel *)rel, symbol, addend, oc); encodeAddendRISCV64(targetSection, (Elf_Rel *)rel, addend); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b73cf299516bd383b1f14baf073df100d1369dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b73cf299516bd383b1f14baf073df100d1369dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 22:31:32 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 04 Mar 2024 17:31:32 -0500 Subject: [Git][ghc/ghc][wip/submodule-bumps] 1699 commits: Propagate failure if unable to push notes Message-ID: <65e64bc449b88_4bf9063c1f86043@gitlab.mail> Ben Gamari pushed to branch wip/submodule-bumps at Glasgow Haskell Compiler / GHC Commits: fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00 Propagate failure if unable to push notes - - - - - 8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00 rts: Fix `prompt#` when profiling is enabled This commit also adds a new -Dk RTS option to the debug RTS to assist debugging continuation captures. Currently, the printed information is quite minimal, but more can be added in the future if it proves to be useful when debugging future issues. fixes #23001 - - - - - e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00 Explicit migration timeline for loopy SC solving This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912 - - - - - 4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00 JS: make some arithmetic primops faster (#22835) Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump terminfo submodule to 0.4.1.6 - - - - - f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump unix submodule to 2.8.1.0 - - - - - 47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump deepseq submodule to 1.4.8.1 - - - - - d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump directory submodule to 1.3.8.1 - - - - - df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump process submodule to v1.6.17.0 - - - - - 4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump hsc2hs submodule to 0.68.8 - - - - - 81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump array submodule to 0.5.4.0 - - - - - 6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump Cabal submodule to 3.9 pre-release - - - - - 4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump filepath submodule to 1.4.100.1 - - - - - 2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump haskeline submodule to 0.8.2.1 - - - - - fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00 gitlab-ci: Run nix-build with -v0 This significantly cuts down on the amount of noise in the job log. Addresses #22861. - - - - - 69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00 Fix ParallelListComp out of scope suggestion This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940 - - - - - ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00 Fix shadowing bug in prepareAlts As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts]. - - - - - 7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00 JS: Store CI perf results (fix #22923) - - - - - b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00 Don't specialise incoherent instance applications Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304 - - - - - d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00 Fix SCC grouping example - - - - - f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00 Mark setnumcapabilities001 fragile - - - - - 29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00 Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail See #22520 - - - - - 9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00 ghc-prim: fix hs_cmpxchg64 function prototype hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised builds, which go unnoticed at compile-time due to C implicit casting in .hc files. - - - - - 0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00 Account for local rules in specImports As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules - - - - - 8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00 JS: fix for overlap with copyMutableByteArray# (#23033) The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case. - - - - - 239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00 Testsuite: replace some js_skip with req_cmm req_cmm is more informative than js_skip - - - - - 7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00 Take more care with unlifted bindings in the specialiser As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise - - - - - bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00 Account for TYPE vs CONSTRAINT in mkSelCo As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion. - - - - - 79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00 hadrian: Add dependency from lib/settings to mk/config.mk In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253 by adding logic to the bindist Makefile to regenerate the `settings` file from information gleaned by the bindist `configure` script. However, this fix had no effect as `lib/settings` is shipped in the binary distribution (to allow in-place use of the binary distribution). As `lib/settings` already existed and its rule declared no dependencies, `make` would fail to use the added rule to regenerate it. Fix this by explicitly declaring a dependency from `lib/settings` on `mk/config.mk`. Fixes #22982. - - - - - a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00 Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)" This reverts the bits affecting fusion of `drop` and `dropWhile` of commit 0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`. It also adds a new test for #23021 (which was the reason for reverting) as well as adds a clarifying comment to T18964. Fixes #23021, unfixes #18964. Metric Increase: T18964 Metric Decrease: T18964 - - - - - cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00 Refine the test for naughty record selectors The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038. - - - - - 86f240ca by romes at 2023-03-01T04:19:10-05:00 fix: Consider strictness annotation in rep_bind Fixes #23036 - - - - - 1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00 Don't suppress *all* Wanteds Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707 - - - - - 8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00 Check for platform support for JavaScript foreign imports GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774 - - - - - db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Statically assert alignment of Capability In #22965 we noticed that changes in the size of `Capability` can result in unsound behavior due to the `align` pragma claiming an alignment which we don't in practice observe. Avoid this by statically asserting that the size is a multiple of the alignment. - - - - - 5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Introduce stgMallocAlignedBytes - - - - - 8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Correctly align Capability allocations Previously we failed to tell the C allocator that `Capability`s needed to be aligned, resulting in #22965. Fixes #22965. Fixes #22975. - - - - - 5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Drop no-alignment special case for Windows For reasons that aren't clear, we were previously not giving Capability the same favorable alignment on Windows that we provided on other platforms. Fix this. - - - - - a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00 constant folding: Correct type of decodeDouble_Int64 rule The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019 - - - - - 68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00 ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002 - - - - - 2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00 Get the right in-scope set in etaBodyForJoinPoint Fixes #23026 - - - - - 45af8482 by David Feuer at 2023-03-03T11:40:47-05:00 Export getSolo from Data.Tuple Proposed in [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113) and [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191) - - - - - 0c694895 by David Feuer at 2023-03-03T11:40:47-05:00 Document getSolo - - - - - bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00 More fixes for `type data` declarations This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00 Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT These all type-level equality decision procedures. Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98 - - - - - bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00 Add test for T22793 - - - - - c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00 Fix typo in docs referring to threadLabel - - - - - 232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00 Add regression test for #22328 - - - - - 5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Enable response files for linker if supported - - - - - 1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Synchronize `configure.ac` and `distrib/configure.ac.in` - - - - - 70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix `hadrian/bindist/config.mk.in` … as suggested by @bgamari - - - - - b042b125 by sheaf at 2023-03-06T17:06:50-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Try to create somewhat portable `ld` command I cannot figure out a good way to generate an `ld` command that works on both Linux and macOS. Normally you'd use something like `AC_LINK_IFELSE` for this purpose (I think), but that won't let us test response file support. - - - - - 83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Quote variables … as suggested by @bgamari - - - - - 845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix configure failure on alpine linux - - - - - c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Small fixes to configure script - - - - - cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00 Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason - - - - - c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00 Constraint simplification loop now depends on `ExpansionFuel` instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel] - - - - - a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00 Documentation: describe laziness of several function from Data.List - - - - - fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00 Add `Data.Functor.unzip` This function is currently present in `Data.List.NonEmpty`, but `Data.Functor` is a better home for it. This change was discussed and approved by the CLC at https://github.com/haskell/core-libraries-committee/issues/88. - - - - - 2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00 Fix documentation for traceWith and friends - - - - - f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00 Remove utils/hpc subdirectory and its contents - - - - - cf98e286 by David Binder at 2023-03-08T01:24:17-05:00 Add git submodule for utils/hpc - - - - - 605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 606793d4 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00 linker: fix linking with aligned sections (#23066) Take section alignment into account instead of assuming 16 bytes (which is wrong when the section requires 32 bytes, cf #23066). - - - - - 1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00 Change hostSupportsRPaths to report False on OpenBSD OpenBSD does support -rpath but ghc build process relies on some related features that don't work there. See ghc/ghc#23011 - - - - - bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00 bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args fixes #23068 - - - - - 321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Drop redundant prototype - - - - - abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix style - - - - - be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Deduplicate assertion - - - - - b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Use release ordering when storing thread labels Since this makes the ByteArray# visible from other cores. - - - - - 5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - 6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00 Evac: Squash data race in eval_selector_chain - - - - - 7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify comment - - - - - bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Fixes #22931. - - - - - 92227b60 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - 99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - 58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Assert state of swept segments - - - - - 2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive We must conservatively assume that new closures are reachable since we are not guaranteed to mark such blocks. - - - - - e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. Fixes #22927. - - - - - 1b069671 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. See the inline comments for details. Fixes #22930. - - - - - d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Post-sweep sanity checking - - - - - 0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Avoid n_caps race - - - - - 5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. - - - - - 7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Sync-phase mark budgeting Here we significantly improve the bound on sync phase pause times by imposing a limit on the amount of work that we can perform during the sync. If we find that we have exceeded our marking budget then we allow the mutators to resume, return to concurrent marking, and try synchronizing again later. Fixes #22929. - - - - - ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Reenable assertion - - - - - b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move current segment array into Capability The current segments are conceptually owned by the mutator, not the collector. Consequently, it was quite tricky to prove that the mutator would not race with the collect due to this shared state. It turns out that such races are possible: when resizing the current segment array we may concurrently try to take a heap census. This will attempt to walk the current segment array, causing a data race. Fix this by moving the current segment array into `Capability`, where it belongs. Fixes #22926. - - - - - 56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix Note references Some references to Note [Deadlock detection under the non-moving collector] were missing an article. - - - - - 4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts/Sanity: Fix block count assertion with non-moving collector The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two. - - - - - 96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't call prepareUnloadCheck When the nonmoving GC is in use we do not call `checkUnload` (since we don't unload code) and therefore should not call `prepareUnloadCheck`, lest we run into assertions. - - - - - 6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Encapsulate block allocator spinlock This makes it a bit easier to add instrumentation on this spinlock while debugging. - - - - - e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip some tests when sanity checking is enabled - - - - - 3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix unregisterised build - - - - - 4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Ensure that sanity checker accounts for saved_filled segments - - - - - f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00 hadrian: Add +boot_nonmoving_gc flavour transformer For using GHC bootstrapping to validate the non-moving GC. - - - - - 581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00 gitlab-ci: Add job bootstrapping with nonmoving GC - - - - - 487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move allocator into new source file - - - - - 8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Split out nonmovingAllocateGC - - - - - 662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Only run T22795* in the normal way It doesn't make sense to run these in multiple ways as they merely test whether `-threaded`/`-single-threaded` flags. - - - - - 0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Rename clear_segment(_free_blocks)? To reflect the fact that these are to do with the nonmoving collector, now since they are exposed no longer static. - - - - - 7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Fix incorrect STATIC_INLINE This should be INLINE_HEADER lest we get unused declaration warnings. - - - - - f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Mark ffi023 as broken due to #23089 - - - - - a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip T7160 in the nonmoving way Finalization order is different under the nonmoving collector. - - - - - f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Capture GC configuration in a struct The number of distinct arguments passed to GarbageCollect was getting a bit out of hand. - - - - - ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Non-concurrent collection - - - - - 7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00 hadrian: Fix flavour compiler stage options off-by-one error !9193 pointed out that ghcDebugAssertions was supposed to be a predicate on the stage of the built compiler, but in practice it was a predicate on the stage of the compiler used to build. Unfortunately, while it fixed that issue for ghcDebugAssertions, it documented every other similar option as behaving the same way when in fact they all used the old behavior. The new behavior of ghcDebugAssertions seems more intuitive, so this commit changes the interpretation of every other option to match. It also improves the enableProfiledGhc and debugGhc flavour transformers by making them more selective about which stages in which they build additional library/RTS ways. - - - - - f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00 Delete created temporary subdirectories at end of session. This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952 - - - - - 9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00 Fixes #19627. Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes - - - - - ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00 DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997) We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997. - - - - - 5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00 JS: remove dead code for old integer-gmp - - - - - bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00 JS: Fix implementation of MK_JSVAL - - - - - ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00 Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf. - - - - - 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: ...lots of lines omitted... Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - c2803b76 by Ben Gamari at 2024-03-04T22:29:56+00:00 filepath: Bump submodule to 1.5.2.0 - - - - - 6799904f by Ben Gamari at 2024-03-04T22:30:51+00:00 os-string: Bump submodule to 2.0.2 - - - - - 20 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - − .gitlab/gen-ci.cabal - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - .gitlab/hie.yaml → .gitlab/generate-ci/hie.yaml - − .gitlab/generate_job_metadata - − .gitlab/generate_jobs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/081dd4d535f0bbb73171ad2eb345fcaea21279d6...6799904fb12272f2cd9a047f4c821ae0bc931ce7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/081dd4d535f0bbb73171ad2eb345fcaea21279d6...6799904fb12272f2cd9a047f4c821ae0bc931ce7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 22:53:25 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 04 Mar 2024 17:53:25 -0500 Subject: [Git][ghc/ghc][wip/exception-context] 21 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e650e514ac3_4bf90e25680160f3@gitlab.mail> Ben Gamari pushed to branch wip/exception-context at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1d50acb0 by Ben Gamari at 2024-03-02T15:57:31-05:00 Bump array submodule - - - - - 47f147a8 by Ben Gamari at 2024-03-02T15:57:31-05:00 Bump stm submodule - - - - - ea099b75 by Ben Gamari at 2024-03-04T17:46:09-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 1e6c267d by Ben Gamari at 2024-03-04T17:53:11-05:00 testsuite/interface-stability: Update documentation - - - - - 368e1d7c by Ben Gamari at 2024-03-04T17:53:11-05:00 ghc-internal: comment formatting - - - - - 8c4f7b40 by Ben Gamari at 2024-03-04T17:53:11-05:00 compiler: Default and warn ExceptionContext constraints - - - - - bc9163db by Ben Gamari at 2024-03-04T17:53:11-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated mechinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 9573d836 by Ben Gamari at 2024-03-04T17:53:11-05:00 users guide: Release notes for exception backtrace work - - - - - 167ee1f8 by Ben Gamari at 2024-03-04T17:53:11-05:00 ghc-experimental: Add dummy dependencies to work around #24436 This is a temporary measure to improve CI reliability until a proper solution is developed. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Type.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/Runtime/Eval.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/StgToJS/Utils.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Bind.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/168cb5028e8b15b32889aee2680421b4330584fc...167ee1f8282bd4e5863cc8a8732f7c32a98d4386 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/168cb5028e8b15b32889aee2680421b4330584fc...167ee1f8282bd4e5863cc8a8732f7c32a98d4386 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 22:55:42 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 04 Mar 2024 17:55:42 -0500 Subject: [Git][ghc/ghc][wip/exception-context] 7 commits: Introduce exception context Message-ID: <65e6516e15d68_4bf90113e9e818236@gitlab.mail> Ben Gamari pushed to branch wip/exception-context at Glasgow Haskell Compiler / GHC Commits: 9440575f by Ben Gamari at 2024-03-04T17:55:25-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 54084c37 by Ben Gamari at 2024-03-04T17:55:27-05:00 testsuite/interface-stability: Update documentation - - - - - 4c52e827 by Ben Gamari at 2024-03-04T17:55:27-05:00 ghc-internal: comment formatting - - - - - 404a69cc by Ben Gamari at 2024-03-04T17:55:27-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 1843a15d by Ben Gamari at 2024-03-04T17:55:32-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 5c5c2dbf by Ben Gamari at 2024-03-04T17:55:36-05:00 users guide: Release notes for exception backtrace work - - - - - 953f0e50 by Ben Gamari at 2024-03-04T17:55:36-05:00 ghc-experimental: Add dummy dependencies to work around #24436 This is a temporary measure to improve CI reliability until a proper solution is developed. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr - libraries/base/tests/IO/openFile002.stderr - libraries/base/tests/IO/openFile002.stderr-mingw32 - libraries/base/tests/IO/withBinaryFile001.stderr - libraries/base/tests/IO/withBinaryFile002.stderr - libraries/base/tests/IO/withFile001.stderr - libraries/base/tests/IO/withFile002.stderr - libraries/base/tests/IO/withFileBlocking001.stderr - libraries/base/tests/IO/withFileBlocking002.stderr - libraries/base/tests/T15349.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/167ee1f8282bd4e5863cc8a8732f7c32a98d4386...953f0e509f9c7a96adce285bb70c45c8357a51d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/167ee1f8282bd4e5863cc8a8732f7c32a98d4386...953f0e509f9c7a96adce285bb70c45c8357a51d0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 4 23:40:07 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 04 Mar 2024 18:40:07 -0500 Subject: [Git][ghc/ghc][wip/t24277] base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <65e65bd79145_4bf90242a8a4210dd@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: 082a054c by Finley McIlwaine at 2024-03-04T15:34:32-08:00 base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Stack` and `GHC.Exts`. Also add an opaque exposed type for cost center ids, `CostCentreId`, with appropriate instances. Implements CLC proposal 235. Resolves #24277 - - - - - 9 changed files: - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -84,6 +84,8 @@ module GHC.Exts traceEvent, -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, ===================================== libraries/base/src/GHC/Stack.hs ===================================== @@ -18,6 +18,7 @@ module GHC.Stack (errorWithStackTrace, -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks CallStack, @@ -37,16 +38,19 @@ module GHC.Stack -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where -import GHC.Internal.Stack \ No newline at end of file +import GHC.Internal.Stack ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -24,6 +25,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +40,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO Word32 +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Internal.Stack.CCS.CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9303,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9312,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11557,6 +11563,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11639,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12022,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12134,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12208,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12255,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12432,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12633,6 +12646,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12811,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -5727,6 +5727,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -12351,14 +12352,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -12380,14 +12384,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -5907,6 +5907,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9533,14 +9534,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9562,14 +9566,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9309,14 +9310,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9338,14 +9342,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/082a054c59e7fad06fcc2736fe81e7eb17d9c3cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/082a054c59e7fad06fcc2736fe81e7eb17d9c3cf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 00:59:18 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 04 Mar 2024 19:59:18 -0500 Subject: [Git][ghc/ghc][master] add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e66e668328f_4bf9047ed19c3253e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 26 changed files: - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -1,164 +1,90 @@ -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE TupleSections #-} +{-# LANGUAGE RecordWildCards #-} --- | Adds cost-centers after the core piple has run. +-- | Adds cost-centers after the core pipline has run. module GHC.Core.LateCC - ( addLateCostCentresMG - , addLateCostCentresPgm - , addLateCostCentres -- Might be useful for API users - , Env(..) + ( -- * Inserting cost centres + addLateCostCenters ) where -import Control.Applicative -import Control.Monad -import qualified Data.Set as S - import GHC.Prelude -import GHC.Types.CostCentre -import GHC.Types.CostCentre.State -import GHC.Types.Name hiding (varName) -import GHC.Types.Tickish -import GHC.Unit.Module.ModGuts -import GHC.Types.Var -import GHC.Unit.Types -import GHC.Data.FastString -import GHC.Core -import GHC.Core.Opt.Monad -import GHC.Core.Utils (mkTick) -import GHC.Types.Id -import GHC.Driver.DynFlags +import GHC.Core +import GHC.Core.LateCC.OverloadedCalls +import GHC.Core.LateCC.TopLevelBinds +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Seq +import qualified GHC.Data.Strict as Strict +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.SrcLoc +import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Utils.Misc -import GHC.Utils.Error (withTiming) -import GHC.Utils.Monad.State.Strict - - -{- Note [Collecting late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Usually cost centres defined by a module are collected -during tidy by collectCostCentres. However with `-fprof-late` -we insert cost centres after inlining. So we keep a list of -all the cost centres we inserted and combine that with the list -of cost centres found during tidy. - -To avoid overhead when using -fprof-inline there is a flag to stop -us from collecting them here when we run this pass before tidy. - -Note [Adding late cost centres] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The basic idea is very simple. For every top level binder -`f = rhs` we compile it as if the user had written -`f = {-# SCC f #-} rhs`. - -If we do this after unfoldings for `f` have been created this -doesn't impact core-level optimizations at all. If we do it -before the cost centre will be included in the unfolding and -might inhibit optimizations at the call site. For this reason -we provide flags for both approaches as they have different -tradeoffs. - -We also don't add a cost centre for any binder that is a constructor -worker or wrapper. These will never meaningfully enrich the resulting -profile so we improve efficiency by omitting those. - --} - -addLateCostCentresMG :: ModGuts -> CoreM ModGuts -addLateCostCentresMG guts = do - dflags <- getDynFlags - let env :: Env - env = Env - { thisModule = mg_module guts - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = False -- See Note [Collecting late cost centres] - } - let guts' = guts { mg_binds = fstOf3 (addLateCostCentres env (mg_binds guts)) - } - return guts' - -addLateCostCentresPgm :: DynFlags -> Logger -> Module -> CoreProgram -> IO (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentresPgm dflags logger mod binds = - withTiming logger - (text "LateCC"<+>brackets (ppr mod)) - (\(a,b,c) -> a `seqList` (b `seq` (c `seq` ()))) $ do - let env = Env - { thisModule = mod - , countEntries = gopt Opt_ProfCountEntries dflags - , collectCCs = True -- See Note [Collecting late cost centres] - } - (binds', ccs, cc_state) = addLateCostCentres env binds - when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ - putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr binds')) - return (binds', ccs, cc_state) -addLateCostCentres :: Env -> CoreProgram -> (CoreProgram, S.Set CostCentre, CostCentreState) -addLateCostCentres env binds = - let (binds', state) = runState (mapM (doBind env) binds) initLateCCState - in (binds', lcs_ccs state, lcs_state state) - - -doBind :: Env -> CoreBind -> M CoreBind -doBind env (NonRec b rhs) = NonRec b <$> doBndr env b rhs -doBind env (Rec bs) = Rec <$> mapM doPair bs +-- | Late cost center insertion logic used by the driver +addLateCostCenters :: + Logger + -- ^ Logger + -> LateCCConfig + -- ^ Late cost center configuration + -> CoreProgram + -- ^ The program + -> IO (CoreProgram, LateCCState (Strict.Maybe SrcSpan)) +addLateCostCenters logger LateCCConfig{..} core_binds = do + + -- If top-level late CCs are enabled via either -fprof-late or + -- -fprof-late-overloaded, add them + (top_level_cc_binds, top_level_late_cc_state) <- + case lateCCConfig_whichBinds of + LateCCNone -> + return (core_binds, initLateCCState ()) + _ -> + withTiming + logger + (text "LateTopLevelCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateTopLevelCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (initLateCCState ()) + (topLevelBindsCC top_level_cc_pred) + core_binds + + -- If overloaded call CCs are enabled via -fprof-late-overloaded-calls, add + -- them + (late_cc_binds, late_cc_state) <- + if lateCCConfig_overloadedCalls then + withTiming + logger + (text "LateOverloadedCallsCCs" <+> brackets (ppr this_mod)) + (\(binds, late_cc_state) -> seqBinds binds `seq` late_cc_state `seq` ()) + $ {-# SCC lateoverloadedCallsCCs #-} do + pure $ + doLateCostCenters + lateCCConfig_env + (top_level_late_cc_state { lateCCState_extra = Strict.Nothing }) + overloadedCallsCC + top_level_cc_binds + else + return + ( top_level_cc_binds + , top_level_late_cc_state { lateCCState_extra = Strict.Nothing } + ) + + return (late_cc_binds, late_cc_state) where - doPair :: ((Id, CoreExpr) -> M (Id, CoreExpr)) - doPair (b,rhs) = (b,) <$> doBndr env b rhs - -doBndr :: Env -> Id -> CoreExpr -> M CoreExpr -doBndr env bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = doBndr' env bndr rhs - - --- We want to put the cost centre below the lambda as we only care about executions of the RHS. -doBndr' :: Env -> Id -> CoreExpr -> State LateCCState CoreExpr -doBndr' env bndr (Lam b rhs) = Lam b <$> doBndr' env bndr rhs -doBndr' env bndr rhs = do - let name = idName bndr - name_loc = nameSrcSpan name - cc_name = getOccFS name - count = countEntries env - cc_flavour <- getCCFlavour cc_name - let cc_mod = thisModule env - bndrCC = NormalCC cc_flavour cc_name cc_mod name_loc - note = ProfNote bndrCC count True - addCC env bndrCC - return $ mkTick note rhs - -data LateCCState = LateCCState - { lcs_state :: !CostCentreState - , lcs_ccs :: S.Set CostCentre - } -type M = State LateCCState - -initLateCCState :: LateCCState -initLateCCState = LateCCState newCostCentreState mempty - -getCCFlavour :: FastString -> M CCFlavour -getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name - -getCCIndex' :: FastString -> M CostCentreIndex -getCCIndex' name = do - state <- get - let (index,cc_state') = getCCIndex name (lcs_state state) - put (state { lcs_state = cc_state'}) - return index - -addCC :: Env -> CostCentre -> M () -addCC !env cc = do - state <- get - when (collectCCs env) $ do - let ccs' = S.insert cc (lcs_ccs state) - put (state { lcs_ccs = ccs'}) - -data Env = Env - { thisModule :: !Module - , countEntries:: !Bool - , collectCCs :: !Bool - } - + top_level_cc_pred :: CoreExpr -> Bool + top_level_cc_pred = + case lateCCConfig_whichBinds of + LateCCAllBinds -> + const True + LateCCOverloadedBinds -> + isOverloadedTy . exprType + LateCCNone -> + -- This is here for completeness, we won't actually use this + -- predicate in this case since we'll shortcut. + const False + + this_mod = lateCCEnv_module lateCCConfig_env ===================================== compiler/GHC/Core/LateCC/OverloadedCalls.hs ===================================== @@ -0,0 +1,204 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} + +module GHC.Core.LateCC.OverloadedCalls + ( overloadedCallsCC + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified GHC.Data.Strict as Strict + +import GHC.Data.FastString +import GHC.Core +import GHC.Core.LateCC.Utils +import GHC.Core.LateCC.Types +import GHC.Core.Make +import GHC.Core.Predicate +import GHC.Core.Type +import GHC.Core.Utils +import GHC.Tc.Utils.TcType +import GHC.Types.Id +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Types.Tickish +import GHC.Types.Var +import GHC.Utils.Outputable + +type OverloadedCallsCCState = Strict.Maybe SrcSpan + +-- | Insert cost centres on function applications with dictionary arguments. The +-- source locations attached to the cost centres is approximated based on the +-- "closest" source note encountered in the traversal. +overloadedCallsCC :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind +overloadedCallsCC = + processBind + where + processBind :: CoreBind -> LateCCM OverloadedCallsCCState CoreBind + processBind core_bind = + case core_bind of + NonRec b e -> + NonRec b <$> wrap_if_join b (processExpr e) + Rec es -> + Rec <$> mapM (\(b,e) -> (b,) <$> wrap_if_join b (processExpr e)) es + where + -- If an overloaded function is turned into a join point, we won't add + -- SCCs directly to calls since it makes them non-tail calls. Instead, + -- we look for join points here and add an SCC to their RHS if they are + -- overloaded. + wrap_if_join :: + CoreBndr + -> LateCCM OverloadedCallsCCState CoreExpr + -> LateCCM OverloadedCallsCCState CoreExpr + wrap_if_join b pexpr = do + expr <- pexpr + if isJoinId b && isOverloadedTy (exprType expr) then do + let + cc_name :: FastString + cc_name = fsLit "join-rhs-" `appendFS` getOccFS b + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan expr + else + return expr + + + processExpr :: CoreExpr -> LateCCM OverloadedCallsCCState CoreExpr + processExpr expr = + case expr of + -- The case we care about: Application + app at App{} -> do + -- Here we have some application like `f v1 ... vN`, where v1 ... vN + -- should be the function's type arguments followed by the value + -- arguments. To determine if the `f` is an overloaded function, we + -- check if any of the arguments v1 ... vN are dictionaries. + let + (f, xs) = collectArgs app + resultTy = applyTypeToArgs empty (exprType f) xs + + -- Recursively process the arguments first for no particular reason + args <- mapM processExpr xs + let app' = mkCoreApps f args + + if + -- Check if any of the arguments are dictionaries + any isDictExpr args + + -- Avoid instrumenting dictionary functions, which may be + -- overloaded if there are superclasses, by checking if the result + -- type of the function is a dictionary type. + && not (isDictTy resultTy) + + -- Avoid instrumenting constraint selectors like eq_sel + && (typeTypeOrConstraint resultTy /= ConstraintLike) + + -- Avoid instrumenting join points. + -- (See comment in processBind above) + && not (isJoinVarExpr f) + then do + -- Extract a name and source location from the function being + -- applied + let + cc_name :: FastString + cc_name = + fsLit $ maybe "" getOccString (exprName app) + + cc_srcspan <- + fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ + lift $ gets lateCCState_extra + + insertCC cc_name cc_srcspan app' + else + return app' + + -- For recursive constructors of Expr, we traverse the nested Exprs + Lam b e -> + mkCoreLams [b] <$> processExpr e + Let b e -> + mkCoreLet <$> processBind b <*> processExpr e + Case e b t alts -> + Case + <$> processExpr e + <*> pure b + <*> pure t + <*> mapM processAlt alts + Cast e co -> + mkCast <$> processExpr e <*> pure co + Tick t e -> do + trackSourceNote t $ + mkTick t <$> processExpr e + + -- For non-recursive constructors of Expr, we do nothing + x -> return x + + processAlt :: CoreAlt -> LateCCM OverloadedCallsCCState CoreAlt + processAlt (Alt c bs e) = Alt c bs <$> processExpr e + + trackSourceNote :: CoreTickish -> LateCCM OverloadedCallsCCState a -> LateCCM OverloadedCallsCCState a + trackSourceNote tick act = + case tick of + SourceNote rss _ -> do + -- Prefer source notes from the current file + in_current_file <- + maybe False ((== EQ) . lexicalCompareFS (srcSpanFile rss)) <$> + asks lateCCEnv_file + if not in_current_file then + act + else do + loc <- lift $ gets lateCCState_extra + lift . modify $ \s -> + s { lateCCState_extra = + Strict.Just $ RealSrcSpan rss mempty + } + x <- act + lift . modify $ \s -> + s { lateCCState_extra = loc + } + return x + _ -> + act + + -- Utility functions + + -- Extract a Name from an expression. If it is an application, attempt to + -- extract a name from the applied function. If it is a variable, return the + -- Name of the variable. If it is a tick/cast, attempt to extract a Name + -- from the expression held in the tick/cast. Otherwise return Nothing. + exprName :: CoreExpr -> Maybe Name + exprName = + \case + App f _ -> + exprName f + Var f -> + Just (idName f) + Tick _ e -> + exprName e + Cast e _ -> + exprName e + _ -> + Nothing + + -- Determine whether an expression is a dictionary + isDictExpr :: CoreExpr -> Bool + isDictExpr = + maybe False isDictTy . exprType' + where + exprType' :: CoreExpr -> Maybe Type + exprType' = \case + Type{} -> Nothing + expr -> Just $ exprType expr + + -- Determine whether an expression is a join variable + isJoinVarExpr :: CoreExpr -> Bool + isJoinVarExpr = + \case + Var var -> isJoinId var + Tick _ e -> isJoinVarExpr e + Cast e _ -> isJoinVarExpr e + _ -> False ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE TupleSections #-} +module GHC.Core.LateCC.TopLevelBinds where + +import GHC.Prelude + +import GHC.Core +-- import GHC.Core.LateCC +import GHC.Core.LateCC.Types +import GHC.Core.LateCC.Utils +import GHC.Core.Opt.Monad +import GHC.Driver.DynFlags +import GHC.Types.Id +import GHC.Types.Name +import GHC.Unit.Module.ModGuts + +{- Note [Collecting late cost centres] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Usually cost centres defined by a module are collected +during tidy by collectCostCentres. However with `-fprof-late` +we insert cost centres after inlining. So we keep a list of +all the cost centres we inserted and combine that with the list +of cost centres found during tidy. + +To avoid overhead when using -fprof-inline there is a flag to stop +us from collecting them here when we run this pass before tidy. + +Note [Adding late cost centres to top level bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The basic idea is very simple. For every top level binder +`f = rhs` we compile it as if the user had written +`f = {-# SCC f #-} rhs`. + +If we do this after unfoldings for `f` have been created this +doesn't impact core-level optimizations at all. If we do it +before the cost centre will be included in the unfolding and +might inhibit optimizations at the call site. For this reason +we provide flags for both approaches as they have different +tradeoffs. + +We also don't add a cost centre for any binder that is a constructor +worker or wrapper. These will never meaningfully enrich the resulting +profile so we improve efficiency by omitting those. + +-} + +-- | Add late cost centres directly to the 'ModGuts'. This is used inside the +-- core pipeline with the -fprof-late-inline flag. It should not be used after +-- tidy, since it does not manually track inserted cost centers. See +-- Note [Collecting late cost centres]. +topLevelBindsCCMG :: ModGuts -> CoreM ModGuts +topLevelBindsCCMG guts = do + dflags <- getDynFlags + let + env = + LateCCEnv + { lateCCEnv_module = mg_module guts + + -- We don't use this for topLevelBindsCC, so Nothing is okay + , lateCCEnv_file = Nothing + + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = False + } + guts' = + guts + { mg_binds = + fst + ( doLateCostCenters + env + (initLateCCState ()) + (topLevelBindsCC (const True)) + (mg_binds guts) + ) + } + return guts' + +-- | Insert cost centres on top-level bindings in the module, depending on +-- whether or not they satisfy the given predicate. +topLevelBindsCC :: (CoreExpr -> Bool) -> CoreBind -> LateCCM s CoreBind +topLevelBindsCC pred core_bind = + case core_bind of + NonRec b rhs -> + NonRec b <$> doBndr b rhs + Rec bs -> + Rec <$> mapM doPair bs + where + doPair :: ((Id, CoreExpr) -> LateCCM s (Id, CoreExpr)) + doPair (b,rhs) = (b,) <$> doBndr b rhs + + doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr + doBndr bndr rhs + -- Cost centres on constructor workers are pretty much useless + -- so we don't emit them if we are looking at the rhs of a constructor + -- binding. + | Just _ <- isDataConId_maybe bndr = pure rhs + | otherwise = if pred rhs then addCC bndr rhs else pure rhs + + -- We want to put the cost centre below the lambda as we only care about + -- executions of the RHS. + addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs + addCC bndr rhs = do + let name = idName bndr + cc_loc = nameSrcSpan name + cc_name = getOccFS name + insertCC cc_name cc_loc rhs \ No newline at end of file ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -0,0 +1,74 @@ +-- | Types related to late cost center insertion +module GHC.Core.LateCC.Types + ( LateCCConfig(..) + , LateCCBindSpec(..) + , LateCCEnv(..) + , LateCCState(..) + , initLateCCState + , LateCCM + ) where + +import GHC.Prelude + +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Unit.Types + +-- | Late cost center insertion configuration. +-- +-- Specifies whether cost centers are added to overloaded function call sites +-- and/or top-level bindings, and which top-level bindings they are added to. +-- Also holds the cost center insertion environment. +data LateCCConfig = + LateCCConfig + { lateCCConfig_whichBinds :: !LateCCBindSpec + , lateCCConfig_overloadedCalls :: !Bool + , lateCCConfig_env :: !LateCCEnv + } + +-- | The types of top-level bindings we support adding cost centers to. +data LateCCBindSpec = + LateCCNone + | LateCCAllBinds + | LateCCOverloadedBinds + +-- | Late cost centre insertion environment +data LateCCEnv = LateCCEnv + { lateCCEnv_module :: !Module + -- ^ Current module + , lateCCEnv_file :: Maybe FastString + -- ^ Current file, if we have one + , lateCCEnv_countEntries:: !Bool + -- ^ Whether the inserted cost centers should count entries + , lateCCEnv_collectCCs :: !Bool + -- ^ Whether to collect the cost centres we insert. See + -- Note [Collecting late cost centres] + + } + +-- | Late cost centre insertion state, indexed by some extra state type that an +-- insertion method may require. +data LateCCState s = LateCCState + { lateCCState_ccs :: !(S.Set CostCentre) + -- ^ Cost centres that have been inserted + , lateCCState_ccState :: !CostCentreState + -- ^ Per-module state tracking for cost centre indices + , lateCCState_extra :: !s + } + +-- | The empty late cost centre insertion state +initLateCCState :: s -> LateCCState s +initLateCCState s = + LateCCState + { lateCCState_ccState = newCostCentreState + , lateCCState_ccs = mempty + , lateCCState_extra = s + } + +-- | Late cost centre insertion monad +type LateCCM s = ReaderT LateCCEnv (State (LateCCState s)) ===================================== compiler/GHC/Core/LateCC/Utils.hs ===================================== @@ -0,0 +1,80 @@ +module GHC.Core.LateCC.Utils + ( -- * Inserting cost centres + doLateCostCenters -- Might be useful for API users + + -- ** Helpers for defining insertion methods + , getCCFlavour + , insertCC + ) where + +import GHC.Prelude + +import Control.Monad +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State.Strict +import qualified Data.Set as S + +import GHC.Core +import GHC.Core.LateCC.Types +import GHC.Core.Utils +import GHC.Data.FastString +import GHC.Types.CostCentre +import GHC.Types.CostCentre.State +import GHC.Types.SrcLoc +import GHC.Types.Tickish + +-- | Insert cost centres into the 'CoreProgram' using the provided environment, +-- initial state, and insertion method. +doLateCostCenters + :: LateCCEnv + -- ^ Environment to run the insertion in + -> LateCCState s + -- ^ Initial state to run the insertion with + -> (CoreBind -> LateCCM s CoreBind) + -- ^ Insertion method + -> CoreProgram + -- ^ Bindings to consider + -> (CoreProgram, LateCCState s) +doLateCostCenters env state method binds = + runLateCC env state $ mapM method binds + +-- | Evaluate late cost centre insertion +runLateCC :: LateCCEnv -> LateCCState s -> LateCCM s a -> (a, LateCCState s) +runLateCC env state = (`runState` state) . (`runReaderT` env) + +-- | Given the name of a cost centre, get its flavour +getCCFlavour :: FastString -> LateCCM s CCFlavour +getCCFlavour name = mkLateCCFlavour <$> getCCIndex' name + where + getCCIndex' :: FastString -> LateCCM s CostCentreIndex + getCCIndex' name = do + cc_state <- lift $ gets lateCCState_ccState + let (index, cc_state') = getCCIndex name cc_state + lift . modify $ \s -> s { lateCCState_ccState = cc_state'} + return index + +-- | Insert a cost centre with the specified name and source span on the given +-- expression. The inserted cost centre will be appropriately tracked in the +-- late cost centre state. +insertCC + :: FastString + -- ^ Name of the cost centre to insert + -> SrcSpan + -- ^ Source location to associate with the cost centre + -> CoreExpr + -- ^ Expression to wrap in the cost centre + -> LateCCM s CoreExpr +insertCC cc_name cc_loc expr = do + cc_flavour <- getCCFlavour cc_name + env <- ask + let + cc_mod = lateCCEnv_module env + cc = NormalCC cc_flavour cc_name cc_mod cc_loc + note = ProfNote cc (lateCCEnv_countEntries env) True + when (lateCCEnv_collectCCs env) $ do + lift . modify $ \s -> + s { lateCCState_ccs = S.insert cc (lateCCState_ccs s) + } + return $ mkTick note expr + ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) import GHC.Core.Opt.CallerCC ( addCallerCostCentres ) -import GHC.Core.LateCC (addLateCostCentresMG) +import GHC.Core.LateCC.TopLevelBinds (topLevelBindsCCMG) import GHC.Core.Seq (seqBinds) import GHC.Core.FamInstEnv @@ -520,7 +520,7 @@ doCorePass pass guts = do addCallerCostCentres guts CoreAddLateCcs -> {-# SCC "AddLateCcs" #-} - addLateCostCentresMG guts + topLevelBindsCCMG guts CoreDoPrintCore -> {-# SCC "PrintCore" #-} liftIO $ printCore logger (mg_binds guts) >> return guts ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -341,6 +341,8 @@ data GeneralFlag | Opt_ProfCountEntries | Opt_ProfLateInlineCcs | Opt_ProfLateCcs + | Opt_ProfLateOverloadedCcs + | Opt_ProfLateoverloadedCallsCCs | Opt_ProfManualCcs -- ^ Ignore manual SCC annotations -- misc opts ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -175,7 +175,6 @@ import GHC.Iface.Ext.Debug ( diffFile, validateScopes ) import GHC.Core import GHC.Core.Lint.Interactive ( interactiveInScope ) import GHC.Core.Tidy ( tidyExpr ) -import GHC.Core.Type ( Type, Kind ) import GHC.Core.Utils ( exprType ) import GHC.Core.ConLike import GHC.Core.Opt.Pipeline @@ -185,7 +184,8 @@ import GHC.Core.InstEnv import GHC.Core.FamInstEnv import GHC.Core.Rules import GHC.Core.Stats -import GHC.Core.LateCC (addLateCostCentresPgm) +import GHC.Core.LateCC +import GHC.Core.LateCC.Types import GHC.CoreToStg.Prep @@ -197,6 +197,7 @@ import GHC.Parser.Lexer as Lexer import GHC.Tc.Module import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.TcType import GHC.Tc.Zonk.Env ( ZonkFlexi (DefaultFlexi) ) import GHC.Stg.Syntax @@ -297,7 +298,6 @@ import GHC.StgToCmm.Utils (IPEStats) import GHC.Types.Unique.FM import GHC.Types.Unique.DFM import GHC.Cmm.Config (CmmConfig) -import GHC.Types.CostCentre.State (newCostCentreState) {- ********************************************************************** @@ -1791,22 +1791,41 @@ hscGenHardCode hsc_env cgguts location output_filename = do ------------------- - -- Insert late cost centres if enabled. - -- If `-fprof-late-inline` is enabled we can skip this, as it will have added - -- a superset of cost centres we would add here already. - - (late_cc_binds, late_local_ccs, cc_state) <- - if gopt Opt_ProfLateCcs dflags && not (gopt Opt_ProfLateInlineCcs dflags) - then - withTiming - logger - (text "LateCCs"<+>brackets (ppr this_mod)) - (const ()) - $ {-# SCC lateCC #-} do - (binds, late_ccs, cc_state) <- addLateCostCentresPgm dflags logger this_mod core_binds - return ( binds, (S.toList late_ccs `mappend` local_ccs ), cc_state) + -- Insert late cost centres based on the provided flags. + -- + -- If -fprof-late-inline is enabled, we will skip adding CCs on any + -- top-level bindings here (via shortcut in `addLateCostCenters`), + -- since it will have already added a superset of the CCs we would add + -- here. + let + late_cc_config :: LateCCConfig + late_cc_config = + LateCCConfig + { lateCCConfig_whichBinds = + if gopt Opt_ProfLateInlineCcs dflags then + LateCCNone + else if gopt Opt_ProfLateCcs dflags then + LateCCAllBinds + else if gopt Opt_ProfLateOverloadedCcs dflags then + LateCCOverloadedBinds else - return (core_binds, local_ccs, newCostCentreState) + LateCCNone + , lateCCConfig_overloadedCalls = + gopt Opt_ProfLateoverloadedCallsCCs dflags + , lateCCConfig_env = + LateCCEnv + { lateCCEnv_module = this_mod + , lateCCEnv_file = fsLit <$> ml_hs_file location + , lateCCEnv_countEntries= gopt Opt_ProfCountEntries dflags + , lateCCEnv_collectCCs = True + } + } + + (late_cc_binds, late_cc_state) <- + addLateCostCenters logger late_cc_config core_binds + + when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ + putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr late_cc_binds)) ------------------- -- Run late plugins @@ -1820,7 +1839,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do cg_hpc_info = hpc_info, cg_spt_entries = spt_entries, cg_binds = late_binds, - cg_ccs = late_local_ccs' + cg_ccs = late_local_ccs } , _ ) <- @@ -1833,9 +1852,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do (($ hsc_env) . latePlugin) ( cgguts { cg_binds = late_cc_binds - , cg_ccs = late_local_ccs + , cg_ccs = S.toList (lateCCState_ccs late_cc_state) ++ local_ccs } - , cc_state + , lateCCState_ccState late_cc_state ) let @@ -1876,7 +1895,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do let (stg_binds,_stg_deps) = unzip stg_binds_with_deps let cost_centre_info = - (late_local_ccs' ++ caf_ccs, caf_cc_stacks) + (late_local_ccs ++ caf_ccs, caf_cc_stacks) platform = targetPlatform dflags prof_init | sccProfilingEnabled dflags = profilingInitCode platform this_mod cost_centre_info ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2444,6 +2444,8 @@ fFlagsDeps = [ flagSpec "prof-cafs" Opt_AutoSccsOnIndividualCafs, flagSpec "prof-count-entries" Opt_ProfCountEntries, flagSpec "prof-late" Opt_ProfLateCcs, + flagSpec "prof-late-overloaded" Opt_ProfLateOverloadedCcs, + flagSpec "prof-late-overloaded-calls" Opt_ProfLateoverloadedCallsCCs, flagSpec "prof-manual" Opt_ProfManualCcs, flagSpec "prof-late-inline" Opt_ProfLateInlineCcs, flagSpec "regs-graph" Opt_RegsGraph, @@ -3763,6 +3765,10 @@ needSourceNotes :: DynFlags -> Bool needSourceNotes dflags = debugLevel dflags > 0 || gopt Opt_InfoTableMap dflags + -- Source ticks are used to approximate the location of + -- overloaded call cost centers + || gopt Opt_ProfLateoverloadedCallsCCs dflags + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1907,7 +1907,7 @@ isRhoExpTy (Infer {}) = True isOverloadedTy :: Type -> Bool -- Yes for a type of a function that might require evidence-passing --- Used only by bindLocalMethods +-- Used by bindLocalMethods and for -fprof-late-overloaded isOverloadedTy ty | Just ty' <- coreView ty = isOverloadedTy ty' isOverloadedTy (ForAllTy _ ty) = isOverloadedTy ty isOverloadedTy (FunTy { ft_af = af }) = isInvisibleFunArg af ===================================== compiler/ghc.cabal.in ===================================== @@ -336,6 +336,10 @@ Library GHC.Core.Lint GHC.Core.Lint.Interactive GHC.Core.LateCC + GHC.Core.LateCC.Types + GHC.Core.LateCC.TopLevelBinds + GHC.Core.LateCC.Utils + GHC.Core.LateCC.OverloadedCalls GHC.Core.Make GHC.Core.Map.Expr GHC.Core.Map.Type ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -186,6 +186,15 @@ Compiler This means that if you are using ``-fllvm`` you now need ``llc``, ``opt`` and ``clang`` available. +- The :ghc-flag:`-fprof-late-overloaded` flag has been introduced. It causes + cost centres to be added to *overloaded* top level bindings, unlike + :ghc-flag:`-fprof-late` which adds cost centres to all top level bindings. + +- The :ghc-flag:`-fprof-late-overloaded-calls` flag has been introduced. It + causes cost centres to be inserted at call sites including instance dictionary + arguments. This may be preferred over :ghc-flag:`-fprof-late-overloaded` since + it may reveal whether imported functions are called overloaded. + JavaScript backend ~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -518,6 +518,49 @@ of your profiled program will be different to that of the unprofiled one. You can try this mode if :ghc-flag:`-fprof-late` results in a profile that's too hard to interpret. +.. ghc-flag:: -fprof-late-overloaded + :shortdesc: Auto-add ``SCC``\\ s to all top level overloaded bindings *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all *overloaded* top level bindings + late in the compilation pipeline after the optimizer has run and unfoldings + have been created. This means these cost centres will not interfere with + core-level optimizations and the resulting profile will be closer to the + performance profile of an optimized non-profiled executable. + + This flag can help determine which top level bindings encountered during a + program's execution are still overloaded after inlining and specialization. + +.. ghc-flag:: -fprof-late-overloaded-calls + :shortdesc: Auto-add ``SCC``\\ s to all call sites that include dictionary arguments *after* the core pipeline has run. + :type: dynamic + :reverse: -fno-prof-late-overloaded-calls + :category: + + :since: 9.10.1 + + Adds an automatic ``SCC`` annotation to all call sites that include + dictionary arguments late in the compilation pipeline after the optimizer + has run and unfoldings have been created. This means these cost centres will + not interfere with core-level optimizations and the resulting profile will + be closer to the performance profile of an optimized non-profiled + executable. + + This flag is potentially more useful than :ghc-flag:`-fprof-late-overloaded` + since it will also add ``SCC`` annotations to call sites of imported + overloaded functions. + + Some overloaded calls may not be annotated, specifically in cases where the + optimizer turns an overloaded function into a join point. Calls to such + functions will not be wrapped in ``SCC`` annotations, since it would make + them non-tail calls, which is a requirement for join points. Instead, + ``SCC`` annotations are added around the body of overloaded join variables + and given distinct names (``join-rhs-``) to avoid confusion. + .. ghc-flag:: -fprof-cafs :shortdesc: Auto-add ``SCC``\\ s to all CAFs :type: dynamic ===================================== testsuite/tests/profiling/should_run/all.T ===================================== @@ -195,3 +195,30 @@ test('ignore_scc', [], compile_and_run, ['-fno-prof-manual']) test('T21446', [], makefile_test, ['T21446']) + + +test('scc-prof-overloaded001', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded002', + [], + compile_and_run, + ['-fno-prof-auto -fno-full-laziness -fprof-late-overloaded'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls001', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fno-full-laziness -fprof-late-overloaded-calls'] # See Note [consistent stacks] +) + +test('scc-prof-overloaded-calls002', + [], + compile_and_run, + # Need optimizations to get rid of unwanted overloaded calls + ['-O -fno-prof-auto -fprof-late-overloaded-calls'] +) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample ===================================== @@ -0,0 +1,26 @@ + Thu Jan 4 11:49 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,320 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded-calls001.hs:24:1-31 256 1 0.0 0.3 0.0 0.8 + f Main scc-prof-overloaded-calls001.hs:18:1-18 257 1 0.0 0.6 0.0 0.6 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample ===================================== @@ -0,0 +1,31 @@ + Fri Jan 5 11:06 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded-calls002 +RTS -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 59,152 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 34.8 +CAF GHC.IO.Handle.FD 0.0 58.7 +CAF GHC.IO.Encoding 0.0 4.1 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 34.8 0.0 100.0 + CAF Main 255 0 0.0 0.6 0.0 0.9 + f Main scc-prof-overloaded-calls002.hs:52:1-25 262 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:48:1-25 261 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:44:1-25 260 1 0.0 0.1 0.0 0.1 + f Main scc-prof-overloaded-calls002.hs:40:1-25 259 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:36:1-25 258 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:32:1-25 257 1 0.0 0.0 0.0 0.0 + f Main scc-prof-overloaded-calls002.hs:28:1-25 256 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.1 0.0 4.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.3 0.0 0.3 + CAF GHC.IO.Handle.FD 208 0 0.0 58.7 0.0 58.7 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs ===================================== @@ -0,0 +1,24 @@ +-- Running this program should result in two calls to overloaded functions: One +-- with the $fShowX dictionary, the next with the $fShowList dictionary +-- constructor for X. +-- +-- Note that although the `$fShowList` dictionary constructor is itself +-- overloaded, it should not get an SCC since we avoid instrumenting overloaded +-- calls that result in dictionaries. +-- +-- With just -fprof-late-overloaded, only `invoke` should get an SCC, since it +-- is the only overloaded top level binding. With +-- `-fprof-late-overloaded-calls`, the calls to both `invoke` and `f` (in the +-- body of invoke) should get SCCs. + +module Main where + +{-# NOINLINE invoke #-} +invoke :: Show a => (Show [a] => [a] -> String) -> a -> String +invoke f x = f [x] + +data X = X + deriving Show + +main :: IO () +main = putStrLn (invoke show X) ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.prof.sample ===================================== @@ -0,0 +1,25 @@ + Thu Jan 4 11:26 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded001 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 48,304 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 20.5 +CAF GHC.IO.Handle.FD 0.0 71.9 +CAF GHC.IO.Encoding 0.0 5.1 +CAF GHC.Conc.Signal 0.0 1.3 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 20.5 0.0 100.0 + CAF Main 255 0 0.0 0.0 0.0 0.8 + invoke Main scc-prof-overloaded001.hs:18:1-6 256 1 0.0 0.8 0.0 0.8 + CAF GHC.Conc.Signal 238 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 219 0 0.0 5.1 0.0 5.1 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 71.9 0.0 71.9 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded001.stdout ===================================== @@ -0,0 +1 @@ +[X] ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.hs ===================================== @@ -0,0 +1,65 @@ +-- Running this program should result in seven calls to overloaded functions +-- with increasing numbers of dictionary arguments. +-- +-- With just -fprof-late-overloaded, no SCCs should be added, since none of the +-- overloaded functions are top level. With `-fprof-late-overloaded-calls`, all +-- seven calls should get *distinct* SCCs with separate source locations even +-- though the overloaded functions share an OccName (`f`). + +module Main where + +data X = X + +instance Show X where +instance Num X where +instance Eq X where +instance Enum X where +instance Ord X where +instance Real X where +instance Integral X where + +-- No overloaded call +{-# NOINLINE invoke0 #-} +invoke0 :: (forall a. a -> a -> String) -> X -> String +invoke0 f val = f val val + +{-# NOINLINE invoke1 #-} +invoke1 :: (forall a. Show a => a -> a -> String) -> X -> String +invoke1 f val = f val val + +{-# NOINLINE invoke2 #-} +invoke2 :: (forall a. (Show a, Num a) => a -> a -> String) -> X -> String +invoke2 f val = f val val + +{-# NOINLINE invoke3 #-} +invoke3 :: (forall a. (Show a, Num a, Eq a) => a -> a -> String) -> X -> String +invoke3 f val = f val val + +{-# NOINLINE invoke4 #-} +invoke4 :: (forall a. (Show a, Num a, Eq a, Enum a) => a -> a -> String) -> X -> String +invoke4 f val = f val val + +{-# NOINLINE invoke5 #-} +invoke5 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a) => a -> a -> String) -> X -> String +invoke5 f val = f val val + +{-# NOINLINE invoke6 #-} +invoke6 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a) => a -> a -> String) -> X -> String +invoke6 f val = f val val + +{-# NOINLINE invoke7 #-} +invoke7 :: (forall a. (Show a, Num a, Eq a, Enum a, Ord a, Real a, Integral a) => a -> a -> String) -> X -> String +invoke7 f val = f val val + +main :: IO () +main = do + putStrLn $ invoke0 (\_ _ -> s) X + putStrLn $ invoke1 (\_ _ -> s) X + putStrLn $ invoke2 (\_ _ -> s) X + putStrLn $ invoke3 (\_ _ -> s) X + putStrLn $ invoke4 (\_ _ -> s) X + putStrLn $ invoke5 (\_ _ -> s) X + putStrLn $ invoke6 (\_ _ -> s) X + putStrLn $ invoke7 (\_ _ -> s) X + where + s = "wibbly" ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.prof.sample ===================================== @@ -0,0 +1,23 @@ + Thu Jan 4 11:55 2024 Time and Allocation Profiling Report (Final) + + scc-prof-overloaded002 +RTS -hc -p -RTS + + total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) + total alloc = 56,472 bytes (excludes profiling overheads) + +COST CENTRE MODULE SRC %time %alloc + +MAIN MAIN 0.0 32.7 +CAF GHC.IO.Handle.FD 0.0 61.5 +CAF GHC.IO.Encoding 0.0 4.3 +CAF GHC.Conc.Signal 0.0 1.1 + + + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + +MAIN MAIN 128 0 0.0 32.7 0.0 100.0 + CAF GHC.Conc.Signal 238 0 0.0 1.1 0.0 1.1 + CAF GHC.IO.Encoding 219 0 0.0 4.3 0.0 4.3 + CAF GHC.IO.Encoding.Iconv 217 0 0.0 0.4 0.0 0.4 + CAF GHC.IO.Handle.FD 208 0 0.0 61.5 0.0 61.5 ===================================== testsuite/tests/profiling/should_run/scc-prof-overloaded002.stdout ===================================== @@ -0,0 +1,8 @@ +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly +wibbly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61bb5ff68630c203eaae4baba554640246df5a63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61bb5ff68630c203eaae4baba554640246df5a63 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 01:00:05 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 04 Mar 2024 20:00:05 -0500 Subject: [Git][ghc/ghc][master] x86-ncg: Fix fma codegen when arguments are globals Message-ID: <65e66e95ee021_4bf904b6261037199@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 4 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3424,7 +3424,6 @@ genFMA3Code :: Width -> FMASign -> CmmExpr -> CmmExpr -> CmmExpr -> NatM Register genFMA3Code w signs x y z = do - -- For the FMA instruction, we want to compute x * y + z -- -- There are three possible instructions we could emit: @@ -3445,17 +3444,45 @@ genFMA3Code w signs x y z = do -- -- Currently we follow neither of these optimisations, -- opting to always use fmadd213 for simplicity. + -- + -- We would like to compute the result directly into the requested register. + -- To do so we must first compute `x` into the destination register. This is + -- only possible if the other arguments don't use the destination register. + -- We check for this and if there is a conflict we move the result only after + -- the computation. See #24496 how this went wrong in the past. let rep = floatFormat w (y_reg, y_code) <- getNonClobberedReg y - (z_reg, z_code) <- getNonClobberedReg z + (z_op, z_code) <- getNonClobberedOperand z x_code <- getAnyReg x + x_tmp <- getNewRegNat rep let fma213 = FMA3 rep signs FMA213 - code dst - = y_code `appOL` + + code, code_direct, code_mov :: Reg -> InstrBlock + -- Ideal: Compute the result directly into dst + code_direct dst = x_code dst `snocOL` + fma213 z_op y_reg dst + -- Fallback: Compute the result into a tmp reg and then move it. + code_mov dst = x_code x_tmp `snocOL` + fma213 z_op y_reg x_tmp `snocOL` + MOV rep (OpReg x_tmp) (OpReg dst) + + code dst = + y_code `appOL` z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_reg dst + ( if arg_regs_conflict then code_mov dst else code_direct dst ) + + where + + arg_regs_conflict = + y_reg == dst || + case z_op of + OpReg z_reg -> z_reg == dst + OpAddr amode -> dst `elem` addrModeRegs amode + OpImm {} -> False + + -- NB: Computing the result into a desired register using Any can be tricky. + -- So for now, we keep it simple. (See #24496). return (Any rep code) ----------- ===================================== testsuite/tests/primops/should_run/T24496.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) +{-# NOINLINE twoProductFloat# #-} + +twoProductDouble# :: Double# -> Double# -> (# Double#, Double# #) +twoProductDouble# x y = let !r = x *## y + in (# r, fmsubDouble# x y r #) +{-# NOINLINE twoProductDouble# #-} + +main :: IO () +main = do + print $ case twoProductFloat# 2.0# 3.0# of (# r, s #) -> (F# r, F# s) + print $ case twoProductDouble# 2.0## 3.0## of (# r, s #) -> (D# r, D# s) ===================================== testsuite/tests/primops/should_run/T24496.stdout ===================================== @@ -0,0 +1,2 @@ +(6.0,0.0) +(6.0,0.0) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,3 +77,10 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) +test('T24496' + , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) + , js_skip # JS backend doesn't have an FMA implementation + , when(arch('wasm32'), skip) + , when(have_llvm(), extra_ways(["optllvm"])) + ] + , compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82ccb8012ba532f0fa06dc6ff96d33217560088a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82ccb8012ba532f0fa06dc6ff96d33217560088a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 02:53:31 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 04 Mar 2024 21:53:31 -0500 Subject: [Git][ghc/ghc][wip/exception-context] compiler: Don't show ExceptionContext of GhcExceptions Message-ID: <65e6892be80d4_4bf907ecdc70421ce@gitlab.mail> Ben Gamari pushed to branch wip/exception-context at Glasgow Haskell Compiler / GHC Commits: 5dcc5481 by Ben Gamari at 2024-03-04T21:52:13-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - 1 changed file: - compiler/GHC/Utils/Panic.hs Changes: ===================================== compiler/GHC/Utils/Panic.hs ===================================== @@ -127,6 +127,10 @@ instance Exception GhcException where PlainProgramError str -> ProgramError str | otherwise = Nothing + -- Explicitly omit ExceptionContext since we generally don't + -- want backtraces and other context in GHC's user errors. + displayException = ghcGhcExceptionUnsafe + instance Show GhcException where showsPrec _ e = showGhcExceptionUnsafe e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5dcc5481a48f55d95ed12114e8eb31b405ec8039 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5dcc5481a48f55d95ed12114e8eb31b405ec8039 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 03:31:29 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 04 Mar 2024 22:31:29 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: x86-ncg: Fix fma codegen when arguments are globals Message-ID: <65e69211a4511_4bf9090d3b90486e4@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 4a1b0eb0 by Cheng Shao at 2024-03-04T22:31:07-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 2d218101 by Ben Gamari at 2024-03-04T22:31:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - fc22d8dc by Ben Gamari at 2024-03-04T22:31:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 12 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - libraries/filepath - libraries/os-string - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/sm/MBlock.c - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T - testsuite/tests/rts/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3424,7 +3424,6 @@ genFMA3Code :: Width -> FMASign -> CmmExpr -> CmmExpr -> CmmExpr -> NatM Register genFMA3Code w signs x y z = do - -- For the FMA instruction, we want to compute x * y + z -- -- There are three possible instructions we could emit: @@ -3445,17 +3444,45 @@ genFMA3Code w signs x y z = do -- -- Currently we follow neither of these optimisations, -- opting to always use fmadd213 for simplicity. + -- + -- We would like to compute the result directly into the requested register. + -- To do so we must first compute `x` into the destination register. This is + -- only possible if the other arguments don't use the destination register. + -- We check for this and if there is a conflict we move the result only after + -- the computation. See #24496 how this went wrong in the past. let rep = floatFormat w (y_reg, y_code) <- getNonClobberedReg y - (z_reg, z_code) <- getNonClobberedReg z + (z_op, z_code) <- getNonClobberedOperand z x_code <- getAnyReg x + x_tmp <- getNewRegNat rep let fma213 = FMA3 rep signs FMA213 - code dst - = y_code `appOL` + + code, code_direct, code_mov :: Reg -> InstrBlock + -- Ideal: Compute the result directly into dst + code_direct dst = x_code dst `snocOL` + fma213 z_op y_reg dst + -- Fallback: Compute the result into a tmp reg and then move it. + code_mov dst = x_code x_tmp `snocOL` + fma213 z_op y_reg x_tmp `snocOL` + MOV rep (OpReg x_tmp) (OpReg dst) + + code dst = + y_code `appOL` z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_reg dst + ( if arg_regs_conflict then code_mov dst else code_direct dst ) + + where + + arg_regs_conflict = + y_reg == dst || + case z_op of + OpReg z_reg -> z_reg == dst + OpAddr amode -> dst `elem` addrModeRegs amode + OpImm {} -> False + + -- NB: Computing the result into a desired register using Any can be tricky. + -- So for now, we keep it simple. (See #24496). return (Any rep code) ----------- ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -232,6 +232,10 @@ Runtime system - Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. +- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual + memory address space reserved by the two step allocator on a 64-bit + platform. See :ghc-ticket:`24498`. + ``base`` library ~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -368,6 +368,18 @@ Miscellaneous RTS options thread can execute its exception handlers. The ``-xq`` controls the size of this additional quota. +.. rts-flag:: -xr ⟨size⟩ + + :default: 0.25T on aarch64, 1T otherwise + + This option controls the size of virtual memory address space + reserved by the two step allocator on a 64-bit platform. It can be + useful in scenarios where even reserving a large address range + without committing can be expensive (e.g. WSL1), or when you + actually have enough physical memory and want to support a Haskell + heap larger than 1T. ``-xr`` is a no-op if GHC is configured with + ``--disable-large-address-space`` or if the platform is 32-bit. + .. _rts-options-gc: RTS options to control the garbage collector ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 ===================================== rts/RtsFlags.c ===================================== @@ -186,6 +186,14 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.ringBell = false; RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */ +#if defined(aarch64_HOST_ARCH) + // 1/4 TBytes, see 38c98e4f for rationale + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 38; +#else + // 1 TBytes + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40; +#endif + RtsFlags.DebugFlags.scheduler = false; RtsFlags.DebugFlags.interpreter = false; RtsFlags.DebugFlags.weak = false; @@ -552,6 +560,11 @@ usage_text[] = { " -xq The allocation limit given to a thread after it receives", " an AllocationLimitExceeded exception. (default: 100k)", "", +#if defined(USE_LARGE_ADDRESS_SPACE) +" -xr The size of virtual memory address space reserved by the", +" two step allocator (default: 0.25T on aarch64, 1T otherwise)", +"", +#endif " -Mgrace=", " The amount of allocation after the program receives a", " HeapOverflow exception before the exception is thrown again, if", @@ -1820,6 +1833,12 @@ error = true; / BLOCK_SIZE; break; + case 'r': + OPTION_UNSAFE; + RtsFlags.GcFlags.addressSpaceSize + = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_INT_MAX); + break; + default: OPTION_SAFE; errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -2118,7 +2137,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) m = atof(s); c = s[strlen(s)-1]; - if (c == 'g' || c == 'G') + if (c == 't' || c == 'T') + m *= (StgWord64)1024*1024*1024*1024; + else if (c == 'g' || c == 'G') m *= 1024*1024*1024; else if (c == 'm' || c == 'M') m *= 1024*1024; @@ -2737,4 +2758,3 @@ doingErasProfiling( void ) || RtsFlags.ProfFlags.eraSelector != 0); } #endif /* PROFILING */ - ===================================== rts/include/rts/Flags.h ===================================== @@ -89,6 +89,8 @@ typedef struct _GC_FLAGS { bool numa; /* Use NUMA */ StgWord numaMask; + + StgWord64 addressSpaceSize; /* large address space size in bytes */ } GC_FLAGS; /* See Note [Synchronization of flags and base APIs] */ ===================================== rts/sm/MBlock.c ===================================== @@ -659,20 +659,14 @@ initMBlocks(void) #if defined(USE_LARGE_ADDRESS_SPACE) { - W_ size; -#if defined(aarch64_HOST_ARCH) - size = (W_)1 << 38; // 1/4 TByte -#else - size = (W_)1 << 40; // 1 TByte -#endif void *startAddress = NULL; if (RtsFlags.GcFlags.heapBase) { startAddress = (void*) RtsFlags.GcFlags.heapBase; } - void *addr = osReserveHeapMemory(startAddress, &size); + void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize); mblock_address_space.begin = (W_)addr; - mblock_address_space.end = (W_)addr + size; + mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize; mblock_high_watermark = (W_)addr; } #elif SIZEOF_VOID_P == 8 ===================================== testsuite/tests/primops/should_run/T24496.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) +{-# NOINLINE twoProductFloat# #-} + +twoProductDouble# :: Double# -> Double# -> (# Double#, Double# #) +twoProductDouble# x y = let !r = x *## y + in (# r, fmsubDouble# x y r #) +{-# NOINLINE twoProductDouble# #-} + +main :: IO () +main = do + print $ case twoProductFloat# 2.0# 3.0# of (# r, s #) -> (F# r, F# s) + print $ case twoProductDouble# 2.0## 3.0## of (# r, s #) -> (D# r, D# s) ===================================== testsuite/tests/primops/should_run/T24496.stdout ===================================== @@ -0,0 +1,2 @@ +(6.0,0.0) +(6.0,0.0) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -77,3 +77,10 @@ test('FMA_ConstantFold' test('T21624', normal, compile_and_run, ['']) test('T23071', ignore_stdout, compile_and_run, ['']) test('T22710', normal, compile_and_run, ['']) +test('T24496' + , [ when(have_cpu_feature('fma'), extra_hc_opts('-mfma')) + , js_skip # JS backend doesn't have an FMA implementation + , when(arch('wasm32'), skip) + , when(have_llvm(), extra_ways(["optllvm"])) + ] + , compile_and_run, ['-O']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -3,7 +3,7 @@ test('testblockalloc', compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'), + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'), when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/31be53b2c08f1fe1d53917aeb227a3b8c49bbcf4...fc22d8dcf40f4a4eb8d020d8c2d7b8c6eca23449 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/31be53b2c08f1fe1d53917aeb227a3b8c49bbcf4...fc22d8dcf40f4a4eb8d020d8c2d7b8c6eca23449 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 03:58:13 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Mon, 04 Mar 2024 22:58:13 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T23942 Message-ID: <65e69855778e_4bf909d06e3050434@gitlab.mail> Matthew Craven pushed new branch wip/T23942 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T23942 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 05:55:23 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 05 Mar 2024 00:55:23 -0500 Subject: [Git][ghc/ghc][wip/t24277] base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <65e6b3cbec212_4bf90d0a1dbc57012@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: ea65619c by Finley McIlwaine at 2024-03-04T21:54:57-08:00 base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Stack` and `GHC.Exts`. Also add an opaque exposed type for cost center ids, `CostCentreId`, with appropriate instances. Implements CLC proposal 235. Resolves #24277 - - - - - 11 changed files: - docs/users_guide/9.10.1-notes.rst - libraries/base/changelog.md - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -244,6 +244,12 @@ Runtime system constructors in scope and the levity of ``t`` is statically known, then the constraint ``DataToTag t`` can always be solved. +- The ``CostCentreId`` type and ``currentCallStackIds :: IO [CostCentreId]`` + function for getting the IDs of the cost centers on the current stack are now + exported from ``GHC.Exts``. In addition to those, the ``ccId`` and + ``ccsToIds`` functions for getting ``CostCentreId``s are also exported from + ``GHC.Stack`. + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Export `CostCentreId` from `GHC.Exts` and `GHC.Stack` + * Export `currentCallStackIds` from `GHC.Exts` and `GHC.Stack` + * Export `ccId` and `ccsToIds` from `GHC.Stack` + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -84,6 +84,8 @@ module GHC.Exts traceEvent, -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, ===================================== libraries/base/src/GHC/Stack.hs ===================================== @@ -18,6 +18,7 @@ module GHC.Stack (errorWithStackTrace, -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks CallStack, @@ -37,16 +38,19 @@ module GHC.Stack -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where -import GHC.Internal.Stack \ No newline at end of file +import GHC.Internal.Stack ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -24,6 +25,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +40,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO Word32 +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -5373,6 +5373,8 @@ module GHC.Exts where data Compact# type Constraint :: * type Constraint = CONSTRAINT LiftedRep + type CostCentreId :: * + newtype CostCentreId = ... type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint class DataToTag a where dataToTag# :: a -> Int# @@ -5758,6 +5760,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9305,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9314,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11557,6 +11565,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11641,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12024,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12136,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12210,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12257,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12434,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12632,6 +12647,7 @@ instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12813,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -5727,6 +5727,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -12344,6 +12345,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -12351,14 +12354,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -12380,14 +12386,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String @@ -14592,6 +14601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -14667,6 +14677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -15051,6 +15062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -15162,6 +15174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15235,6 +15248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15281,6 +15295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -15659,6 +15674,7 @@ instance GHC.Classes.Eq GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15824,6 +15840,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -5519,6 +5519,8 @@ module GHC.Exts where data Compact# type Constraint :: * type Constraint = CONSTRAINT LiftedRep + type CostCentreId :: * + newtype CostCentreId = ... type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint class DataToTag a where dataToTag# :: a -> Int# @@ -5907,6 +5909,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9526,6 +9529,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9533,14 +9538,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11821,6 +11829,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11897,6 +11906,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Enum.Enum GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12291,6 +12301,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12403,6 +12414,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Read.Read GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12476,6 +12488,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12522,6 +12535,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12695,6 +12709,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.ConsoleEvent.ConsoleE instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Event.Windows.CbResult a) -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12907,6 +12922,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Classes.Eq GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -13075,6 +13091,7 @@ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.I instance GHC.Classes.Ord GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Ord GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9303,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9312,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9338,14 +9344,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String @@ -11557,6 +11566,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11642,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12025,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12137,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12211,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12258,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12435,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12633,6 +12649,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12814,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea65619cfd34e30885c69dac1a4f83888ac0ab5d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea65619cfd34e30885c69dac1a4f83888ac0ab5d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 07:11:55 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 02:11:55 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: rts: add -xr option to control two step allocator reserved space size Message-ID: <65e6c5bbf164_4bf90f136c6c63749@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5bed33cb by Cheng Shao at 2024-03-05T02:11:46-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 7850f462 by Ben Gamari at 2024-03-05T02:11:47-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 996ec365 by Ben Gamari at 2024-03-05T02:11:47-05:00 os-string: Bump submodule to 2.0.2 - - - - - 8 changed files: - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - libraries/filepath - libraries/os-string - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/sm/MBlock.c - testsuite/tests/rts/all.T Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -232,6 +232,10 @@ Runtime system - Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. +- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual + memory address space reserved by the two step allocator on a 64-bit + platform. See :ghc-ticket:`24498`. + ``base`` library ~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -368,6 +368,18 @@ Miscellaneous RTS options thread can execute its exception handlers. The ``-xq`` controls the size of this additional quota. +.. rts-flag:: -xr ⟨size⟩ + + :default: 0.25T on aarch64, 1T otherwise + + This option controls the size of virtual memory address space + reserved by the two step allocator on a 64-bit platform. It can be + useful in scenarios where even reserving a large address range + without committing can be expensive (e.g. WSL1), or when you + actually have enough physical memory and want to support a Haskell + heap larger than 1T. ``-xr`` is a no-op if GHC is configured with + ``--disable-large-address-space`` or if the platform is 32-bit. + .. _rts-options-gc: RTS options to control the garbage collector ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 ===================================== rts/RtsFlags.c ===================================== @@ -186,6 +186,14 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.ringBell = false; RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */ +#if defined(aarch64_HOST_ARCH) + // 1/4 TBytes, see 38c98e4f for rationale + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 38; +#else + // 1 TBytes + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40; +#endif + RtsFlags.DebugFlags.scheduler = false; RtsFlags.DebugFlags.interpreter = false; RtsFlags.DebugFlags.weak = false; @@ -552,6 +560,11 @@ usage_text[] = { " -xq The allocation limit given to a thread after it receives", " an AllocationLimitExceeded exception. (default: 100k)", "", +#if defined(USE_LARGE_ADDRESS_SPACE) +" -xr The size of virtual memory address space reserved by the", +" two step allocator (default: 0.25T on aarch64, 1T otherwise)", +"", +#endif " -Mgrace=", " The amount of allocation after the program receives a", " HeapOverflow exception before the exception is thrown again, if", @@ -1820,6 +1833,12 @@ error = true; / BLOCK_SIZE; break; + case 'r': + OPTION_UNSAFE; + RtsFlags.GcFlags.addressSpaceSize + = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_INT_MAX); + break; + default: OPTION_SAFE; errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -2118,7 +2137,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) m = atof(s); c = s[strlen(s)-1]; - if (c == 'g' || c == 'G') + if (c == 't' || c == 'T') + m *= (StgWord64)1024*1024*1024*1024; + else if (c == 'g' || c == 'G') m *= 1024*1024*1024; else if (c == 'm' || c == 'M') m *= 1024*1024; @@ -2737,4 +2758,3 @@ doingErasProfiling( void ) || RtsFlags.ProfFlags.eraSelector != 0); } #endif /* PROFILING */ - ===================================== rts/include/rts/Flags.h ===================================== @@ -89,6 +89,8 @@ typedef struct _GC_FLAGS { bool numa; /* Use NUMA */ StgWord numaMask; + + StgWord64 addressSpaceSize; /* large address space size in bytes */ } GC_FLAGS; /* See Note [Synchronization of flags and base APIs] */ ===================================== rts/sm/MBlock.c ===================================== @@ -659,20 +659,14 @@ initMBlocks(void) #if defined(USE_LARGE_ADDRESS_SPACE) { - W_ size; -#if defined(aarch64_HOST_ARCH) - size = (W_)1 << 38; // 1/4 TByte -#else - size = (W_)1 << 40; // 1 TByte -#endif void *startAddress = NULL; if (RtsFlags.GcFlags.heapBase) { startAddress = (void*) RtsFlags.GcFlags.heapBase; } - void *addr = osReserveHeapMemory(startAddress, &size); + void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize); mblock_address_space.begin = (W_)addr; - mblock_address_space.end = (W_)addr + size; + mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize; mblock_high_watermark = (W_)addr; } #elif SIZEOF_VOID_P == 8 ===================================== testsuite/tests/rts/all.T ===================================== @@ -3,7 +3,7 @@ test('testblockalloc', compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'), + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'), when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc22d8dcf40f4a4eb8d020d8c2d7b8c6eca23449...996ec36554fd7b6fd5cbf74a96541e9f0cae10ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc22d8dcf40f4a4eb8d020d8c2d7b8c6eca23449...996ec36554fd7b6fd5cbf74a96541e9f0cae10ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 09:39:55 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 04:39:55 -0500 Subject: [Git][ghc/ghc][wip/eras-profiling-with-base] 89 commits: JS: add simple optimizer Message-ID: <65e6e86b9a2eb_3f00d94ec44c8419@gitlab.mail> Matthew Pickering pushed to branch wip/eras-profiling-with-base at Glasgow Haskell Compiler / GHC Commits: 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - cd24db4f by Matthew Pickering at 2024-03-05T09:39:23+00:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - 21 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b73832d82bb8baac79e4c58284526911f8c6773a...cd24db4fdc95a506aa0639422aec4e7c65145d79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b73832d82bb8baac79e4c58284526911f8c6773a...cd24db4fdc95a506aa0639422aec4e7c65145d79 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 09:42:10 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 04:42:10 -0500 Subject: [Git][ghc/ghc][wip/eras-profiling-with-base] base: Reflect new era profiling RTS flags in GHC.RTS.Flags Message-ID: <65e6e8f29bdf4_3f00d95d7244875e6@gitlab.mail> Matthew Pickering pushed to branch wip/eras-profiling-with-base at Glasgow Haskell Compiler / GHC Commits: 7ec4ac34 by Matthew Pickering at 2024-03-05T09:42:00+00:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - 5 changed files: - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Add `HeapByEra`, `eraSelector` and `automaticEraIncrement` to `GHC.RTS.Flags` to + reflect the new RTS flags: `-he` profiling mode, `-he` selector and `--automatic-era-increment`. + ([CLC proposal #254](https://github.com/haskell/core-libraries-committee/issues/254)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -274,6 +274,7 @@ data DoHeapProfile | HeapByLDV | HeapByClosureType | HeapByInfoTable + | HeapByEra -- ^ @since base-4.20.0.0 deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -289,6 +290,7 @@ instance Enum DoHeapProfile where fromEnum HeapByLDV = #{const HEAP_BY_LDV} fromEnum HeapByClosureType = #{const HEAP_BY_CLOSURE_TYPE} fromEnum HeapByInfoTable = #{const HEAP_BY_INFO_TABLE} + fromEnum HeapByEra = #{const HEAP_BY_ERA} toEnum #{const NO_HEAP_PROFILING} = NoHeapProfiling toEnum #{const HEAP_BY_CCS} = HeapByCCS @@ -299,6 +301,7 @@ instance Enum DoHeapProfile where toEnum #{const HEAP_BY_LDV} = HeapByLDV toEnum #{const HEAP_BY_CLOSURE_TYPE} = HeapByClosureType toEnum #{const HEAP_BY_INFO_TABLE} = HeapByInfoTable + toEnum #{const HEAP_BY_ERA} = HeapByEra toEnum e = errorWithoutStackTrace ("invalid enum for DoHeapProfile: " ++ show e) -- | Parameters of the cost-center profiler @@ -311,6 +314,7 @@ data ProfFlags = ProfFlags , startHeapProfileAtStartup :: Bool , startTimeProfileAtStartup :: Bool -- ^ @since base-4.20.0.0 , showCCSOnException :: Bool + , automaticEraIncrement :: Bool -- ^ @since 4.20.0.0 , maxRetainerSetSize :: Word , ccsLength :: Word , modSelector :: Maybe String @@ -320,6 +324,7 @@ data ProfFlags = ProfFlags , ccsSelector :: Maybe String , retainerSelector :: Maybe String , bioSelector :: Maybe String + , eraSelector :: Word -- ^ @since base-4.20.0.0 } deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -633,6 +638,8 @@ getProfFlags = do (#{peek PROFILING_FLAGS, startTimeProfileAtStartup} ptr :: IO CBool)) <*> (toBool <$> (#{peek PROFILING_FLAGS, showCCSOnException} ptr :: IO CBool)) + <*> (toBool <$> + (#{peek PROFILING_FLAGS, incrementUserEra} ptr :: IO CBool)) <*> #{peek PROFILING_FLAGS, maxRetainerSetSize} ptr <*> #{peek PROFILING_FLAGS, ccsLength} ptr <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, modSelector} ptr) @@ -642,6 +649,7 @@ getProfFlags = do <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, ccsSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, retainerSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, bioSelector} ptr) + <*> #{peek PROFILING_FLAGS, eraSelector} ptr getTraceFlags :: IO TraceFlags getTraceFlags = do ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9088,7 +9088,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -12071,7 +12071,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -12130,7 +12130,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -9253,7 +9253,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9312,7 +9312,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ec4ac341f1ee271a9f27666b6608326cb765c74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ec4ac341f1ee271a9f27666b6608326cb765c74 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 10:12:27 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 05:12:27 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: rts: add -xr option to control two step allocator reserved space size Message-ID: <65e6f00b9e0c7_3f00d9142f42c99124@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1bc4e7ab by Cheng Shao at 2024-03-05T05:12:05-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 48325bf7 by Ben Gamari at 2024-03-05T05:12:06-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 2254cd78 by Ben Gamari at 2024-03-05T05:12:06-05:00 os-string: Bump submodule to 2.0.2 - - - - - 8 changed files: - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - libraries/filepath - libraries/os-string - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/sm/MBlock.c - testsuite/tests/rts/all.T Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -232,6 +232,10 @@ Runtime system - Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. +- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual + memory address space reserved by the two step allocator on a 64-bit + platform. See :ghc-ticket:`24498`. + ``base`` library ~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -368,6 +368,18 @@ Miscellaneous RTS options thread can execute its exception handlers. The ``-xq`` controls the size of this additional quota. +.. rts-flag:: -xr ⟨size⟩ + + :default: 0.25T on aarch64, 1T otherwise + + This option controls the size of virtual memory address space + reserved by the two step allocator on a 64-bit platform. It can be + useful in scenarios where even reserving a large address range + without committing can be expensive (e.g. WSL1), or when you + actually have enough physical memory and want to support a Haskell + heap larger than 1T. ``-xr`` is a no-op if GHC is configured with + ``--disable-large-address-space`` or if the platform is 32-bit. + .. _rts-options-gc: RTS options to control the garbage collector ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 ===================================== rts/RtsFlags.c ===================================== @@ -186,6 +186,14 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.ringBell = false; RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */ +#if defined(aarch64_HOST_ARCH) + // 1/4 TBytes, see 38c98e4f for rationale + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 38; +#else + // 1 TBytes + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40; +#endif + RtsFlags.DebugFlags.scheduler = false; RtsFlags.DebugFlags.interpreter = false; RtsFlags.DebugFlags.weak = false; @@ -552,6 +560,11 @@ usage_text[] = { " -xq The allocation limit given to a thread after it receives", " an AllocationLimitExceeded exception. (default: 100k)", "", +#if defined(USE_LARGE_ADDRESS_SPACE) +" -xr The size of virtual memory address space reserved by the", +" two step allocator (default: 0.25T on aarch64, 1T otherwise)", +"", +#endif " -Mgrace=", " The amount of allocation after the program receives a", " HeapOverflow exception before the exception is thrown again, if", @@ -1820,6 +1833,12 @@ error = true; / BLOCK_SIZE; break; + case 'r': + OPTION_UNSAFE; + RtsFlags.GcFlags.addressSpaceSize + = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_INT_MAX); + break; + default: OPTION_SAFE; errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -2118,7 +2137,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) m = atof(s); c = s[strlen(s)-1]; - if (c == 'g' || c == 'G') + if (c == 't' || c == 'T') + m *= (StgWord64)1024*1024*1024*1024; + else if (c == 'g' || c == 'G') m *= 1024*1024*1024; else if (c == 'm' || c == 'M') m *= 1024*1024; @@ -2737,4 +2758,3 @@ doingErasProfiling( void ) || RtsFlags.ProfFlags.eraSelector != 0); } #endif /* PROFILING */ - ===================================== rts/include/rts/Flags.h ===================================== @@ -89,6 +89,8 @@ typedef struct _GC_FLAGS { bool numa; /* Use NUMA */ StgWord numaMask; + + StgWord64 addressSpaceSize; /* large address space size in bytes */ } GC_FLAGS; /* See Note [Synchronization of flags and base APIs] */ ===================================== rts/sm/MBlock.c ===================================== @@ -659,20 +659,14 @@ initMBlocks(void) #if defined(USE_LARGE_ADDRESS_SPACE) { - W_ size; -#if defined(aarch64_HOST_ARCH) - size = (W_)1 << 38; // 1/4 TByte -#else - size = (W_)1 << 40; // 1 TByte -#endif void *startAddress = NULL; if (RtsFlags.GcFlags.heapBase) { startAddress = (void*) RtsFlags.GcFlags.heapBase; } - void *addr = osReserveHeapMemory(startAddress, &size); + void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize); mblock_address_space.begin = (W_)addr; - mblock_address_space.end = (W_)addr + size; + mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize; mblock_high_watermark = (W_)addr; } #elif SIZEOF_VOID_P == 8 ===================================== testsuite/tests/rts/all.T ===================================== @@ -3,7 +3,7 @@ test('testblockalloc', compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'), + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'), when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/996ec36554fd7b6fd5cbf74a96541e9f0cae10ca...2254cd78e793065c4eb8490321d6904bf7f1be2f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/996ec36554fd7b6fd5cbf74a96541e9f0cae10ca...2254cd78e793065c4eb8490321d6904bf7f1be2f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 10:35:30 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 05:35:30 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 14 commits: add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e6f5726078f_3f00d921e4a2c110951@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - ecc35ffc by Matthew Pickering at 2024-03-05T10:20:49+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage2 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage2 package database. * Stage 2 cross compilers need to use stage3 libraries, so likewise, we should set to stage * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. - - - - - 2de8f171 by Matthew Pickering at 2024-03-05T10:20:49+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 0ab114b6 by Matthew Pickering at 2024-03-05T10:20:49+00:00 Add missing req_interp modifier to T18441fail3 and T18441fail19 These tests require the interpreter but they were failing in a different way with the javascript backend because the interpreter was disabled and stderr is ignored by the test. - - - - - 0efa8c8b by Matthew Pickering at 2024-03-05T10:20:49+00:00 Use explicit syntax rather than pure - - - - - fcd3f900 by Matthew Pickering at 2024-03-05T10:20:49+00:00 ci: Fail when bindist configure fails when installing bindist It is better to fail earlier if the configure step fails rather than carrying on for a more obscure error message. - - - - - bc787bb0 by Matthew Pickering at 2024-03-05T10:20:49+00:00 packaging: correctly propagate build/host/target to bindist configure script At the moment the host and target which we will produce a compiler for is fixed at the initial configure time. Therefore we need to persist the choice made at this time into the installation bindist as well so we look for the right tools, with the right prefixes at install time. In the future, we want to provide a bit more control about what kind of bindist we produce so the logic about what the host/target will have to be written by hadrian rather than persisted by the configure script. In particular with cross compilers we want to either build a normal stage 2 cross bindist or a stage 3 bindist, which creates a bindist which has a native compiler for the target platform. Fixes #21970 - - - - - ded9f536 by Matthew Pickering at 2024-03-05T10:20:49+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - 42d26a43 by Matthew Pickering at 2024-03-05T10:20:49+00:00 hadrian: Disable docs when cross compiling Before there were a variety of ad-hoc places where doc building was disabled when cross compiling. * Some CI jobs sets --docs=none in gen_ci.hs * Some CI jobs set --docs=none in .gitlab/ci.sh * There was some logic in hadrian to not need the ["docs"] target when making a bindist. Now the situation is simple: * If you are cross compiling then defaultDocsTargets is empty by default. In theory, there is no reason why we can't build documentation for cross compiler bindists, but this is left to future work to generalise the documentation building rules to allow this (#24289) - - - - - 236d1a2f by Matthew Pickering at 2024-03-05T10:24:40+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 29759eef by Matthew Pickering at 2024-03-05T10:24:40+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - 5449f5b0 by Matthew Pickering at 2024-03-05T10:24:40+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 69d8b51b by Matthew Pickering at 2024-03-05T10:24:40+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - configure.ac - distrib/configure.ac.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/hadrian.cabal - + hadrian/src/BindistConfig.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78f3bbdc0b305fc29aff6dc6ee77359f50603ae5...69d8b51b500b8b879413feb552c1b7bd9125e120 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78f3bbdc0b305fc29aff6dc6ee77359f50603ae5...69d8b51b500b8b879413feb552c1b7bd9125e120 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 10:43:42 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 05:43:42 -0500 Subject: [Git][ghc/ghc][wip/is-cross] 216 commits: Always refresh profiling CCSes after running pending initializers Message-ID: <65e6f75edff41_3f00d9231683c11494f@gitlab.mail> Matthew Pickering pushed to branch wip/is-cross at Glasgow Haskell Compiler / GHC Commits: 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - ef58d767 by Matthew Pickering at 2024-03-05T10:43:17+00:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 18 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitmodules - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e68e2c2908eec11f0403d6dfd1de459d4a0bdbf5...ef58d767728ef98e060771d32ee69cdfd71b0f39 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e68e2c2908eec11f0403d6dfd1de459d4a0bdbf5...ef58d767728ef98e060771d32ee69cdfd71b0f39 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 10:44:42 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 05:44:42 -0500 Subject: [Git][ghc/ghc][wip/is-cross] testsuite: Rename isCross() predicate to needsTargetWrapper() Message-ID: <65e6f79a8e85f_3f00d9242b6dc115487@gitlab.mail> Matthew Pickering pushed to branch wip/is-cross at Glasgow Haskell Compiler / GHC Commits: f20a6dfa by Matthew Pickering at 2024-03-05T10:44:30+00:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 2 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -182,8 +182,6 @@ class TestConfig: self.threads = 1 # An optional executable used to wrap target code execution - # When set tests which aren't marked with TestConfig.cross_okay - # are skipped. self.target_wrapper = None # tests which should be considered to be broken during this testsuite @@ -460,12 +458,6 @@ class TestOptions: # Should we copy the files of symlink the files for the test? self.copy_files = False - # Should the test be run in a cross-compiled tree? - # None: infer from test function - # True: run when --target-wrapper is set - # False: do not run in cross-compiled trees - self.cross_okay = None # type: Optional[bool] - # The extra hadrian dependencies we need for this particular test self.hadrian_deps = set(["test:ghc"]) # type: Set[str] ===================================== testsuite/driver/testlib.py ===================================== @@ -91,8 +91,8 @@ def setLocalTestOpts(opts: TestOptions) -> None: global testopts_ctx_var testopts_ctx_var.set(opts) -def isCross() -> bool: - """ Are we testing a cross-compiler? """ +def needsTargetWrapper() -> bool: + """ Do we need to use a target wrapper? """ return config.target_wrapper is not None def isCompilerStatsTest() -> bool: @@ -240,7 +240,7 @@ def req_dynamic_hs( name, opts ): opts.expect = 'fail' def req_interp( name, opts ): - if not config.have_interp or isCross(): + if not config.have_interp or needsTargetWrapper(): opts.expect = 'fail' # skip on wasm32, otherwise they show up as unexpected passes if arch('wasm32'): @@ -346,11 +346,10 @@ def req_host_target_ghc( name, opts ): """ When testing a cross GHC, some test cases require a host GHC as well (e.g. for compiling custom Setup.hs). This is not supported yet (#23236), so for - the time being we skip them when testing cross GHCs. However, this is not - the case for the JS backend. The JS backend is a cross-compiler that - produces code that the host can run. + the time being we skip them when testing cross GHCs. However, for cross targets + which don't need a target wrapper (e.g. javascript), we can still run these testcases. """ - if isCross() and not js_arch(): + if hasTargetWrapper(): opts.skip = True has_ls_files = None @@ -1290,21 +1289,18 @@ async def test_common_work(name: TestName, opts, all_ways = [WayName('ghci'), WayName('ghci-opt')] else: all_ways = [] - if isCross(): - opts.cross_okay = False + if needsTargetWrapper(): + opts.skip = True elif func in [makefile_test, run_command]: # makefile tests aren't necessarily runtime or compile-time # specific. Assume we can run them in all ways. See #16042 for what # happened previously. all_ways = config.compile_ways + config.run_ways - if isCross(): - opts.cross_okay = False + if needsTargetWrapper(): + opts.skip = True else: all_ways = [WayName('normal')] - if isCross() and opts.cross_okay is False: - opts.skip = True - # A test itself can request extra ways by setting opts.extra_ways all_ways = list(OrderedDict.fromkeys(all_ways + [way for way in opts.extra_ways if way not in all_ways])) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f20a6dfaf0afab5647916ff0c242121ac5321609 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f20a6dfaf0afab5647916ff0c242121ac5321609 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 10:59:58 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 05:59:58 -0500 Subject: [Git][ghc/ghc][wip/global-package-db] 4 commits: add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e6fb2ec4512_3f00d930527301222bb@gitlab.mail> Matthew Pickering pushed to branch wip/global-package-db at Glasgow Haskell Compiler / GHC Commits: 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 5d441f0a by Matthew Pickering at 2024-03-05T10:57:55+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 8e3cb48c by Matthew Pickering at 2024-03-05T10:58:29+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - hadrian/bindist/Makefile - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - libraries/ghc-boot/GHC/Settings/Utils.hs - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a9a06debfc3acf933734c0b0e681e92e928e899...8e3cb48ce42cfd6ea83528ae70df486e011bb017 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a9a06debfc3acf933734c0b0e681e92e928e899...8e3cb48ce42cfd6ea83528ae70df486e011bb017 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 11:02:31 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 06:02:31 -0500 Subject: [Git][ghc/ghc][wip/is-cross] testsuite: Rename isCross() predicate to needsTargetWrapper() Message-ID: <65e6fbc7233a1_3f00d932f1a7c128272@gitlab.mail> Matthew Pickering pushed to branch wip/is-cross at Glasgow Haskell Compiler / GHC Commits: 66e5e45a by Matthew Pickering at 2024-03-05T11:02:19+00:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 2 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -182,8 +182,6 @@ class TestConfig: self.threads = 1 # An optional executable used to wrap target code execution - # When set tests which aren't marked with TestConfig.cross_okay - # are skipped. self.target_wrapper = None # tests which should be considered to be broken during this testsuite @@ -460,12 +458,6 @@ class TestOptions: # Should we copy the files of symlink the files for the test? self.copy_files = False - # Should the test be run in a cross-compiled tree? - # None: infer from test function - # True: run when --target-wrapper is set - # False: do not run in cross-compiled trees - self.cross_okay = None # type: Optional[bool] - # The extra hadrian dependencies we need for this particular test self.hadrian_deps = set(["test:ghc"]) # type: Set[str] ===================================== testsuite/driver/testlib.py ===================================== @@ -91,8 +91,8 @@ def setLocalTestOpts(opts: TestOptions) -> None: global testopts_ctx_var testopts_ctx_var.set(opts) -def isCross() -> bool: - """ Are we testing a cross-compiler? """ +def needsTargetWrapper() -> bool: + """ Do we need to use a target wrapper? """ return config.target_wrapper is not None def isCompilerStatsTest() -> bool: @@ -240,7 +240,7 @@ def req_dynamic_hs( name, opts ): opts.expect = 'fail' def req_interp( name, opts ): - if not config.have_interp or isCross(): + if not config.have_interp or needsTargetWrapper(): opts.expect = 'fail' # skip on wasm32, otherwise they show up as unexpected passes if arch('wasm32'): @@ -346,11 +346,10 @@ def req_host_target_ghc( name, opts ): """ When testing a cross GHC, some test cases require a host GHC as well (e.g. for compiling custom Setup.hs). This is not supported yet (#23236), so for - the time being we skip them when testing cross GHCs. However, this is not - the case for the JS backend. The JS backend is a cross-compiler that - produces code that the host can run. + the time being we skip them when testing cross GHCs. However, for cross targets + which don't need a target wrapper (e.g. javascript), we can still run these testcases. """ - if isCross() and not js_arch(): + if needsTargetWrapper(): opts.skip = True has_ls_files = None @@ -1290,21 +1289,18 @@ async def test_common_work(name: TestName, opts, all_ways = [WayName('ghci'), WayName('ghci-opt')] else: all_ways = [] - if isCross(): - opts.cross_okay = False + if needsTargetWrapper(): + opts.skip = True elif func in [makefile_test, run_command]: # makefile tests aren't necessarily runtime or compile-time # specific. Assume we can run them in all ways. See #16042 for what # happened previously. all_ways = config.compile_ways + config.run_ways - if isCross(): - opts.cross_okay = False + if needsTargetWrapper(): + opts.skip = True else: all_ways = [WayName('normal')] - if isCross() and opts.cross_okay is False: - opts.skip = True - # A test itself can request extra ways by setting opts.extra_ways all_ways = list(OrderedDict.fromkeys(all_ways + [way for way in opts.extra_ways if way not in all_ways])) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66e5e45a745695ebf5b3fa01bad26dc467d33857 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66e5e45a745695ebf5b3fa01bad26dc467d33857 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 12:27:10 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 07:27:10 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-alpine-aarch64 Message-ID: <65e70f9e2208_3f00d957470701503a7@gitlab.mail> Matthew Pickering pushed new branch wip/bump-alpine-aarch64 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-alpine-aarch64 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 13:16:48 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 05 Mar 2024 08:16:48 -0500 Subject: [Git][ghc/ghc][wip/exception-context] 14 commits: compiler: start deprecating cmmToRawCmmHook Message-ID: <65e71b408040c_3f00d96dca9b41696c6@gitlab.mail> Ben Gamari pushed to branch wip/exception-context at Glasgow Haskell Compiler / GHC Commits: 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - e1468888 by Ben Gamari at 2024-03-05T08:16:41-05:00 Bump array submodule - - - - - ccb842af by Ben Gamari at 2024-03-05T08:16:41-05:00 Bump stm submodule - - - - - cc5cfe7e by Ben Gamari at 2024-03-05T08:16:41-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 868368d8 by Ben Gamari at 2024-03-05T08:16:41-05:00 testsuite/interface-stability: Update documentation - - - - - 6a74cfb5 by Ben Gamari at 2024-03-05T08:16:41-05:00 ghc-internal: comment formatting - - - - - 6879d943 by Ben Gamari at 2024-03-05T08:16:41-05:00 compiler: Default and warn ExceptionContext constraints - - - - - a75706f6 by Ben Gamari at 2024-03-05T08:16:41-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 1772a3f2 by Ben Gamari at 2024-03-05T08:16:41-05:00 users guide: Release notes for exception backtrace work - - - - - 1d6ce21d by Ben Gamari at 2024-03-05T08:16:42-05:00 ghc-experimental: Add dummy dependencies to work around #24436 This is a temporary measure to improve CI reliability until a proper solution is developed. - - - - - 6049c291 by Ben Gamari at 2024-03-05T08:16:42-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/profiling.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5dcc5481a48f55d95ed12114e8eb31b405ec8039...6049c29119e98fe7155e70d3384f48ed7c8104ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5dcc5481a48f55d95ed12114e8eb31b405ec8039...6049c29119e98fe7155e70d3384f48ed7c8104ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 13:24:05 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 05 Mar 2024 08:24:05 -0500 Subject: [Git][ghc/ghc][wip/T24471] 4 commits: add -fprof-late-overloaded and -fprof-late-overloaded-calls Message-ID: <65e71cf5b8517_3f00d96f704f81722ee@gitlab.mail> Ben Gamari pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - afb90d4c by Ben Gamari at 2024-03-05T08:22:58-05:00 ghc-experimental: Add dummy dependencies to work around #24436 This is a temporary measure to improve CI reliability until a proper solution is developed. - - - - - 427a7d2e by Simon Peyton Jones at 2024-03-05T08:23:23-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 3.5%, and much more in artificial cases. Metric Decrease: CoOpt_Read T12425 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/profiling.rst - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - + testsuite/tests/primops/should_run/T24496.hs - + testsuite/tests/primops/should_run/T24496.stdout - testsuite/tests/primops/should_run/all.T - testsuite/tests/profiling/should_run/all.T - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls001.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.hs - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.prof.sample - + testsuite/tests/profiling/should_run/scc-prof-overloaded-calls002.stdout - + testsuite/tests/profiling/should_run/scc-prof-overloaded001.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd5073c699a3b4d2583437094683ac13f9f088da...427a7d2e6175b972773ad9a43580a98e0c9e95de -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd5073c699a3b4d2583437094683ac13f9f088da...427a7d2e6175b972773ad9a43580a98e0c9e95de You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 14:12:32 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 09:12:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e7285025a9d_3f00d98bb62c018893e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 11ccf8d4 by Matthew Pickering at 2024-03-05T09:12:24-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - 9f8b4ddf by Matthew Pickering at 2024-03-05T09:12:24-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 841aad2e by Matthew Pickering at 2024-03-05T09:12:24-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 7c2fe093 by Matthew Pickering at 2024-03-05T09:12:24-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2ec4d32e by Ben Gamari at 2024-03-05T09:12:24-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 5472fdf1 by Ben Gamari at 2024-03-05T09:12:24-05:00 os-string: Bump submodule to 2.0.2 - - - - - 10 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/filepath - libraries/ghc-experimental/src/GHC/Profiling/Eras.hs - libraries/ghc-internal/ghc-internal.cabal - libraries/os-string Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -1031,7 +1031,7 @@ job_groups = -- (see Note [Object unloading]). fullyStaticBrokenTests = modifyJobs (addVariable "BROKEN_TESTS" "ghcilink002 linker_unload_native") - hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-base-url") + hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-for-hackage") tsan_jobs = modifyJobs ===================================== .gitlab/jobs.yaml ===================================== @@ -2330,7 +2330,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url", + "HADRIAN_ARGS": "--haddock-for-hackage", "LLC": "/bin/false", "OPT": "/bin/false", "RUNTEST_ARGS": "", @@ -4007,7 +4007,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url --hash-unit-ids", + "HADRIAN_ARGS": "--haddock-for-hackage --hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "LLC": "/bin/false", "OPT": "/bin/false", ===================================== .gitlab/rel_eng/upload_ghc_libs.py ===================================== @@ -49,6 +49,10 @@ def prep_base(): shutil.copy('config.guess', 'libraries/base') shutil.copy('config.sub', 'libraries/base') +def prep_ghc_internal(): + shutil.copy('config.guess', 'libraries/ghc-internal') + shutil.copy('config.sub', 'libraries/ghc-internal') + def build_copy_file(pkg: Package, f: Path): target = Path('_build') / 'stage1' / pkg.path / 'build' / f dest = pkg.path / f @@ -93,6 +97,8 @@ PACKAGES = { pkg.name: pkg for pkg in [ Package('base', Path("libraries/base"), prep_base), + Package('ghc-internal', Path("libraries/ghc-internal"), prep_ghc_internal), + Package('ghc-experimental', Path("libraries/ghc-experimental"), no_prep), Package('ghc-prim', Path("libraries/ghc-prim"), prep_ghc_prim), Package('integer-gmp', Path("libraries/integer-gmp"), no_prep), Package('ghc-bignum', Path("libraries/ghc-bignum"), prep_ghc_bignum), ===================================== hadrian/README.md ===================================== @@ -306,9 +306,9 @@ all of the documentation targets: You can pass several `--docs=...` flags, Hadrian will combine their effects. -To build haddock documentation for upload to hackage you need to pass the `--haddock-base-url` flag, -by default this will choose a url suitable for uploading to hackage but you might also want to pass something like -`http://127.0.0.1:8080/package/%pkg%/docs` for testing upload locally on a local hackage server. +To build haddock documentation for upload to hackage you need to pass the `--haddock-for-hackage` flag, +This will generate URLs which are appropiate for either uploading to a local hackage +server or the global hackage server. #### Source distribution ===================================== hadrian/src/CommandLine.hs ===================================== @@ -17,7 +17,6 @@ import System.Environment import qualified System.Directory as Directory import qualified Data.Set as Set -import Data.Maybe data TestSpeed = TestSlow | TestNormal | TestFast deriving (Show, Eq) @@ -114,7 +113,7 @@ data DocArgs = DocArgs } deriving (Eq, Show) defaultDocArgs :: DocArgs -defaultDocArgs = DocArgs { docsBaseUrl = "../%pkg%" } +defaultDocArgs = DocArgs { docsBaseUrl = "../%pkgid%" } readConfigure :: Either String (CommandLineArgs -> CommandLineArgs) readConfigure = Left "hadrian --configure has been deprecated (see #20167). Please run ./boot; ./configure manually" @@ -192,11 +191,11 @@ readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testO readTestSkipPerf :: Either String (CommandLineArgs -> CommandLineArgs) readTestSkipPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testSkipPerf = True } } -readHaddockBaseUrl :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) -readHaddockBaseUrl base_url = Right $ \flags -> - flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url' } } +readHaddockBaseUrl :: Either String (CommandLineArgs -> CommandLineArgs) +readHaddockBaseUrl = Right $ \flags -> + flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url } } - where base_url' = fromMaybe "https://hackage.haskell.org/package/%pkg%/docs" base_url + where base_url = "/package/%pkg%/docs" readTestRootDirs :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) @@ -320,8 +319,8 @@ optDescrs = "Destination path for the bindist 'install' rule" , Option [] ["complete-setting"] (OptArg readCompleteStg "SETTING") "Setting key to autocomplete, for the 'autocomplete' target." - , Option [] ["haddock-base-url"] (OptArg readHaddockBaseUrl "BASE_URL") - "Generate documentation suitable for upload to hackage or for another base URL (for example a local hackage server)." + , Option [] ["haddock-for-hackage"] (NoArg readHaddockBaseUrl) + "Generate documentation suitable for upload to a hackage server." ] -- | A type-indexed map containing Hadrian command line arguments to be passed ===================================== hadrian/src/Settings/Builders/Haddock.hs ===================================== @@ -43,12 +43,15 @@ haddockBuilderArgs = mconcat version <- expr $ pkgVersion pkg synopsis <- expr $ pkgSynopsis pkg haddocks <- expr $ haddockDependencies context - haddocks_with_versions <- expr $ sequence $ [(,h) <$> pkgUnitId stage p | (p, h) <- haddocks] + haddocks_with_versions <- expr $ sequence $ [(,,h) <$> pkgSimpleIdentifier p <*> pkgUnitId stage p | (p, h) <- haddocks] hVersion <- expr $ pkgVersion haddock statsDir <- expr $ haddockStatsFilesDir baseUrlTemplate <- expr (docsBaseUrl <$> userSetting defaultDocArgs) - let baseUrl p = substituteTemplate baseUrlTemplate p + -- The path to where the docs for a package are + let docpath p = substituteTemplate baseUrlTemplate p + -- The path to where the src folder is for a package (typically docs ++ "/src/") + let srcpath p = docpath p ++ "/src/" ghcOpts <- haddockGhcArgs -- These are the options which are necessary to perform the build. Additional -- options such as `--hyperlinked-source`, `--hoogle`, `--quickjump` are @@ -67,14 +70,18 @@ haddockBuilderArgs = mconcat , arg $ "--optghc=-D__HADDOCK_VERSION__=" ++ show (versionToInt hVersion) , map ("--hide=" ++) <$> getContextData otherModules - , pure [ "--read-interface=../" ++ p - ++ "," ++ baseUrl p ++ "/src/%{MODULE}.html#%{NAME}," - ++ haddock | (p, haddock) <- haddocks_with_versions ] + , pure [ "--read-interface=" ++ docpath (p, pid) + ++ "," ++ srcpath (p, pid) ++ "," + ++ haddock | (p, pid, haddock) <- haddocks_with_versions ] , pure [ "--optghc=" ++ opt | opt <- ghcOpts, not ("--package-db" `isInfixOf` opt) ] , arg "+RTS" , arg $ "-t" ++ (statsDir -/- pkgName pkg ++ ".t") , arg "--machine-readable" , arg "-RTS" ] ] -substituteTemplate :: String -> String -> String -substituteTemplate baseTemplate pkgId = T.unpack . T.replace "%pkg%" (T.pack pkgId) . T.pack $ baseTemplate +substituteTemplate :: String -> (String, String) -> String +substituteTemplate baseTemplate (pkg, pkgId) = + T.unpack + . T.replace "%pkg%" (T.pack pkg) + . T.replace "%pkgid%" (T.pack pkgId) + . T.pack $ baseTemplate ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/ghc-experimental/src/GHC/Profiling/Eras.hs ===================================== @@ -1,7 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} --- | TODO move this module into ghc-internals module GHC.Profiling.Eras ( setUserEra , getUserEra , incrementUserEra ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -17,7 +17,7 @@ description: extra-tmp-files: autom4te.cache - base.buildinfo + ghc-internal.buildinfo config.log config.status include/EventConfig.h @@ -25,8 +25,8 @@ extra-tmp-files: extra-source-files: aclocal.m4 - base.buildinfo.in - changelog.md + ghc-internal.buildinfo.in + CHANGELOG.md configure configure.ac include/CTypes.h ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2254cd78e793065c4eb8490321d6904bf7f1be2f...5472fdf1fe1fc502ca16fe30a1d80ffa68d0c9cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2254cd78e793065c4eb8490321d6904bf7f1be2f...5472fdf1fe1fc502ca16fe30a1d80ffa68d0c9cc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 14:20:49 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 05 Mar 2024 09:20:49 -0500 Subject: [Git][ghc/ghc][wip/t24277] base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <65e72a416fc3e_3f00d98d0cc7819588c@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: 91c6bb55 by Finley McIlwaine at 2024-03-05T06:20:30-08:00 base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Stack` and `GHC.Exts`. Also add an opaque exposed type for cost center ids, `CostCentreId`, with appropriate instances. Implements CLC proposal 235. Resolves #24277 - - - - - 11 changed files: - docs/users_guide/9.10.1-notes.rst - libraries/base/changelog.md - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -244,6 +244,12 @@ Runtime system constructors in scope and the levity of ``t`` is statically known, then the constraint ``DataToTag t`` can always be solved. +- The ``CostCentreId`` type and ``currentCallStackIds :: IO [CostCentreId]`` + function for getting the IDs of the cost centers on the current stack are now + exported from ``GHC.Exts``. In addition to those, the ``ccId`` and + ``ccsToIds`` functions for getting ``CostCentreId``\s are also exported from + ``GHC.Stack`. + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Export `CostCentreId` from `GHC.Exts` and `GHC.Stack` + * Export `currentCallStackIds` from `GHC.Exts` and `GHC.Stack` + * Export `ccId` and `ccsToIds` from `GHC.Stack` + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -84,6 +84,8 @@ module GHC.Exts traceEvent, -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, ===================================== libraries/base/src/GHC/Stack.hs ===================================== @@ -18,6 +18,7 @@ module GHC.Stack (errorWithStackTrace, -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks CallStack, @@ -37,16 +38,19 @@ module GHC.Stack -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where -import GHC.Internal.Stack \ No newline at end of file +import GHC.Internal.Stack ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -24,6 +25,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +40,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO Word32 +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -5373,6 +5373,8 @@ module GHC.Exts where data Compact# type Constraint :: * type Constraint = CONSTRAINT LiftedRep + type CostCentreId :: * + newtype CostCentreId = ... type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint class DataToTag a where dataToTag# :: a -> Int# @@ -5758,6 +5760,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9305,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9314,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11557,6 +11565,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11641,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12024,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12136,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12210,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12257,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12434,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12632,6 +12647,7 @@ instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12813,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -5727,6 +5727,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -12344,6 +12345,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -12351,14 +12354,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -12380,14 +12386,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String @@ -14592,6 +14601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -14667,6 +14677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -15051,6 +15062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -15162,6 +15174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15235,6 +15248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15281,6 +15295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -15659,6 +15674,7 @@ instance GHC.Classes.Eq GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15824,6 +15840,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -5519,6 +5519,8 @@ module GHC.Exts where data Compact# type Constraint :: * type Constraint = CONSTRAINT LiftedRep + type CostCentreId :: * + newtype CostCentreId = ... type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint class DataToTag a where dataToTag# :: a -> Int# @@ -5907,6 +5909,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9526,6 +9529,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9533,14 +9538,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11821,6 +11829,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11897,6 +11906,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Enum.Enum GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12291,6 +12301,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12403,6 +12414,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Read.Read GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12476,6 +12488,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12522,6 +12535,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12695,6 +12709,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.ConsoleEvent.ConsoleE instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Event.Windows.CbResult a) -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12907,6 +12922,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Classes.Eq GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -13075,6 +13091,7 @@ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.I instance GHC.Classes.Ord GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Ord GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9303,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9312,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9338,14 +9344,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String @@ -11557,6 +11566,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11642,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12025,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12137,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12211,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12258,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12435,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12633,6 +12649,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12814,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91c6bb55a937d97bf9647e0d89f80c93464b5123 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91c6bb55a937d97bf9647e0d89f80c93464b5123 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 14:32:18 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 05 Mar 2024 09:32:18 -0500 Subject: [Git][ghc/ghc][wip/T24471] Three compile perf improvements with deep nesting Message-ID: <65e72cf299a8f_28e20e4275d428665@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 557ac3d9 by Simon Peyton Jones at 2024-03-05T14:32:01+00:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 3.5%, and much more in artificial cases. Metric Decrease: CoOpt_Read T12425 - - - - - 6 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [ collect_compiler_stats('all', 5) ], + multimod_compile, ['T24471', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/557ac3d9646c37baf627e784cf078bf9cb866f6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/557ac3d9646c37baf627e784cf078bf9cb866f6f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 17:18:29 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 05 Mar 2024 12:18:29 -0500 Subject: [Git][ghc/ghc][wip/eras-profiling-with-base] base: Reflect new era profiling RTS flags in GHC.RTS.Flags Message-ID: <65e753e518221_28e20e508258c930fd@gitlab.mail> Matthew Pickering pushed to branch wip/eras-profiling-with-base at Glasgow Haskell Compiler / GHC Commits: 6c76be87 by Matthew Pickering at 2024-03-05T17:18:20+00:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - 6 changed files: - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Add `HeapByEra`, `eraSelector` and `automaticEraIncrement` to `GHC.RTS.Flags` to + reflect the new RTS flags: `-he` profiling mode, `-he` selector and `--automatic-era-increment`. + ([CLC proposal #254](https://github.com/haskell/core-libraries-committee/issues/254)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -274,6 +274,7 @@ data DoHeapProfile | HeapByLDV | HeapByClosureType | HeapByInfoTable + | HeapByEra -- ^ @since base-4.20.0.0 deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -289,6 +290,7 @@ instance Enum DoHeapProfile where fromEnum HeapByLDV = #{const HEAP_BY_LDV} fromEnum HeapByClosureType = #{const HEAP_BY_CLOSURE_TYPE} fromEnum HeapByInfoTable = #{const HEAP_BY_INFO_TABLE} + fromEnum HeapByEra = #{const HEAP_BY_ERA} toEnum #{const NO_HEAP_PROFILING} = NoHeapProfiling toEnum #{const HEAP_BY_CCS} = HeapByCCS @@ -299,6 +301,7 @@ instance Enum DoHeapProfile where toEnum #{const HEAP_BY_LDV} = HeapByLDV toEnum #{const HEAP_BY_CLOSURE_TYPE} = HeapByClosureType toEnum #{const HEAP_BY_INFO_TABLE} = HeapByInfoTable + toEnum #{const HEAP_BY_ERA} = HeapByEra toEnum e = errorWithoutStackTrace ("invalid enum for DoHeapProfile: " ++ show e) -- | Parameters of the cost-center profiler @@ -311,6 +314,7 @@ data ProfFlags = ProfFlags , startHeapProfileAtStartup :: Bool , startTimeProfileAtStartup :: Bool -- ^ @since base-4.20.0.0 , showCCSOnException :: Bool + , automaticEraIncrement :: Bool -- ^ @since 4.20.0.0 , maxRetainerSetSize :: Word , ccsLength :: Word , modSelector :: Maybe String @@ -320,6 +324,7 @@ data ProfFlags = ProfFlags , ccsSelector :: Maybe String , retainerSelector :: Maybe String , bioSelector :: Maybe String + , eraSelector :: Word -- ^ @since base-4.20.0.0 } deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -633,6 +638,8 @@ getProfFlags = do (#{peek PROFILING_FLAGS, startTimeProfileAtStartup} ptr :: IO CBool)) <*> (toBool <$> (#{peek PROFILING_FLAGS, showCCSOnException} ptr :: IO CBool)) + <*> (toBool <$> + (#{peek PROFILING_FLAGS, incrementUserEra} ptr :: IO CBool)) <*> #{peek PROFILING_FLAGS, maxRetainerSetSize} ptr <*> #{peek PROFILING_FLAGS, ccsLength} ptr <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, modSelector} ptr) @@ -642,6 +649,7 @@ getProfFlags = do <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, ccsSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, retainerSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, bioSelector} ptr) + <*> #{peek PROFILING_FLAGS, eraSelector} ptr getTraceFlags :: IO TraceFlags getTraceFlags = do ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -12071,7 +12071,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -12122,6 +12122,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -12130,7 +12131,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -9253,7 +9253,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9304,6 +9304,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9312,7 +9313,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c76be87d8e1d50dcb6905a3837c7518f10b3920 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c76be87d8e1d50dcb6905a3837c7518f10b3920 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 17:31:45 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Tue, 05 Mar 2024 12:31:45 -0500 Subject: [Git][ghc/ghc][wip/T23942] 2 commits: testsuite changes from implicit GHC.Num.BigNat deps Message-ID: <65e7570197410_28e20e5296170969cf@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 088b0243 by Matthew Craven at 2024-03-05T07:30:56-05:00 testsuite changes from implicit GHC.Num.BigNat deps - - - - - 023bf72c by Matthew Craven at 2024-03-05T12:30:27-05:00 Attempt to properly track more implicit dependencies See the new Note [Tracking implicit dependencies]. - - - - - 16 changed files: - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Iface/Type.hs-boot - libraries/ghc-bignum/src/GHC/Num/Primitives.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Data/Tuple.hs - libraries/ghc-internal/src/GHC/Internal/Exception/Type.hs-boot - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs-boot - libraries/ghc-internal/src/GHC/Internal/Maybe.hs - libraries/ghc-internal/src/GHC/Internal/Stack/Types.hs - libraries/ghc-internal/src/GHC/Internal/TypeError.hs - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Tuple.hs - testsuite/tests/plugins/plugins09.stdout - testsuite/tests/plugins/plugins10.stdout - testsuite/tests/plugins/plugins11.stdout - testsuite/tests/plugins/static-plugins.stdout Changes: ===================================== compiler/GHC/Driver/MakeFile.hs ===================================== @@ -19,6 +19,7 @@ import qualified GHC import GHC.Driver.Monad import GHC.Driver.DynFlags import GHC.Driver.Ppr +import GHC.Driver.Config.Finder import GHC.Utils.Misc import GHC.Driver.Env import GHC.Driver.Errors.Types @@ -34,20 +35,26 @@ import GHC.Utils.TmpFs import GHC.Iface.Load (cannotFindModule) +import GHC.Builtin.Names + import GHC.Unit.Module import GHC.Unit.Module.ModSummary import GHC.Unit.Module.Graph import GHC.Unit.Finder +import GHC.Unit.Home +import GHC.Unit.Env import GHC.Utils.Exception import GHC.Utils.Error import GHC.Utils.Logger +import GHC.LanguageExtensions + import System.Directory import System.FilePath import System.IO import System.IO.Error ( isEOFError ) -import Control.Monad ( when, forM_ ) +import Control.Monad import Data.Maybe ( isJust ) import Data.IORef import qualified Data.Set as Set @@ -229,19 +236,22 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ node)) obj_file = msObjFilePath node obj_files = insertSuffixes obj_file extra_suffixes - do_imp loc is_boot pkg_qual imp_mod + handle_hi_file hi_file = do + { let hi_files = insertSuffixes hi_file extra_suffixes + write_dep (obj,hi) = writeDependency root hdl [obj] hi + + -- Add one dependency for each suffix; + -- e.g. A.o : B.hi + -- A.x_o : B.x_hi + ; mapM_ write_dep (obj_files `zip` hi_files) } + + do_import loc is_boot pkg_qual imp_mod = do { mb_hi <- findDependency hsc_env loc pkg_qual imp_mod is_boot include_pkg_deps ; case mb_hi of { Nothing -> return () ; - Just hi_file -> do - { let hi_files = insertSuffixes hi_file extra_suffixes - write_dep (obj,hi) = writeDependency root hdl [obj] hi - - -- Add one dependency for each suffix; - -- e.g. A.o : B.hi - -- A.x_o : B.x_hi - ; mapM_ write_dep (obj_files `zip` hi_files) }}} + Just hi_file -> handle_hi_file hi_file + }} -- Emit std dependency of the object(s) on the source file @@ -272,15 +282,91 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ node)) -- Emit a dependency for each import - ; let do_imps is_boot idecls = sequence_ - [ do_imp loc is_boot mb_pkg mod + ; let do_imports is_boot idecls = sequence_ + [ do_import loc is_boot mb_pkg mod | (mb_pkg, L loc mod) <- idecls, mod `notElem` excl_mods ] - ; do_imps IsBoot (ms_srcimps node) - ; do_imps NotBoot (ms_imps node) + ; do_imports IsBoot (ms_srcimps node) + ; do_imports NotBoot (ms_imps node) + + -- Handle implicit built-in stuff: + -- see Note [Tracking implicit dependencies] + ; let + do_implicit_import :: Module -> IO () + do_implicit_import mod = when include_pkg_deps $ do + -- hard part: get a ModuleLoc from a Module and the env + -- This is mostly copied from GHC.Iface.LoadfindAndReadIface. + -- Surely there is a better way to do this? + let im = fst (getModuleInstantiation mod) + fc = hsc_FC hsc_env + fopts = initFinderOpts (hsc_dflags hsc_env) + other_fopts = initFinderOpts . homeUnitEnv_dflags <$> (hsc_HUG hsc_env) + unit_state = hsc_units hsc_env + mhome_unit = hsc_home_unit_maybe hsc_env + mb_found <- findExactModule fc fopts other_fopts unit_state mhome_unit im + case mb_found of + InstalledFound ml _ -> handle_hi_file (ml_hi_file ml) + InstalledNoPackage _ -> panic "processDeps.do_implicit_import" + InstalledNotFound _ _ -> panic "processDeps.do_implicit_import" + + -- every module implicitly depends on GHC.Types + ; unless (ms_mod node == gHC_TYPES) $ + do_implicit_import gHC_TYPES + + -- A module may implicitly depend on GHC.Tuple if ListTuplePuns is set + ; when (xopt ListTuplePuns dflags) $ + -- see Note [Tracking implicit dependencies], wrinkle TID2 + unless (isHomeUnitInstanceOf (hsc_home_unit hsc_env) primUnitId) $ + do_implicit_import gHC_INTERNAL_TUPLE } +{- +Note [Tracking implicit dependencies] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There are several wired-in things that ghc will read interface +files to look up even if they are not imported. They include + + * Monad-related stuff in GHC.Internal.Base, if `do` notation is used + * Tuple-related stuff in GHC.Tuple, if the built-in tuple syntax is used + * TypeRep-related stuff in GHC.Types, unless `-dno-typeable-binds` is set + * deriving-related stuff mostly elsewhere in ghc-prim + +In order for GHC's build system to work reliably, we have to track the +implicit dependencies introduced by GHC's habit of reading these +interfaces. So we include them in our -M output if -include-pkg-deps +is set, with the following wrinkles: + +(TID1) We don't actually bother adding implicit dependencies for + Monad, Arrow, etc. because the program will presumably fail to + typecheck unless these are reachable via explicit imports anyway. + +(TID2) Users can opt out of implicitly depending on GHC.Tuple with the + NoListTuplePuns languge extension. Ideally we would just turn off + ListTuplePuns in the bits of ghc-prim that GHC.Tuple depends on, but + when I tried, I got stupid errors like this: + + libraries/ghc-prim/GHC/Types.hs:371:15: error: [GHC-46574] + Cannot parse data constructor in a data/newtype declaration: [] + | + 371 | data List a = [] | a : List a + | ^^ + + So for now we don't emit this dependency in the `ghc-prim` package, + which must explicitly import GHC.Tuple for build-order reasons. + Yuck! But this doesn't make things in `ghc-prim` much worse, because + +(TID3) We don't even try to track dependencies involving `deriving`. + We try to prevent this from causing problems by ensuring that any + machinery `deriving` needs to reference related to a typeclass is + imported from the defining module for that class. For example, the + class Eq is defined in GHC.Classes, and derived Eq instances can + reference GHC.Magic.dataToTag#. So we make sure that GHC.Magic is + imported in GHC.Classes. + + Failing to do this for the Lift class caused #22229, which is sadly + still open as of March 2024. +-} findDependency :: HscEnv -> SrcSpan ===================================== compiler/GHC/Iface/Type.hs-boot ===================================== @@ -5,10 +5,6 @@ module GHC.Iface.Type ) where --- Empty import to influence the compilation ordering. --- See Note [Depend on GHC.Num.Integer] in GHC.Base -import GHC.Base () - data IfaceAppArgs data IfaceType ===================================== libraries/ghc-bignum/src/GHC/Num/Primitives.hs ===================================== @@ -97,7 +97,6 @@ import GHC.Prim.Exception import GHC.Prim import GHC.Types -import GHC.Tuple () -- See Note [Depend on GHC.Tuple] in GHC.Base default () ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -326,8 +326,7 @@ import GHC.Internal.Err import GHC.Internal.Maybe import {-# SOURCE #-} GHC.Internal.IO (mkUserError, mplusIO) -import GHC.Tuple (Solo (MkSolo)) -- Note [Depend on GHC.Tuple] -import GHC.Num.Integer () -- Note [Depend on GHC.Num.Integer] +import GHC.Tuple (Solo (MkSolo)) -- See Note [Semigroup stimes cycle] import {-# SOURCE #-} GHC.Internal.Num (Num (..)) @@ -348,38 +347,6 @@ infixl 4 <*>, <*, *>, <**> default () -- Double isn't available yet {- -Note [Depend on GHC.Num.Integer] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The Integer type is special because GHC.CoreToStg.Prep.mkConvertNumLiteral -lookups names in ghc-bignum interfaces to construct Integer literal values. -Currently it reads the interface file whether or not the current module *has* -any Integer literals, so it's important that GHC.Num.Integer is compiled before -any other module. - -The danger is that if the build system doesn't know about the implicit -dependency on Integer, it'll compile some base module before GHC.Num.Integer, -resulting in: - Failed to load interface for ‘GHC.Num.Integer’ - There are files missing in the ‘ghc-bignum’ package, - -To ensure that GHC.Num.Integer is there, we must ensure that there is a visible -dependency on GHC.Num.Integer from every module in base. We make GHC.Internal.Base -depend on GHC.Num.Integer; and everything else either depends on GHC.Base, -directly on GHC.Num.Integer, or does not have NoImplicitPrelude (and hence -depends on Prelude). - -The lookup is only disabled for packages ghc-prim and ghc-bignum, which aren't -allowed to contain any Integer literal. - - -Note [Depend on GHC.Tuple] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -Similarly, tuple syntax (or ()) creates an implicit dependency on -GHC.Tuple, so we use the same rule as for Integer --- see Note [Depend on -GHC.Num.Integer] --- to explain this to the build system. We make GHC.Internal.Base -depend on GHC.Tuple, and everything else depends on GHC.Internal.Base or Prelude. - - Note [Semigroup stimes cycle] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Semigroup is defined in this module, GHC.Base, with the method ===================================== libraries/ghc-internal/src/GHC/Internal/Data/Tuple.hs ===================================== @@ -25,7 +25,6 @@ module GHC.Internal.Data.Tuple , swap ) where -import GHC.Internal.Base () -- Note [Depend on GHC.Tuple] import GHC.Tuple (Solo (..), getSolo) default () -- Double isn't available yet ===================================== libraries/ghc-internal/src/GHC/Internal/Exception/Type.hs-boot ===================================== @@ -9,8 +9,6 @@ module GHC.Internal.Exception.Type , underflowException ) where -import GHC.Num.Integer () -- See Note [Depend on GHC.Num.Integer] in GHC.Internal.Base - data SomeException divZeroException, overflowException, ratioZeroDenomException, underflowException :: SomeException ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs-boot ===================================== @@ -2,7 +2,4 @@ module GHC.Internal.IO.Handle.Types ( Handle ) where --- See Note [Depend on GHC.Num.Integer] in GHC.Internal.Base -import GHC.Types () - data Handle ===================================== libraries/ghc-internal/src/GHC/Internal/Maybe.hs ===================================== @@ -7,7 +7,6 @@ module GHC.Internal.Maybe ) where -import GHC.Num.Integer () -- See Note [Depend on GHC.Num.Integer] in GHC.Internal.Base import GHC.Classes default () ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/Types.hs ===================================== @@ -54,10 +54,6 @@ import cycle, import GHC.Classes (Eq) import GHC.Types (Char, Int) --- Make implicit dependency known to build system -import GHC.Tuple () -- See Note [Depend on GHC.Tuple] in GHC.Internal.Base -import GHC.Num.Integer () -- See Note [Depend on GHC.Num.Integer] in GHC.Internal.Base - -- $setup -- >>> import Prelude -- >>> import GHC.Internal.Stack (prettyCallStack, callStack) ===================================== libraries/ghc-internal/src/GHC/Internal/TypeError.hs ===================================== @@ -32,7 +32,6 @@ module GHC.Internal.TypeError ) where import GHC.Internal.Data.Bool -import GHC.Num.Integer () -- See Note [Depend on GHC.Num.Integer] in GHC.Internal.Base import GHC.Types (TYPE, Constraint, Symbol) {- Note [Custom type errors] ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -137,7 +137,10 @@ module GHC.Classes( ) where -- GHC.Magic is used in some derived instances +-- See Note [Tracking implicit dependencies] +-- in compiler/GHC/Driver/MakeFile.hs, wrinkle TID3 import GHC.Magic () + import GHC.Prim import GHC.Tuple import GHC.CString (unpackCString#) ===================================== libraries/ghc-prim/GHC/Tuple.hs ===================================== @@ -29,10 +29,6 @@ module GHC.Tuple ( Tuple60(..), Tuple61(..), Tuple62(..), Tuple63(..), Tuple64(..), ) where -import GHC.CString () -- Make sure we do it first, so that the - -- implicit Typeable stuff can see GHC.Types.TyCon - -- and unpackCString# etc - default () -- Double and Integer aren't available yet -- | The unit datatype @Unit@ has one non-undefined member, the nullary ===================================== testsuite/tests/plugins/plugins09.stdout ===================================== @@ -5,4 +5,3 @@ interfacePlugin: GHC.Internal.Float interfacePlugin: GHC.Prim.Ext typeCheckPlugin (rn) typeCheckPlugin (tc) -interfacePlugin: GHC.Num.BigNat ===================================== testsuite/tests/plugins/plugins10.stdout ===================================== @@ -8,7 +8,6 @@ interfacePlugin: GHC.Prim.Ext interfacePlugin: Language.Haskell.TH.Syntax typeCheckPlugin (rn) typeCheckPlugin (tc) -interfacePlugin: GHC.Num.BigNat parsePlugin(a) typeCheckPlugin (rn) interfacePlugin: Language.Haskell.TH.Lib.Internal ===================================== testsuite/tests/plugins/plugins11.stdout ===================================== @@ -5,4 +5,3 @@ interfacePlugin: GHC.Internal.Float interfacePlugin: GHC.Prim.Ext typeCheckPlugin (rn) typeCheckPlugin (tc) -interfacePlugin: GHC.Num.BigNat ===================================== testsuite/tests/plugins/static-plugins.stdout ===================================== @@ -12,7 +12,6 @@ interfacePlugin: GHC.Internal.TopHandler typeCheckPlugin (tc) interfacePlugin: GHC.CString interfacePlugin: GHC.Prim -interfacePlugin: GHC.Num.BigNat ==pure.1 ==fp0.0 parsePlugin() View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a83c4255167dbdbc02dccaffda96d60f2ab7ee0...023bf72cf6cf394e6739faa3f51830cd2fc182d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a83c4255167dbdbc02dccaffda96d60f2ab7ee0...023bf72cf6cf394e6739faa3f51830cd2fc182d0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 18:02:57 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Tue, 05 Mar 2024 13:02:57 -0500 Subject: [Git][ghc/ghc][wip/T23942] implicit dependencies for string literals Message-ID: <65e75e5166059_28e20e61fd9d8103513@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 5f386def by Matthew Craven at 2024-03-05T13:02:12-05:00 implicit dependencies for string literals - - - - - 1 changed file: - compiler/GHC/Driver/MakeFile.hs Changes: ===================================== compiler/GHC/Driver/MakeFile.hs ===================================== @@ -315,10 +315,13 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ node)) do_implicit_import gHC_TYPES -- A module may implicitly depend on GHC.Tuple if ListTuplePuns is set - ; when (xopt ListTuplePuns dflags) $ - -- see Note [Tracking implicit dependencies], wrinkle TID2 - unless (isHomeUnitInstanceOf (hsc_home_unit hsc_env) primUnitId) $ + ; unless (isHomeUnitInstanceOf (hsc_home_unit hsc_env) primUnitId) $ do + { -- see Note [Tracking implicit dependencies], wrinkle TID2 + when (xopt ListTuplePuns dflags) $ do_implicit_import gHC_INTERNAL_TUPLE + -- see Note [Tracking implicit dependencies], wrinkle TID4 + ; do_implicit_import gHC_CSTRING + } } {- @@ -331,6 +334,7 @@ files to look up even if they are not imported. They include * Tuple-related stuff in GHC.Tuple, if the built-in tuple syntax is used * TypeRep-related stuff in GHC.Types, unless `-dno-typeable-binds` is set * deriving-related stuff mostly elsewhere in ghc-prim + * GHC.CString.unpackCString# et al, if string literals are used In order for GHC's build system to work reliably, we have to track the implicit dependencies introduced by GHC's habit of reading these @@ -366,6 +370,10 @@ is set, with the following wrinkles: Failing to do this for the Lift class caused #22229, which is sadly still open as of March 2024. + +(TID4) Likewise, since we don't have a flag to disable string + literals, we always add an implicit dependency on GHC.CString for + any modules outside of `ghc-prim`. -} findDependency :: HscEnv View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f386def642896cfa0f302fafbc18931d696c344 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f386def642896cfa0f302fafbc18931d696c344 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 18:23:27 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Tue, 05 Mar 2024 13:23:27 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Try inlining checkTyCoVarInScope Message-ID: <65e7631f30399_28e20e703bb1c104078@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: 07de4242 by Mikolaj Konarski at 2024-03-05T19:22:42+01:00 Try inlining checkTyCoVarInScope - - - - - 1 changed file: - compiler/GHC/Core/Lint.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1933,6 +1933,7 @@ checkTyCon tc ------------------- checkTyCoVarInScope :: Subst -> TyCoVar -> LintM () +{-# INLINE checkTyCoVarInScope rev #-} checkTyCoVarInScope subst tcv = checkL (tcv `isInScope` subst) $ hang (text "The type or coercion variable" <+> pprBndr LetBind tcv) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07de42425ac7832b9d21f915cf7b14576a4f6748 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07de42425ac7832b9d21f915cf7b14576a4f6748 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 18:47:17 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Tue, 05 Mar 2024 13:47:17 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Try inlining checkTyCoVarInScope Message-ID: <65e768b592c30_28e20e7baa264106496@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: 26b42422 by Mikolaj Konarski at 2024-03-05T19:47:05+01:00 Try inlining checkTyCoVarInScope - - - - - 1 changed file: - compiler/GHC/Core/Lint.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1933,6 +1933,7 @@ checkTyCon tc ------------------- checkTyCoVarInScope :: Subst -> TyCoVar -> LintM () +{-# INLINE checkTyCoVarInScope #-} checkTyCoVarInScope subst tcv = checkL (tcv `isInScope` subst) $ hang (text "The type or coercion variable" <+> pprBndr LetBind tcv) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26b4242298fcf60ecee17b36617436b30df916b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26b4242298fcf60ecee17b36617436b30df916b1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 19:22:58 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 14:22:58 -0500 Subject: [Git][ghc/ghc][master] 4 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e77112b064b_28e20e8cee82c115423@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 8 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/ghc-experimental/src/GHC/Profiling/Eras.hs - libraries/ghc-internal/ghc-internal.cabal Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -1031,7 +1031,7 @@ job_groups = -- (see Note [Object unloading]). fullyStaticBrokenTests = modifyJobs (addVariable "BROKEN_TESTS" "ghcilink002 linker_unload_native") - hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-base-url") + hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-for-hackage") tsan_jobs = modifyJobs ===================================== .gitlab/jobs.yaml ===================================== @@ -2330,7 +2330,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url", + "HADRIAN_ARGS": "--haddock-for-hackage", "LLC": "/bin/false", "OPT": "/bin/false", "RUNTEST_ARGS": "", @@ -4007,7 +4007,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url --hash-unit-ids", + "HADRIAN_ARGS": "--haddock-for-hackage --hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "LLC": "/bin/false", "OPT": "/bin/false", ===================================== .gitlab/rel_eng/upload_ghc_libs.py ===================================== @@ -49,6 +49,10 @@ def prep_base(): shutil.copy('config.guess', 'libraries/base') shutil.copy('config.sub', 'libraries/base') +def prep_ghc_internal(): + shutil.copy('config.guess', 'libraries/ghc-internal') + shutil.copy('config.sub', 'libraries/ghc-internal') + def build_copy_file(pkg: Package, f: Path): target = Path('_build') / 'stage1' / pkg.path / 'build' / f dest = pkg.path / f @@ -93,6 +97,8 @@ PACKAGES = { pkg.name: pkg for pkg in [ Package('base', Path("libraries/base"), prep_base), + Package('ghc-internal', Path("libraries/ghc-internal"), prep_ghc_internal), + Package('ghc-experimental', Path("libraries/ghc-experimental"), no_prep), Package('ghc-prim', Path("libraries/ghc-prim"), prep_ghc_prim), Package('integer-gmp', Path("libraries/integer-gmp"), no_prep), Package('ghc-bignum', Path("libraries/ghc-bignum"), prep_ghc_bignum), ===================================== hadrian/README.md ===================================== @@ -306,9 +306,9 @@ all of the documentation targets: You can pass several `--docs=...` flags, Hadrian will combine their effects. -To build haddock documentation for upload to hackage you need to pass the `--haddock-base-url` flag, -by default this will choose a url suitable for uploading to hackage but you might also want to pass something like -`http://127.0.0.1:8080/package/%pkg%/docs` for testing upload locally on a local hackage server. +To build haddock documentation for upload to hackage you need to pass the `--haddock-for-hackage` flag, +This will generate URLs which are appropiate for either uploading to a local hackage +server or the global hackage server. #### Source distribution ===================================== hadrian/src/CommandLine.hs ===================================== @@ -17,7 +17,6 @@ import System.Environment import qualified System.Directory as Directory import qualified Data.Set as Set -import Data.Maybe data TestSpeed = TestSlow | TestNormal | TestFast deriving (Show, Eq) @@ -114,7 +113,7 @@ data DocArgs = DocArgs } deriving (Eq, Show) defaultDocArgs :: DocArgs -defaultDocArgs = DocArgs { docsBaseUrl = "../%pkg%" } +defaultDocArgs = DocArgs { docsBaseUrl = "../%pkgid%" } readConfigure :: Either String (CommandLineArgs -> CommandLineArgs) readConfigure = Left "hadrian --configure has been deprecated (see #20167). Please run ./boot; ./configure manually" @@ -192,11 +191,11 @@ readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testO readTestSkipPerf :: Either String (CommandLineArgs -> CommandLineArgs) readTestSkipPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testSkipPerf = True } } -readHaddockBaseUrl :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) -readHaddockBaseUrl base_url = Right $ \flags -> - flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url' } } +readHaddockBaseUrl :: Either String (CommandLineArgs -> CommandLineArgs) +readHaddockBaseUrl = Right $ \flags -> + flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url } } - where base_url' = fromMaybe "https://hackage.haskell.org/package/%pkg%/docs" base_url + where base_url = "/package/%pkg%/docs" readTestRootDirs :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) @@ -320,8 +319,8 @@ optDescrs = "Destination path for the bindist 'install' rule" , Option [] ["complete-setting"] (OptArg readCompleteStg "SETTING") "Setting key to autocomplete, for the 'autocomplete' target." - , Option [] ["haddock-base-url"] (OptArg readHaddockBaseUrl "BASE_URL") - "Generate documentation suitable for upload to hackage or for another base URL (for example a local hackage server)." + , Option [] ["haddock-for-hackage"] (NoArg readHaddockBaseUrl) + "Generate documentation suitable for upload to a hackage server." ] -- | A type-indexed map containing Hadrian command line arguments to be passed ===================================== hadrian/src/Settings/Builders/Haddock.hs ===================================== @@ -43,12 +43,15 @@ haddockBuilderArgs = mconcat version <- expr $ pkgVersion pkg synopsis <- expr $ pkgSynopsis pkg haddocks <- expr $ haddockDependencies context - haddocks_with_versions <- expr $ sequence $ [(,h) <$> pkgUnitId stage p | (p, h) <- haddocks] + haddocks_with_versions <- expr $ sequence $ [(,,h) <$> pkgSimpleIdentifier p <*> pkgUnitId stage p | (p, h) <- haddocks] hVersion <- expr $ pkgVersion haddock statsDir <- expr $ haddockStatsFilesDir baseUrlTemplate <- expr (docsBaseUrl <$> userSetting defaultDocArgs) - let baseUrl p = substituteTemplate baseUrlTemplate p + -- The path to where the docs for a package are + let docpath p = substituteTemplate baseUrlTemplate p + -- The path to where the src folder is for a package (typically docs ++ "/src/") + let srcpath p = docpath p ++ "/src/" ghcOpts <- haddockGhcArgs -- These are the options which are necessary to perform the build. Additional -- options such as `--hyperlinked-source`, `--hoogle`, `--quickjump` are @@ -67,14 +70,18 @@ haddockBuilderArgs = mconcat , arg $ "--optghc=-D__HADDOCK_VERSION__=" ++ show (versionToInt hVersion) , map ("--hide=" ++) <$> getContextData otherModules - , pure [ "--read-interface=../" ++ p - ++ "," ++ baseUrl p ++ "/src/%{MODULE}.html#%{NAME}," - ++ haddock | (p, haddock) <- haddocks_with_versions ] + , pure [ "--read-interface=" ++ docpath (p, pid) + ++ "," ++ srcpath (p, pid) ++ "," + ++ haddock | (p, pid, haddock) <- haddocks_with_versions ] , pure [ "--optghc=" ++ opt | opt <- ghcOpts, not ("--package-db" `isInfixOf` opt) ] , arg "+RTS" , arg $ "-t" ++ (statsDir -/- pkgName pkg ++ ".t") , arg "--machine-readable" , arg "-RTS" ] ] -substituteTemplate :: String -> String -> String -substituteTemplate baseTemplate pkgId = T.unpack . T.replace "%pkg%" (T.pack pkgId) . T.pack $ baseTemplate +substituteTemplate :: String -> (String, String) -> String +substituteTemplate baseTemplate (pkg, pkgId) = + T.unpack + . T.replace "%pkg%" (T.pack pkg) + . T.replace "%pkgid%" (T.pack pkgId) + . T.pack $ baseTemplate ===================================== libraries/ghc-experimental/src/GHC/Profiling/Eras.hs ===================================== @@ -1,7 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} --- | TODO move this module into ghc-internals module GHC.Profiling.Eras ( setUserEra , getUserEra , incrementUserEra ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -17,7 +17,7 @@ description: extra-tmp-files: autom4te.cache - base.buildinfo + ghc-internal.buildinfo config.log config.status include/EventConfig.h @@ -25,8 +25,8 @@ extra-tmp-files: extra-source-files: aclocal.m4 - base.buildinfo.in - changelog.md + ghc-internal.buildinfo.in + CHANGELOG.md configure configure.ac include/CTypes.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/82ccb8012ba532f0fa06dc6ff96d33217560088a...23f2a478b7dc6b61cab86cf7d0db7fec8a6d9a1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/82ccb8012ba532f0fa06dc6ff96d33217560088a...23f2a478b7dc6b61cab86cf7d0db7fec8a6d9a1f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 19:23:31 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 14:23:31 -0500 Subject: [Git][ghc/ghc][master] 2 commits: filepath: Bump submodule to 1.5.2.0 Message-ID: <65e771331bd54_28e20e8e65160118398@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 2 changed files: - libraries/filepath - libraries/os-string Changes: ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23f2a478b7dc6b61cab86cf7d0db7fec8a6d9a1f...312179442f5a1f0f3e83db6ebd4da20f5b731fa1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23f2a478b7dc6b61cab86cf7d0db7fec8a6d9a1f...312179442f5a1f0f3e83db6ebd4da20f5b731fa1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 19:54:40 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 14:54:40 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e77880131ca_28e20ea1151e8125146@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - aed47084 by Matthew Pickering at 2024-03-05T14:54:13-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - ac6745cc by Sylvain Henry at 2024-03-05T14:54:24-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - efcce4aa by Cheng Shao at 2024-03-05T14:54:26-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 23 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/base/changelog.md - libraries/filepath - libraries/ghc-experimental/src/GHC/Profiling/Eras.hs - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - libraries/os-string - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/js/arith.js - rts/sm/MBlock.c - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/rts/all.T Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -1031,7 +1031,7 @@ job_groups = -- (see Note [Object unloading]). fullyStaticBrokenTests = modifyJobs (addVariable "BROKEN_TESTS" "ghcilink002 linker_unload_native") - hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-base-url") + hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-for-hackage") tsan_jobs = modifyJobs ===================================== .gitlab/jobs.yaml ===================================== @@ -2330,7 +2330,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url", + "HADRIAN_ARGS": "--haddock-for-hackage", "LLC": "/bin/false", "OPT": "/bin/false", "RUNTEST_ARGS": "", @@ -4007,7 +4007,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url --hash-unit-ids", + "HADRIAN_ARGS": "--haddock-for-hackage --hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "LLC": "/bin/false", "OPT": "/bin/false", ===================================== .gitlab/rel_eng/upload_ghc_libs.py ===================================== @@ -49,6 +49,10 @@ def prep_base(): shutil.copy('config.guess', 'libraries/base') shutil.copy('config.sub', 'libraries/base') +def prep_ghc_internal(): + shutil.copy('config.guess', 'libraries/ghc-internal') + shutil.copy('config.sub', 'libraries/ghc-internal') + def build_copy_file(pkg: Package, f: Path): target = Path('_build') / 'stage1' / pkg.path / 'build' / f dest = pkg.path / f @@ -93,6 +97,8 @@ PACKAGES = { pkg.name: pkg for pkg in [ Package('base', Path("libraries/base"), prep_base), + Package('ghc-internal', Path("libraries/ghc-internal"), prep_ghc_internal), + Package('ghc-experimental', Path("libraries/ghc-experimental"), no_prep), Package('ghc-prim', Path("libraries/ghc-prim"), prep_ghc_prim), Package('integer-gmp', Path("libraries/integer-gmp"), no_prep), Package('ghc-bignum', Path("libraries/ghc-bignum"), prep_ghc_bignum), ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -232,6 +232,11 @@ Runtime system - Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. +- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual + memory address space reserved by the two step allocator on a 64-bit + platform. The default size is now 1T on aarch64 as well. See + :ghc-ticket:`24498`. + ``base`` library ~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -368,6 +368,18 @@ Miscellaneous RTS options thread can execute its exception handlers. The ``-xq`` controls the size of this additional quota. +.. rts-flag:: -xr ⟨size⟩ + + :default: 1T + + This option controls the size of virtual memory address space + reserved by the two step allocator on a 64-bit platform. It can be + useful in scenarios where even reserving a large address range + without committing can be expensive (e.g. WSL1), or when you + actually have enough physical memory and want to support a Haskell + heap larger than 1T. ``-xr`` is a no-op if GHC is configured with + ``--disable-large-address-space`` or if the platform is 32-bit. + .. _rts-options-gc: RTS options to control the garbage collector ===================================== hadrian/README.md ===================================== @@ -306,9 +306,9 @@ all of the documentation targets: You can pass several `--docs=...` flags, Hadrian will combine their effects. -To build haddock documentation for upload to hackage you need to pass the `--haddock-base-url` flag, -by default this will choose a url suitable for uploading to hackage but you might also want to pass something like -`http://127.0.0.1:8080/package/%pkg%/docs` for testing upload locally on a local hackage server. +To build haddock documentation for upload to hackage you need to pass the `--haddock-for-hackage` flag, +This will generate URLs which are appropiate for either uploading to a local hackage +server or the global hackage server. #### Source distribution ===================================== hadrian/src/CommandLine.hs ===================================== @@ -17,7 +17,6 @@ import System.Environment import qualified System.Directory as Directory import qualified Data.Set as Set -import Data.Maybe data TestSpeed = TestSlow | TestNormal | TestFast deriving (Show, Eq) @@ -114,7 +113,7 @@ data DocArgs = DocArgs } deriving (Eq, Show) defaultDocArgs :: DocArgs -defaultDocArgs = DocArgs { docsBaseUrl = "../%pkg%" } +defaultDocArgs = DocArgs { docsBaseUrl = "../%pkgid%" } readConfigure :: Either String (CommandLineArgs -> CommandLineArgs) readConfigure = Left "hadrian --configure has been deprecated (see #20167). Please run ./boot; ./configure manually" @@ -192,11 +191,11 @@ readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testO readTestSkipPerf :: Either String (CommandLineArgs -> CommandLineArgs) readTestSkipPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testSkipPerf = True } } -readHaddockBaseUrl :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) -readHaddockBaseUrl base_url = Right $ \flags -> - flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url' } } +readHaddockBaseUrl :: Either String (CommandLineArgs -> CommandLineArgs) +readHaddockBaseUrl = Right $ \flags -> + flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url } } - where base_url' = fromMaybe "https://hackage.haskell.org/package/%pkg%/docs" base_url + where base_url = "/package/%pkg%/docs" readTestRootDirs :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) @@ -320,8 +319,8 @@ optDescrs = "Destination path for the bindist 'install' rule" , Option [] ["complete-setting"] (OptArg readCompleteStg "SETTING") "Setting key to autocomplete, for the 'autocomplete' target." - , Option [] ["haddock-base-url"] (OptArg readHaddockBaseUrl "BASE_URL") - "Generate documentation suitable for upload to hackage or for another base URL (for example a local hackage server)." + , Option [] ["haddock-for-hackage"] (NoArg readHaddockBaseUrl) + "Generate documentation suitable for upload to a hackage server." ] -- | A type-indexed map containing Hadrian command line arguments to be passed ===================================== hadrian/src/Settings/Builders/Haddock.hs ===================================== @@ -43,12 +43,15 @@ haddockBuilderArgs = mconcat version <- expr $ pkgVersion pkg synopsis <- expr $ pkgSynopsis pkg haddocks <- expr $ haddockDependencies context - haddocks_with_versions <- expr $ sequence $ [(,h) <$> pkgUnitId stage p | (p, h) <- haddocks] + haddocks_with_versions <- expr $ sequence $ [(,,h) <$> pkgSimpleIdentifier p <*> pkgUnitId stage p | (p, h) <- haddocks] hVersion <- expr $ pkgVersion haddock statsDir <- expr $ haddockStatsFilesDir baseUrlTemplate <- expr (docsBaseUrl <$> userSetting defaultDocArgs) - let baseUrl p = substituteTemplate baseUrlTemplate p + -- The path to where the docs for a package are + let docpath p = substituteTemplate baseUrlTemplate p + -- The path to where the src folder is for a package (typically docs ++ "/src/") + let srcpath p = docpath p ++ "/src/" ghcOpts <- haddockGhcArgs -- These are the options which are necessary to perform the build. Additional -- options such as `--hyperlinked-source`, `--hoogle`, `--quickjump` are @@ -67,14 +70,18 @@ haddockBuilderArgs = mconcat , arg $ "--optghc=-D__HADDOCK_VERSION__=" ++ show (versionToInt hVersion) , map ("--hide=" ++) <$> getContextData otherModules - , pure [ "--read-interface=../" ++ p - ++ "," ++ baseUrl p ++ "/src/%{MODULE}.html#%{NAME}," - ++ haddock | (p, haddock) <- haddocks_with_versions ] + , pure [ "--read-interface=" ++ docpath (p, pid) + ++ "," ++ srcpath (p, pid) ++ "," + ++ haddock | (p, pid, haddock) <- haddocks_with_versions ] , pure [ "--optghc=" ++ opt | opt <- ghcOpts, not ("--package-db" `isInfixOf` opt) ] , arg "+RTS" , arg $ "-t" ++ (statsDir -/- pkgName pkg ++ ".t") , arg "--machine-readable" , arg "-RTS" ] ] -substituteTemplate :: String -> String -> String -substituteTemplate baseTemplate pkgId = T.unpack . T.replace "%pkg%" (T.pack pkgId) . T.pack $ baseTemplate +substituteTemplate :: String -> (String, String) -> String +substituteTemplate baseTemplate (pkg, pkgId) = + T.unpack + . T.replace "%pkg%" (T.pack pkg) + . T.replace "%pkgid%" (T.pack pkgId) + . T.pack $ baseTemplate ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Add `HeapByEra`, `eraSelector` and `automaticEraIncrement` to `GHC.RTS.Flags` to + reflect the new RTS flags: `-he` profiling mode, `-he` selector and `--automatic-era-increment`. + ([CLC proposal #254](https://github.com/haskell/core-libraries-committee/issues/254)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/ghc-experimental/src/GHC/Profiling/Eras.hs ===================================== @@ -1,7 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} --- | TODO move this module into ghc-internals module GHC.Profiling.Eras ( setUserEra , getUserEra , incrementUserEra ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -17,7 +17,7 @@ description: extra-tmp-files: autom4te.cache - base.buildinfo + ghc-internal.buildinfo config.log config.status include/EventConfig.h @@ -25,8 +25,8 @@ extra-tmp-files: extra-source-files: aclocal.m4 - base.buildinfo.in - changelog.md + ghc-internal.buildinfo.in + CHANGELOG.md configure configure.ac include/CTypes.h ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -274,6 +274,7 @@ data DoHeapProfile | HeapByLDV | HeapByClosureType | HeapByInfoTable + | HeapByEra -- ^ @since base-4.20.0.0 deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -289,6 +290,7 @@ instance Enum DoHeapProfile where fromEnum HeapByLDV = #{const HEAP_BY_LDV} fromEnum HeapByClosureType = #{const HEAP_BY_CLOSURE_TYPE} fromEnum HeapByInfoTable = #{const HEAP_BY_INFO_TABLE} + fromEnum HeapByEra = #{const HEAP_BY_ERA} toEnum #{const NO_HEAP_PROFILING} = NoHeapProfiling toEnum #{const HEAP_BY_CCS} = HeapByCCS @@ -299,6 +301,7 @@ instance Enum DoHeapProfile where toEnum #{const HEAP_BY_LDV} = HeapByLDV toEnum #{const HEAP_BY_CLOSURE_TYPE} = HeapByClosureType toEnum #{const HEAP_BY_INFO_TABLE} = HeapByInfoTable + toEnum #{const HEAP_BY_ERA} = HeapByEra toEnum e = errorWithoutStackTrace ("invalid enum for DoHeapProfile: " ++ show e) -- | Parameters of the cost-center profiler @@ -311,6 +314,7 @@ data ProfFlags = ProfFlags , startHeapProfileAtStartup :: Bool , startTimeProfileAtStartup :: Bool -- ^ @since base-4.20.0.0 , showCCSOnException :: Bool + , automaticEraIncrement :: Bool -- ^ @since 4.20.0.0 , maxRetainerSetSize :: Word , ccsLength :: Word , modSelector :: Maybe String @@ -320,6 +324,7 @@ data ProfFlags = ProfFlags , ccsSelector :: Maybe String , retainerSelector :: Maybe String , bioSelector :: Maybe String + , eraSelector :: Word -- ^ @since base-4.20.0.0 } deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -633,6 +638,8 @@ getProfFlags = do (#{peek PROFILING_FLAGS, startTimeProfileAtStartup} ptr :: IO CBool)) <*> (toBool <$> (#{peek PROFILING_FLAGS, showCCSOnException} ptr :: IO CBool)) + <*> (toBool <$> + (#{peek PROFILING_FLAGS, incrementUserEra} ptr :: IO CBool)) <*> #{peek PROFILING_FLAGS, maxRetainerSetSize} ptr <*> #{peek PROFILING_FLAGS, ccsLength} ptr <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, modSelector} ptr) @@ -642,6 +649,7 @@ getProfFlags = do <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, ccsSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, retainerSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, bioSelector} ptr) + <*> #{peek PROFILING_FLAGS, eraSelector} ptr getTraceFlags :: IO TraceFlags getTraceFlags = do ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 ===================================== rts/RtsFlags.c ===================================== @@ -186,6 +186,9 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.ringBell = false; RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */ + // 1 TBytes + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40; + RtsFlags.DebugFlags.scheduler = false; RtsFlags.DebugFlags.interpreter = false; RtsFlags.DebugFlags.weak = false; @@ -552,6 +555,11 @@ usage_text[] = { " -xq The allocation limit given to a thread after it receives", " an AllocationLimitExceeded exception. (default: 100k)", "", +#if defined(USE_LARGE_ADDRESS_SPACE) +" -xr The size of virtual memory address space reserved by the", +" two step allocator (default: 1T)", +"", +#endif " -Mgrace=", " The amount of allocation after the program receives a", " HeapOverflow exception before the exception is thrown again, if", @@ -1820,6 +1828,12 @@ error = true; / BLOCK_SIZE; break; + case 'r': + OPTION_UNSAFE; + RtsFlags.GcFlags.addressSpaceSize + = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_WORD64_MAX); + break; + default: OPTION_SAFE; errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -2118,7 +2132,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) m = atof(s); c = s[strlen(s)-1]; - if (c == 'g' || c == 'G') + if (c == 't' || c == 'T') + m *= (StgWord64)1024*1024*1024*1024; + else if (c == 'g' || c == 'G') m *= 1024*1024*1024; else if (c == 'm' || c == 'M') m *= 1024*1024; @@ -2737,4 +2753,3 @@ doingErasProfiling( void ) || RtsFlags.ProfFlags.eraSelector != 0); } #endif /* PROFILING */ - ===================================== rts/include/rts/Flags.h ===================================== @@ -89,6 +89,8 @@ typedef struct _GC_FLAGS { bool numa; /* Use NUMA */ StgWord numaMask; + + StgWord64 addressSpaceSize; /* large address space size in bytes */ } GC_FLAGS; /* See Note [Synchronization of flags and base APIs] */ ===================================== rts/js/arith.js ===================================== @@ -44,19 +44,23 @@ function h$hs_remWord64(h1,l1,h2,l2) { } function h$hs_timesWord64(h1,l1,h2,l2) { - var a = W64(h1,l1); - var b = W64(h2,l2); - var r = BigInt.asUintN(64, a * b); - TRACE_ARITH("Word64: " + a + " * " + b + " ==> " + r) - RETURN_W64(r); + var rh = h$mul2Word32(l1,l2); + var rl = h$ret1; + + rh += Math.imul(l1,h2)>>>0; + rh += Math.imul(l2,h1)>>>0; + rh >>>= 0; + + TRACE_ARITH("Word64: " + (h1,l1) + " * " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_minusWord64(h1,l1,h2,l2) { - var a = (BigInt(h1) << BigInt(32)) | BigInt(l1>>>0); - var b = (BigInt(h2) << BigInt(32)) | BigInt(l2>>>0); - var r = BigInt.asUintN(64, a - b); - TRACE_ARITH("Word64: " + a + " - " + b + " ==> " + r) - RETURN_W64(r); + var l = l1-l2; + var rl = l>>>0; + var rh = (h1-h2-(l!=rl?1:0))>>>0; + TRACE_ARITH("Word64: " + (h1,l1) + " - " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_plusWord64(h1,l1,h2,l2) { @@ -68,11 +72,15 @@ function h$hs_plusWord64(h1,l1,h2,l2) { } function h$hs_timesInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a * b); - TRACE_ARITH("Int64: " + a + " * " + b + " ==> " + r) - RETURN_I64(r); + var rh = h$mul2Word32(l1,l2); + var rl = h$ret1; + + rh += Math.imul(l1,h2)|0; + rh += Math.imul(l2,h1)|0; + rh |= 0; + + TRACE_ARITH("Int64: " + (h1,l1) + " * " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_quotInt64(h1,l1,h2,l2) { @@ -92,19 +100,19 @@ function h$hs_remInt64(h1,l1,h2,l2) { } function h$hs_plusInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a + b); - TRACE_ARITH("Int64: " + a + " + " + b + " ==> " + r) - RETURN_I64(r); + var l = l1+l2; + var rl = l>>>0; + var rh = (h1+h2+(l!=rl?1:0))|0; + TRACE_ARITH("Int64: " + (h1,l1) + " + " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_minusInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a - b); - TRACE_ARITH("Int64: " + a + " - " + b + " ==> " + r) - RETURN_I64(r); + var l = l1-l2; + var rl = l>>>0; + var rh = (h1-h2-(l!=rl?1:0))|0; + TRACE_ARITH("Int64: " + (h1,l1) + " - " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_uncheckedShiftLWord64(h,l,n) { ===================================== rts/sm/MBlock.c ===================================== @@ -659,20 +659,14 @@ initMBlocks(void) #if defined(USE_LARGE_ADDRESS_SPACE) { - W_ size; -#if defined(aarch64_HOST_ARCH) - size = (W_)1 << 38; // 1/4 TByte -#else - size = (W_)1 << 40; // 1 TByte -#endif void *startAddress = NULL; if (RtsFlags.GcFlags.heapBase) { startAddress = (void*) RtsFlags.GcFlags.heapBase; } - void *addr = osReserveHeapMemory(startAddress, &size); + void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize); mblock_address_space.begin = (W_)addr; - mblock_address_space.end = (W_)addr + size; + mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize; mblock_high_watermark = (W_)addr; } #elif SIZEOF_VOID_P == 8 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -12071,7 +12071,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -12122,6 +12122,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -12130,7 +12131,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -9253,7 +9253,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9304,6 +9304,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9312,7 +9313,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/rts/all.T ===================================== @@ -3,7 +3,7 @@ test('testblockalloc', compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'), + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'), when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5472fdf1fe1fc502ca16fe30a1d80ffa68d0c9cc...efcce4aab88b2d85ec3aa8670680217f78b6b341 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5472fdf1fe1fc502ca16fe30a1d80ffa68d0c9cc...efcce4aab88b2d85ec3aa8670680217f78b6b341 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 20:00:39 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Tue, 05 Mar 2024 15:00:39 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] 12 commits: Beauify allMachRegNos Message-ID: <65e779e744d17_28e20ea2f3668131363@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 9a8af3a2 by Sven Tennie at 2024-03-05T12:48:43+01:00 Beauify allMachRegNos - - - - - a6af09dc by Sven Tennie at 2024-03-05T13:10:03+01:00 Delete unused function strImmLit - - - - - 569330e5 by Sven Tennie at 2024-03-05T14:48:36+01:00 Introduce constant firstFpRegNo Makes usages more readable. - - - - - a5908d00 by Sven Tennie at 2024-03-05T15:24:53+01:00 Add TODOs - - - - - 1c707282 by Sven Tennie at 2024-03-05T18:30:06+01:00 Cleanup register constants - - - - - 952c4ab0 by Sven Tennie at 2024-03-05T19:19:50+01:00 Make reg numbers less magic - - - - - d5e9df2c by Sven Tennie at 2024-03-05T19:32:56+01:00 More on RegNo - - - - - 84e5bb2a by Sven Tennie at 2024-03-05T19:38:03+01:00 Improve comment - - - - - 73ab87ca by Sven Tennie at 2024-03-05T20:08:34+01:00 Remove unused / non-existent addressing mode - - - - - 1ad87d41 by Sven Tennie at 2024-03-05T20:10:02+01:00 Reformat / cleanup - - - - - 9805cb59 by Sven Tennie at 2024-03-05T20:11:35+01:00 Add TODOs - - - - - da053cea by Sven Tennie at 2024-03-05T20:57:54+01:00 More on RegNos - - - - - 4 changed files: - compiler/GHC/CmmToAsm/RV64/CodeGen.hs - compiler/GHC/CmmToAsm/RV64/Instr.hs - compiler/GHC/CmmToAsm/RV64/Ppr.hs - compiler/GHC/CmmToAsm/RV64/Regs.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/CodeGen.hs ===================================== @@ -502,7 +502,7 @@ getRegister' config plat expr = CmmLit lit -> case lit of - CmmInt 0 w -> pure $ Fixed (intFormat w) zero_reg nilOL + CmmInt 0 w -> pure $ Fixed (intFormat w) zeroReg nilOL CmmInt i w -> -- narrowU is important: Negative immediates may be -- sign-extended on load! @@ -1762,8 +1762,8 @@ genCCall target dest_regs arg_regs bid = do if hint == SignedHint then code_r - `appOL` signExtend w W64 r ip_reg - `snocOL` ann (text "Pass signed argument (size " <> ppr w <> text ") on the stack: " <> ppr ip_reg) str + `appOL` signExtend w W64 r ipReg + `snocOL` ann (text "Pass signed argument (size " <> ppr w <> text ") on the stack: " <> ppr ipReg) str else code_r `snocOL` ann (text "Pass unsigned argument (size " <> ppr w <> text ") on the stack: " <> ppr r) str ===================================== compiler/GHC/CmmToAsm/RV64/Instr.hs ===================================== @@ -161,7 +161,6 @@ regUsageOfInstr platform instr = case instr of (filter (interesting platform) dst) regAddr :: AddrMode -> [Reg] - regAddr (AddrRegReg r1 r2) = [r1, r2] regAddr (AddrRegImm r1 _) = [r1] regAddr (AddrReg r1) = [r1] regOp :: Operand -> [Reg] @@ -205,12 +204,12 @@ regUsageOfInstr platform instr = case instr of -- ZR: Zero, RA: Return Address, SP: Stack Pointer, GP: Global Pointer, TP: Thread Pointer, FP: Frame Pointer -- BR: Base, SL: SpLim callerSavedRegisters :: [Reg] -callerSavedRegisters - = map regSingle [5..7] - ++ map regSingle [10..17] - ++ map regSingle [28..31] - ++ map regSingle [32..39] - ++ map regSingle [42..49] +callerSavedRegisters = + map regSingle [t0RegNo .. t2RegNo] + ++ map regSingle [a0RegNo .. a7RegNo] + ++ map regSingle [t3RegNo .. t6RegNo] + ++ map regSingle [ft0RegNo .. ft7RegNo] + ++ map regSingle [fa0RegNo .. fa7RegNo] -- | Apply a given mapping to all the register references in this -- instruction. @@ -302,7 +301,6 @@ patchRegsOfInstr instr env = case instr of patchTarget (TReg r) = TReg (env r) patchTarget t = t patchAddr :: AddrMode -> AddrMode - patchAddr (AddrRegReg r1 r2) = AddrRegReg (env r1) (env r2) patchAddr (AddrRegImm r1 i) = AddrRegImm (env r1) i patchAddr (AddrReg r) = AddrReg (env r) -------------------------------------------------------------------------------- @@ -388,12 +386,12 @@ mkSpillInstr config reg delta slot = ] where fmt = case reg of - RegReal (RealRegSingle n) | n < 32 -> II64 + RegReal (RealRegSingle n) | n < d0RegNo -> II64 _ -> FF64 - mkStrSpImm imm = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm sp_reg (ImmInt imm))) + mkStrSpImm imm = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm spMachReg (ImmInt imm))) movImmToIp imm = ANN (text "Spill: IP <- " <> int imm) $ MOV ip (OpImm (ImmInt imm)) addSpToIp = ANN (text "Spill: IP <- SP + IP ") $ ADD ip ip sp - mkStrIp = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrReg ip_reg)) + mkStrIp = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrReg ipReg)) off = spillSlotToOffset slot @@ -414,12 +412,12 @@ mkLoadInstr _config reg delta slot = ] where fmt = case reg of - RegReal (RealRegSingle n) | n < 32 -> II64 + RegReal (RealRegSingle n) | n < d0RegNo -> II64 _ -> FF64 - mkLdrSpImm imm = ANN (text "Reload@" <> int (off - delta)) $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm sp_reg (ImmInt imm))) + mkLdrSpImm imm = ANN (text "Reload@" <> int (off - delta)) $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm spMachReg (ImmInt imm))) movImmToIp imm = ANN (text "Reload: IP <- " <> int imm) $ MOV ip (OpImm (ImmInt imm)) addSpToIp = ANN (text "Reload: IP <- SP + IP ") $ ADD ip ip sp - mkLdrIp = ANN (text "Reload@" <> int (off - delta)) $ LDR fmt (OpReg W64 reg) (OpAddr (AddrReg ip_reg)) + mkLdrIp = ANN (text "Reload@" <> int (off - delta)) $ LDR fmt (OpReg W64 reg) (OpAddr (AddrReg ipReg)) off = spillSlotToOffset slot @@ -795,10 +793,6 @@ data Operand | OpAddr AddrMode -- memory reference deriving (Eq, Show) --- Smart constructors -opReg :: Width -> Reg -> Operand -opReg = OpReg - -- Note [The made-up RISCV64 IP register] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- @@ -817,98 +811,101 @@ opReg = OpReg -- X31 is a caller-saved register. I.e. there are no guarantees about what the -- callee does with it. That's exactly what we want here. -zero_reg, ra_reg, sp_reg, ip_reg :: Reg -zero_reg = RegReal (RealRegSingle 0) -ra_reg = RegReal (RealRegSingle 1) -sp_reg = RegReal (RealRegSingle 2) -ip_reg = RegReal (RealRegSingle 31) +zeroReg, raReg, spMachReg, ipReg :: Reg +zeroReg = regSingle 0 +raReg = regSingle 1 +-- | Not to be confused with the `CmmReg` `spReg` +spMachReg = regSingle 2 +ipReg = regSingle 31 + +operandFromReg :: Reg -> Operand +operandFromReg = OpReg W64 + +operandFromRegNo :: RegNo -> Operand +operandFromRegNo = operandFromReg . regSingle zero, ra, sp, gp, tp, fp, ip :: Operand -zero = OpReg W64 zero_reg -ra = OpReg W64 ra_reg -sp = OpReg W64 sp_reg -gp = OpReg W64 (RegReal (RealRegSingle 3)) -tp = OpReg W64 (RegReal (RealRegSingle 4)) -fp = OpReg W64 (RegReal (RealRegSingle 8)) -ip = OpReg W64 ip_reg - -_x :: Int -> Operand -_x i = OpReg W64 (RegReal (RealRegSingle i)) +zero = operandFromReg zeroReg +ra = operandFromReg raReg +sp = operandFromReg spMachReg +gp = operandFromRegNo 3 +tp = operandFromRegNo 4 +fp = operandFromRegNo 8 +ip = operandFromReg ipReg + x0, x1, x2, x3, x4, x5, x6, x7 :: Operand x8, x9, x10, x11, x12, x13, x14, x15 :: Operand x16, x17, x18, x19, x20, x21, x22, x23 :: Operand x24, x25, x26, x27, x28, x29, x30, x31 :: Operand -x0 = OpReg W64 (RegReal (RealRegSingle 0)) -x1 = OpReg W64 (RegReal (RealRegSingle 1)) -x2 = OpReg W64 (RegReal (RealRegSingle 2)) -x3 = OpReg W64 (RegReal (RealRegSingle 3)) -x4 = OpReg W64 (RegReal (RealRegSingle 4)) -x5 = OpReg W64 (RegReal (RealRegSingle 5)) -x6 = OpReg W64 (RegReal (RealRegSingle 6)) -x7 = OpReg W64 (RegReal (RealRegSingle 7)) -x8 = OpReg W64 (RegReal (RealRegSingle 8)) -x9 = OpReg W64 (RegReal (RealRegSingle 9)) -x10 = OpReg W64 (RegReal (RealRegSingle 10)) -x11 = OpReg W64 (RegReal (RealRegSingle 11)) -x12 = OpReg W64 (RegReal (RealRegSingle 12)) -x13 = OpReg W64 (RegReal (RealRegSingle 13)) -x14 = OpReg W64 (RegReal (RealRegSingle 14)) -x15 = OpReg W64 (RegReal (RealRegSingle 15)) -x16 = OpReg W64 (RegReal (RealRegSingle 16)) -x17 = OpReg W64 (RegReal (RealRegSingle 17)) -x18 = OpReg W64 (RegReal (RealRegSingle 18)) -x19 = OpReg W64 (RegReal (RealRegSingle 19)) -x20 = OpReg W64 (RegReal (RealRegSingle 20)) -x21 = OpReg W64 (RegReal (RealRegSingle 21)) -x22 = OpReg W64 (RegReal (RealRegSingle 22)) -x23 = OpReg W64 (RegReal (RealRegSingle 23)) -x24 = OpReg W64 (RegReal (RealRegSingle 24)) -x25 = OpReg W64 (RegReal (RealRegSingle 25)) -x26 = OpReg W64 (RegReal (RealRegSingle 26)) -x27 = OpReg W64 (RegReal (RealRegSingle 27)) -x28 = OpReg W64 (RegReal (RealRegSingle 28)) -x29 = OpReg W64 (RegReal (RealRegSingle 29)) -x30 = OpReg W64 (RegReal (RealRegSingle 30)) -x31 = OpReg W64 (RegReal (RealRegSingle 31)) - -_d :: Int -> Operand -_d = OpReg W64 . RegReal . RealRegSingle +x0 = operandFromRegNo x0RegNo +x1 = operandFromRegNo 1 +x2 = operandFromRegNo 2 +x3 = operandFromRegNo 3 +x4 = operandFromRegNo 4 +x5 = operandFromRegNo x5RegNo +x6 = operandFromRegNo 6 +x7 = operandFromRegNo x7RegNo +x8 = operandFromRegNo 8 +x9 = operandFromRegNo 9 +x10 = operandFromRegNo x10RegNo +x11 = operandFromRegNo 11 +x12 = operandFromRegNo 12 +x13 = operandFromRegNo 13 +x14 = operandFromRegNo 14 +x15 = operandFromRegNo 15 +x16 = operandFromRegNo 16 +x17 = operandFromRegNo x17RegNo +x18 = operandFromRegNo 18 +x19 = operandFromRegNo 19 +x20 = operandFromRegNo 20 +x21 = operandFromRegNo 21 +x22 = operandFromRegNo 22 +x23 = operandFromRegNo 23 +x24 = operandFromRegNo 24 +x25 = operandFromRegNo 25 +x26 = operandFromRegNo 26 +x27 = operandFromRegNo 27 +x28 = operandFromRegNo x28RegNo +x29 = operandFromRegNo 29 +x30 = operandFromRegNo 30 +x31 = operandFromRegNo x31RegNo + d0, d1, d2, d3, d4, d5, d6, d7 :: Operand d8, d9, d10, d11, d12, d13, d14, d15 :: Operand d16, d17, d18, d19, d20, d21, d22, d23 :: Operand d24, d25, d26, d27, d28, d29, d30, d31 :: Operand -d0 = OpReg W64 (RegReal (RealRegSingle 32)) -d1 = OpReg W64 (RegReal (RealRegSingle 33)) -d2 = OpReg W64 (RegReal (RealRegSingle 34)) -d3 = OpReg W64 (RegReal (RealRegSingle 35)) -d4 = OpReg W64 (RegReal (RealRegSingle 36)) -d5 = OpReg W64 (RegReal (RealRegSingle 37)) -d6 = OpReg W64 (RegReal (RealRegSingle 38)) -d7 = OpReg W64 (RegReal (RealRegSingle 39)) -d8 = OpReg W64 (RegReal (RealRegSingle 40)) -d9 = OpReg W64 (RegReal (RealRegSingle 41)) -d10 = OpReg W64 (RegReal (RealRegSingle 42)) -d11 = OpReg W64 (RegReal (RealRegSingle 43)) -d12 = OpReg W64 (RegReal (RealRegSingle 44)) -d13 = OpReg W64 (RegReal (RealRegSingle 45)) -d14 = OpReg W64 (RegReal (RealRegSingle 46)) -d15 = OpReg W64 (RegReal (RealRegSingle 47)) -d16 = OpReg W64 (RegReal (RealRegSingle 48)) -d17 = OpReg W64 (RegReal (RealRegSingle 49)) -d18 = OpReg W64 (RegReal (RealRegSingle 50)) -d19 = OpReg W64 (RegReal (RealRegSingle 51)) -d20 = OpReg W64 (RegReal (RealRegSingle 52)) -d21 = OpReg W64 (RegReal (RealRegSingle 53)) -d22 = OpReg W64 (RegReal (RealRegSingle 54)) -d23 = OpReg W64 (RegReal (RealRegSingle 55)) -d24 = OpReg W64 (RegReal (RealRegSingle 56)) -d25 = OpReg W64 (RegReal (RealRegSingle 57)) -d26 = OpReg W64 (RegReal (RealRegSingle 58)) -d27 = OpReg W64 (RegReal (RealRegSingle 59)) -d28 = OpReg W64 (RegReal (RealRegSingle 60)) -d29 = OpReg W64 (RegReal (RealRegSingle 61)) -d30 = OpReg W64 (RegReal (RealRegSingle 62)) -d31 = OpReg W64 (RegReal (RealRegSingle 63)) +d0 = operandFromRegNo d0RegNo +d1 = operandFromRegNo 33 +d2 = operandFromRegNo 34 +d3 = operandFromRegNo 35 +d4 = operandFromRegNo 36 +d5 = operandFromRegNo 37 +d6 = operandFromRegNo 38 +d7 = operandFromRegNo d7RegNo +d8 = operandFromRegNo 40 +d9 = operandFromRegNo 41 +d10 = operandFromRegNo d10RegNo +d11 = operandFromRegNo 43 +d12 = operandFromRegNo 44 +d13 = operandFromRegNo 45 +d14 = operandFromRegNo 46 +d15 = operandFromRegNo 47 +d16 = operandFromRegNo 48 +d17 = operandFromRegNo d17RegNo +d18 = operandFromRegNo 50 +d19 = operandFromRegNo 51 +d20 = operandFromRegNo 52 +d21 = operandFromRegNo 53 +d22 = operandFromRegNo 54 +d23 = operandFromRegNo 55 +d24 = operandFromRegNo 56 +d25 = operandFromRegNo 57 +d26 = operandFromRegNo 58 +d27 = operandFromRegNo 59 +d28 = operandFromRegNo 60 +d29 = operandFromRegNo 61 +d30 = operandFromRegNo 62 +d31 = operandFromRegNo d31RegNo opRegSExt :: Width -> Reg -> Operand opRegSExt W64 r = OpRegExt W64 r ESXTX 0 @@ -981,7 +978,8 @@ makeFarBranches info_env blocks -- 262144 (2^20 / 4) instructions are allowed; let's keep some distance, as -- we have pseudo-insns that are pretty-printed as multiple instructions, - -- and it's just not worth the effort to calculate things exactly. The + -- and it's just not worth the effort to calculate things exactly as linker + -- relaxations are applied later (optimizing away our flaws.) The -- conservative guess here is that every instruction does not emit more than -- two in the mean. nearLimit = 131072 - mapSize info_env * maxRetInfoTableSizeW ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -304,6 +304,7 @@ negOp (OpImm (ImmInt i)) = OpImm (ImmInt (negate i)) negOp (OpImm (ImmInteger i)) = OpImm (ImmInteger (negate i)) negOp op = pprPanic "RV64.negOp" (text $ show op) +-- TODO: Is this used in RISCV?! pprExt :: IsLine doc => ExtMode -> doc pprExt EUXTB = text "uxtb" pprExt EUXTH = text "uxth" @@ -314,6 +315,7 @@ pprExt ESXTH = text "sxth" pprExt ESXTW = text "sxtw" pprExt ESXTX = text "sxtx" +-- TODO: Is this used in RISCV?! pprShift :: IsLine doc => ShiftMode -> doc pprShift SLSL = text "lsl" pprShift SLSR = text "lsr" @@ -328,8 +330,6 @@ pprOp plat op = case op of OpRegShift w r s i -> pprReg w r <> comma <+> pprShift s <+> char '#' <> int i OpImm im -> pprIm plat im OpImmShift im s i -> pprIm plat im <> comma <+> pprShift s <+> char '#' <> int i - -- TODO: Address computation always use registers as 64bit -- is this correct? - OpAddr (AddrRegReg r1 r2) -> pprPanic "No Reg-Reg addressing mode in Riscv" (text $ show op) -- char '[' <+> pprReg W64 r1 <> comma <+> pprReg W64 r2 <+> char ']' OpAddr (AddrRegImm r1 im) -> pprImm plat im <> char '(' <> pprReg W64 r1 <> char ')' OpAddr (AddrReg r1) -> text "0(" <+> pprReg W64 r1 <+> char ')' ===================================== compiler/GHC/CmmToAsm/RV64/Regs.hs ===================================== @@ -16,42 +16,87 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Platform +-- | First integer register number. @zero@ register. +x0RegNo :: RegNo +x0RegNo = 0 + +x5RegNo, t0RegNo :: RegNo +x5RegNo = 5 +t0RegNo = x5RegNo + +x7RegNo, t2RegNo :: RegNo +x7RegNo = 7 +t2RegNo = x7RegNo + +x28RegNo, t3RegNo :: RegNo +x28RegNo = 28 +t3RegNo = x28RegNo + +-- | Last integer register number. Used as IP register. +x31RegNo, t6RegNo, ipRegNo :: RegNo +x31RegNo = 31 +t6RegNo = x31RegNo +ipRegNo = x31RegNo + +-- | First floating point register. +d0RegNo, ft0RegNo :: RegNo +d0RegNo = 32 +ft0RegNo = d0RegNo + +d7RegNo, ft7RegNo :: RegNo +d7RegNo = 39 +ft7RegNo = d7RegNo + +-- | Last floating point register. +d31RegNo :: RegNo +d31RegNo = 63 + +a0RegNo, x10RegNo :: RegNo +x10RegNo = 10 +a0RegNo = x10RegNo + +a7RegNo, x17RegNo :: RegNo +x17RegNo = 17 +a7RegNo = x17RegNo + +fa0RegNo, d10RegNo :: RegNo +d10RegNo = 42 +fa0RegNo = d10RegNo + +fa7RegNo, d17RegNo :: RegNo +d17RegNo = 49 +fa7RegNo = d17RegNo + +-- | All machine register numbers. allMachRegNos :: [RegNo] -allMachRegNos = [0 .. 31] ++ [32 .. 63] +allMachRegNos = intRegs ++ fpRegs + where + intRegs = [x0RegNo .. x31RegNo] + fpRegs = [d0RegNo .. d31RegNo] --- allocatableRegs is allMachRegNos with the fixed-use regs removed. --- i.e., these are the regs for which we are prepared to allow the --- register allocator to attempt to map VRegs to. +-- | Registers available to the register allocator. +-- +-- These are all registers minus those with a fixed role in RISCV ABI (zero, lr, +-- sp, gp, tp, fp, ip) and GHC RTS (Base, Sp, Hp, HpLim, R1..R8, F1..F6, +-- D1..D6.) allocatableRegs :: Platform -> [RealReg] -allocatableRegs platform - = let isFree = freeReg platform - in map RealRegSingle $ filter isFree allMachRegNos +allocatableRegs platform = + let isFree = freeReg platform + in map RealRegSingle $ filter isFree allMachRegNos --- argRegs is the set of regs which are read for an n-argument call to C. +-- | Integer argument registers according to the calling convention allGpArgRegs :: [Reg] -allGpArgRegs = map regSingle [10..17] -allFpArgRegs :: [Reg] -allFpArgRegs = map regSingle [42..49] - --- STG: --- 19: Base --- 20: Sp --- 21: Hp --- 22-27: R1-R6 --- 28: SpLim - --- This is the STG Sp reg. --- sp :: Reg --- sp = regSingle 20 +allGpArgRegs = map regSingle [a0RegNo .. a7RegNo] --- addressing modes ------------------------------------------------------------ +-- | Floating point argument registers according to the calling convention +allFpArgRegs :: [Reg] +allFpArgRegs = map regSingle [fa0RegNo .. fa7RegNo] --- TODO: AddrRegReg constructor is never used. Remove it? +-- | Addressing modes data AddrMode - = AddrRegReg Reg Reg - | AddrRegImm Reg Imm - | AddrReg Reg - deriving (Eq, Show) + = AddrRegImm Reg Imm + | AddrReg Reg + deriving (Eq, Show) -- ----------------------------------------------------------------------------- -- Immediates @@ -68,25 +113,20 @@ data Imm | ImmConstantDiff Imm Imm deriving (Eq, Show) -strImmLit :: FastString -> Imm -strImmLit s = ImmLit s - - litToImm :: CmmLit -> Imm -litToImm (CmmInt i w) = ImmInteger (narrowS w i) - -- narrow to the width: a CmmInt might be out of - -- range, but we assume that ImmInteger only contains - -- in-range values. A signed value should be fine here. -litToImm (CmmFloat f W32) = ImmFloat f -litToImm (CmmFloat f W64) = ImmDouble f -litToImm (CmmLabel l) = ImmCLbl l +litToImm (CmmInt i w) = ImmInteger (narrowS w i) +-- narrow to the width: a CmmInt might be out of +-- range, but we assume that ImmInteger only contains +-- in-range values. A signed value should be fine here. +litToImm (CmmFloat f W32) = ImmFloat f +litToImm (CmmFloat f W64) = ImmDouble f +litToImm (CmmLabel l) = ImmCLbl l litToImm (CmmLabelOff l off) = ImmIndex l off -litToImm (CmmLabelDiffOff l1 l2 off _) - = ImmConstantSum - (ImmConstantDiff (ImmCLbl l1) (ImmCLbl l2)) - (ImmInt off) -litToImm _ = panic "RV64.Regs.litToImm: no match" - +litToImm (CmmLabelDiffOff l1 l2 off _) = + ImmConstantSum + (ImmConstantDiff (ImmCLbl l1) (ImmCLbl l2)) + (ImmInt off) +litToImm l = panic $ "RV64.Regs.litToImm: no match for " ++ show l -- == To satisfy GHC.CmmToAsm.Reg.Target ======================================= @@ -116,21 +156,19 @@ virtualRegSqueeze cls vr {-# INLINE realRegSqueeze #-} realRegSqueeze :: RegClass -> RealReg -> Int -realRegSqueeze cls rr - = case cls of - RcInteger - -> case rr of - RealRegSingle regNo - | regNo < 32 -> 1 -- first fp reg is 32 - | otherwise -> 0 - - RcDouble - -> case rr of - RealRegSingle regNo - | regNo < 32 -> 0 - | otherwise -> 1 - - _other -> 0 +realRegSqueeze cls rr = + case cls of + RcInteger -> + case rr of + RealRegSingle regNo + | regNo < d0RegNo -> 1 + | otherwise -> 0 + RcDouble -> + case rr of + RealRegSingle regNo + | regNo < d0RegNo -> 0 + | otherwise -> 1 + _other -> 0 mkVirtualReg :: Unique -> Format -> VirtualReg mkVirtualReg u format @@ -141,11 +179,11 @@ mkVirtualReg u format FF64 -> VirtualRegD u _ -> panic "RV64.mkVirtualReg" -{-# INLINE classOfRealReg #-} +{-# INLINE classOfRealReg #-} classOfRealReg :: RealReg -> RegClass classOfRealReg (RealRegSingle i) - | i < 32 = RcInteger - | otherwise = RcDouble + | i < d0RegNo = RcInteger + | otherwise = RcDouble regDotColor :: RealReg -> SDoc regDotColor reg View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b73cf299516bd383b1f14baf073df100d1369dd...da053cea8d36f62887083575202a01da261dd492 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b73cf299516bd383b1f14baf073df100d1369dd...da053cea8d36f62887083575202a01da261dd492 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 20:17:33 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Tue, 05 Mar 2024 15:17:33 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Try sequence LintM actions strictly Message-ID: <65e77dddbfe7a_28e20eaab81b41332fe@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: dc77120b by Mikolaj Konarski at 2024-03-05T21:17:12+01:00 Try sequence LintM actions strictly - - - - - 1 changed file: - compiler/GHC/Core/Lint.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1950,14 +1950,15 @@ lintType (TyVarTy tv) | otherwise = do { subst <- getSubst - ; case lookupTyVar subst tv of - Just linted_ty -> return linted_ty - - -- In GHCi we may lint an expression with a free - -- type variable. Then it won't be in the - -- substitution, but it should be in scope - Nothing -> do { checkTyCoVarInScope subst tv - ; return (TyVarTy tv) } + ; let !f = unLintM $ case lookupTyVar subst tv of + Just linted_ty -> return linted_ty + + -- In GHCi we may lint an expression with a free + -- type variable. Then it won't be in the + -- substitution, but it should be in scope + Nothing -> do { checkTyCoVarInScope subst tv + ; return (TyVarTy tv) } + ; LintM f } lintType ty@(AppTy t1 t2) @@ -2327,10 +2328,11 @@ lintCoercion (CoVarCo cv) | otherwise = do { subst <- getSubst - ; case lookupCoVar subst cv of - Just linted_co -> return linted_co ; - Nothing -> do { checkTyCoVarInScope subst cv - ; return (CoVarCo cv) } + ; let !f = unLintM $ case lookupCoVar subst cv of + Just linted_co -> return linted_co ; + Nothing -> do { checkTyCoVarInScope subst cv + ; return (CoVarCo cv) } + ; LintM f } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc77120b0d214626e6dbaab64904ddc96793108b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc77120b0d214626e6dbaab64904ddc96793108b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 21:49:19 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 05 Mar 2024 16:49:19 -0500 Subject: [Git][ghc/ghc][wip/t24277] base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <65e7935fb18c8_28e20ed0a84b41338d5@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: f0f9cb82 by Finley McIlwaine at 2024-03-05T13:49:06-08:00 base: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Stack` and `GHC.Exts`. Also add an opaque exposed type for cost center ids, `CostCentreId`, with appropriate instances. Implements CLC proposal 235. Resolves #24277 - - - - - 11 changed files: - docs/users_guide/9.10.1-notes.rst - libraries/base/changelog.md - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -244,6 +244,12 @@ Runtime system constructors in scope and the levity of ``t`` is statically known, then the constraint ``DataToTag t`` can always be solved. +- The ``CostCentreId`` type and ``currentCallStackIds :: IO [CostCentreId]`` + function for getting the IDs of the cost centers on the current stack are now + exported from ``GHC.Exts``. In addition to those, the ``ccId`` and + ``ccsToIds`` functions for getting ``CostCentreId``\s are also exported from + ``GHC.Stack``. + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Export `CostCentreId` from `GHC.Exts` and `GHC.Stack` + * Export `currentCallStackIds` from `GHC.Exts` and `GHC.Stack` + * Export `ccId` and `ccsToIds` from `GHC.Stack` + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -84,6 +84,8 @@ module GHC.Exts traceEvent, -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, ===================================== libraries/base/src/GHC/Stack.hs ===================================== @@ -18,6 +18,7 @@ module GHC.Stack (errorWithStackTrace, -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks CallStack, @@ -37,16 +38,19 @@ module GHC.Stack -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where -import GHC.Internal.Stack \ No newline at end of file +import GHC.Internal.Stack ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -24,6 +25,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +40,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -5373,6 +5373,8 @@ module GHC.Exts where data Compact# type Constraint :: * type Constraint = CONSTRAINT LiftedRep + type CostCentreId :: * + newtype CostCentreId = ... type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint class DataToTag a where dataToTag# :: a -> Int# @@ -5758,6 +5760,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9305,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9314,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11557,6 +11565,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11641,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12024,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12136,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12210,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12257,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12434,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12632,6 +12647,7 @@ instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12813,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -5727,6 +5727,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -12344,6 +12345,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -12351,14 +12354,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -12380,14 +12386,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String @@ -14592,6 +14601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -14667,6 +14677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -15051,6 +15062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -15162,6 +15174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15235,6 +15248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15281,6 +15295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -15659,6 +15674,7 @@ instance GHC.Classes.Eq GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15824,6 +15840,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -5519,6 +5519,8 @@ module GHC.Exts where data Compact# type Constraint :: * type Constraint = CONSTRAINT LiftedRep + type CostCentreId :: * + newtype CostCentreId = ... type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint class DataToTag a where dataToTag# :: a -> Int# @@ -5907,6 +5909,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9526,6 +9529,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9533,14 +9538,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO CostCentreId ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [CostCentreId] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [CostCentreId] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -11821,6 +11829,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11897,6 +11906,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Enum.Enum GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12291,6 +12301,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12403,6 +12414,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Read.Read GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12476,6 +12488,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12522,6 +12535,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12695,6 +12709,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.ConsoleEvent.ConsoleE instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Event.Windows.CbResult a) -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12907,6 +12922,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Classes.Eq GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -13075,6 +13091,7 @@ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.I instance GHC.Classes.Ord GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Ord GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -5758,6 +5758,7 @@ module GHC.Exts where ctz64# :: Word64# -> Word# ctz8# :: Word# -> Word# currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] deRefStablePtr# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) deRefWeak# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)). Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #) @@ -9302,6 +9303,8 @@ module GHC.Stack where data CallStack = ... type CostCentre :: * data CostCentre + type CostCentreId :: * + newtype CostCentreId = ... type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint @@ -9309,14 +9312,17 @@ module GHC.Stack where type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] emptyCallStack :: CallStack errorWithStackTrace :: forall a. GHC.Internal.Base.String -> a freezeCallStack :: CallStack -> CallStack @@ -9338,14 +9344,17 @@ module GHC.Stack.CCS where data CostCentre type CostCentreStack :: * data CostCentreStack + ccId :: GHC.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Word.Word32 ccLabel :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccModule :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccSrcSpan :: GHC.Internal.Ptr.Ptr CostCentre -> GHC.Types.IO GHC.Internal.Foreign.C.String.Encoding.CString ccsCC :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentre) ccsParent :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) + ccsToIds :: GHC.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Word.Word32] ccsToStrings :: GHC.Internal.Ptr.Ptr CostCentreStack -> GHC.Types.IO [GHC.Internal.Base.String] clearCCS :: forall a. GHC.Types.IO a -> GHC.Types.IO a currentCallStack :: GHC.Types.IO [GHC.Internal.Base.String] + currentCallStackIds :: GHC.Types.IO [GHC.Word.Word32] getCCSOf :: forall a. a -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) getCurrentCCS :: forall dummy. dummy -> GHC.Types.IO (GHC.Internal.Ptr.Ptr CostCentreStack) renderStack :: [GHC.Internal.Base.String] -> GHC.Internal.Base.String @@ -11557,6 +11566,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11632,6 +11642,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12014,6 +12025,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12125,6 +12137,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12198,6 +12211,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12244,6 +12258,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12420,6 +12435,7 @@ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Internal instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12633,6 +12649,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12797,6 +12814,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f0f9cb82b786a7007604a6abcc3b603f56458393 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f0f9cb82b786a7007604a6abcc3b603f56458393 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 22:00:36 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 05 Mar 2024 17:00:36 -0500 Subject: [Git][ghc/ghc][wip/T24471] 8 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e7960488095_28e20ed92baa013414e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 7841fb71 by Ben Gamari at 2024-03-05T22:00:21+00:00 ghc-experimental: Add dummy dependencies to work around #24436 This is a temporary measure to improve CI reliability until a proper solution is developed. - - - - - 5c227bca by Simon Peyton Jones at 2024-03-05T22:00:21+00:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 18 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/filepath - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-experimental/src/GHC/Profiling/Eras.hs - libraries/ghc-internal/ghc-internal.cabal - libraries/os-string - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -1031,7 +1031,7 @@ job_groups = -- (see Note [Object unloading]). fullyStaticBrokenTests = modifyJobs (addVariable "BROKEN_TESTS" "ghcilink002 linker_unload_native") - hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-base-url") + hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-for-hackage") tsan_jobs = modifyJobs ===================================== .gitlab/jobs.yaml ===================================== @@ -2330,7 +2330,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url", + "HADRIAN_ARGS": "--haddock-for-hackage", "LLC": "/bin/false", "OPT": "/bin/false", "RUNTEST_ARGS": "", @@ -4007,7 +4007,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release", "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--haddock-base-url --hash-unit-ids", + "HADRIAN_ARGS": "--haddock-for-hackage --hash-unit-ids", "IGNORE_PERF_FAILURES": "all", "LLC": "/bin/false", "OPT": "/bin/false", ===================================== .gitlab/rel_eng/upload_ghc_libs.py ===================================== @@ -49,6 +49,10 @@ def prep_base(): shutil.copy('config.guess', 'libraries/base') shutil.copy('config.sub', 'libraries/base') +def prep_ghc_internal(): + shutil.copy('config.guess', 'libraries/ghc-internal') + shutil.copy('config.sub', 'libraries/ghc-internal') + def build_copy_file(pkg: Package, f: Path): target = Path('_build') / 'stage1' / pkg.path / 'build' / f dest = pkg.path / f @@ -93,6 +97,8 @@ PACKAGES = { pkg.name: pkg for pkg in [ Package('base', Path("libraries/base"), prep_base), + Package('ghc-internal', Path("libraries/ghc-internal"), prep_ghc_internal), + Package('ghc-experimental', Path("libraries/ghc-experimental"), no_prep), Package('ghc-prim', Path("libraries/ghc-prim"), prep_ghc_prim), Package('integer-gmp', Path("libraries/integer-gmp"), no_prep), Package('ghc-bignum', Path("libraries/ghc-bignum"), prep_ghc_bignum), ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== hadrian/README.md ===================================== @@ -306,9 +306,9 @@ all of the documentation targets: You can pass several `--docs=...` flags, Hadrian will combine their effects. -To build haddock documentation for upload to hackage you need to pass the `--haddock-base-url` flag, -by default this will choose a url suitable for uploading to hackage but you might also want to pass something like -`http://127.0.0.1:8080/package/%pkg%/docs` for testing upload locally on a local hackage server. +To build haddock documentation for upload to hackage you need to pass the `--haddock-for-hackage` flag, +This will generate URLs which are appropiate for either uploading to a local hackage +server or the global hackage server. #### Source distribution ===================================== hadrian/src/CommandLine.hs ===================================== @@ -17,7 +17,6 @@ import System.Environment import qualified System.Directory as Directory import qualified Data.Set as Set -import Data.Maybe data TestSpeed = TestSlow | TestNormal | TestFast deriving (Show, Eq) @@ -114,7 +113,7 @@ data DocArgs = DocArgs } deriving (Eq, Show) defaultDocArgs :: DocArgs -defaultDocArgs = DocArgs { docsBaseUrl = "../%pkg%" } +defaultDocArgs = DocArgs { docsBaseUrl = "../%pkgid%" } readConfigure :: Either String (CommandLineArgs -> CommandLineArgs) readConfigure = Left "hadrian --configure has been deprecated (see #20167). Please run ./boot; ./configure manually" @@ -192,11 +191,11 @@ readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testO readTestSkipPerf :: Either String (CommandLineArgs -> CommandLineArgs) readTestSkipPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testSkipPerf = True } } -readHaddockBaseUrl :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) -readHaddockBaseUrl base_url = Right $ \flags -> - flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url' } } +readHaddockBaseUrl :: Either String (CommandLineArgs -> CommandLineArgs) +readHaddockBaseUrl = Right $ \flags -> + flags { docsArgs = (docsArgs flags) { docsBaseUrl = base_url } } - where base_url' = fromMaybe "https://hackage.haskell.org/package/%pkg%/docs" base_url + where base_url = "/package/%pkg%/docs" readTestRootDirs :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) @@ -320,8 +319,8 @@ optDescrs = "Destination path for the bindist 'install' rule" , Option [] ["complete-setting"] (OptArg readCompleteStg "SETTING") "Setting key to autocomplete, for the 'autocomplete' target." - , Option [] ["haddock-base-url"] (OptArg readHaddockBaseUrl "BASE_URL") - "Generate documentation suitable for upload to hackage or for another base URL (for example a local hackage server)." + , Option [] ["haddock-for-hackage"] (NoArg readHaddockBaseUrl) + "Generate documentation suitable for upload to a hackage server." ] -- | A type-indexed map containing Hadrian command line arguments to be passed ===================================== hadrian/src/Settings/Builders/Haddock.hs ===================================== @@ -43,12 +43,15 @@ haddockBuilderArgs = mconcat version <- expr $ pkgVersion pkg synopsis <- expr $ pkgSynopsis pkg haddocks <- expr $ haddockDependencies context - haddocks_with_versions <- expr $ sequence $ [(,h) <$> pkgUnitId stage p | (p, h) <- haddocks] + haddocks_with_versions <- expr $ sequence $ [(,,h) <$> pkgSimpleIdentifier p <*> pkgUnitId stage p | (p, h) <- haddocks] hVersion <- expr $ pkgVersion haddock statsDir <- expr $ haddockStatsFilesDir baseUrlTemplate <- expr (docsBaseUrl <$> userSetting defaultDocArgs) - let baseUrl p = substituteTemplate baseUrlTemplate p + -- The path to where the docs for a package are + let docpath p = substituteTemplate baseUrlTemplate p + -- The path to where the src folder is for a package (typically docs ++ "/src/") + let srcpath p = docpath p ++ "/src/" ghcOpts <- haddockGhcArgs -- These are the options which are necessary to perform the build. Additional -- options such as `--hyperlinked-source`, `--hoogle`, `--quickjump` are @@ -67,14 +70,18 @@ haddockBuilderArgs = mconcat , arg $ "--optghc=-D__HADDOCK_VERSION__=" ++ show (versionToInt hVersion) , map ("--hide=" ++) <$> getContextData otherModules - , pure [ "--read-interface=../" ++ p - ++ "," ++ baseUrl p ++ "/src/%{MODULE}.html#%{NAME}," - ++ haddock | (p, haddock) <- haddocks_with_versions ] + , pure [ "--read-interface=" ++ docpath (p, pid) + ++ "," ++ srcpath (p, pid) ++ "," + ++ haddock | (p, pid, haddock) <- haddocks_with_versions ] , pure [ "--optghc=" ++ opt | opt <- ghcOpts, not ("--package-db" `isInfixOf` opt) ] , arg "+RTS" , arg $ "-t" ++ (statsDir -/- pkgName pkg ++ ".t") , arg "--machine-readable" , arg "-RTS" ] ] -substituteTemplate :: String -> String -> String -substituteTemplate baseTemplate pkgId = T.unpack . T.replace "%pkg%" (T.pack pkgId) . T.pack $ baseTemplate +substituteTemplate :: String -> (String, String) -> String +substituteTemplate baseTemplate (pkg, pkgId) = + T.unpack + . T.replace "%pkg%" (T.pack pkg) + . T.replace "%pkgid%" (T.pack pkgId) + . T.pack $ baseTemplate ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit b55465e3d174ccd63914e7146079435503204187 +Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -80,4 +80,5 @@ module Data.Sum.Experimental ( Sum63#, ) where +import GHC.Num.BigNat () -- for build ordering import GHC.Types ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,4 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes +import GHC.Num.BigNat () -- for build ordering ===================================== libraries/ghc-experimental/src/GHC/Profiling/Eras.hs ===================================== @@ -1,7 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} --- | TODO move this module into ghc-internals module GHC.Profiling.Eras ( setUserEra , getUserEra , incrementUserEra ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -17,7 +17,7 @@ description: extra-tmp-files: autom4te.cache - base.buildinfo + ghc-internal.buildinfo config.log config.status include/EventConfig.h @@ -25,8 +25,8 @@ extra-tmp-files: extra-source-files: aclocal.m4 - base.buildinfo.in - changelog.md + ghc-internal.buildinfo.in + CHANGELOG.md configure configure.ac include/CTypes.h ===================================== libraries/os-string ===================================== @@ -1 +1 @@ -Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216 +Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8 ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [ collect_compiler_stats('all', 5) ], + multimod_compile, ['T24471', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/557ac3d9646c37baf627e784cf078bf9cb866f6f...5c227bca89edb27b4328b9ed8b28c393d4cc312a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/557ac3d9646c37baf627e784cf078bf9cb866f6f...5c227bca89edb27b4328b9ed8b28c393d4cc312a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 5 22:50:47 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Tue, 05 Mar 2024 17:50:47 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Make sure the foldl' accumulators are strict Message-ID: <65e7a1c7511d1_28e20eec8815c1388ed@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: f6f06963 by Mikolaj Konarski at 2024-03-05T23:50:20+01:00 Make sure the foldl' accumulators are strict - - - - - 2 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Types/Unique/DSet.hs Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1905,7 +1905,7 @@ foldTyCo (TyCoFolder { tcf_view = view go_prov env (ProofIrrelProv co) = go_co env co go_prov _ (PluginProv _ cvs) = go_cvs env cvs - go_cvs env cvs = foldl' (\acc cv -> acc `mappend` covar env cv) mempty (dVarSetElems cvs) + go_cvs env cvs = foldl' (\ !acc cv -> acc `mappend` covar env cv) mempty (dVarSetElems cvs) -- | A view function that looks through nothing. noView :: Type -> Maybe Type ===================================== compiler/GHC/Types/Unique/DSet.hs ===================================== @@ -132,7 +132,7 @@ mapUniqDSet f (UniqDSet m) = UniqDSet $ unsafeCastUDFMKey $ mapUDFM f m -- mapping from DFM. strictFoldUniqDSet :: (a -> r -> r) -> r -> UniqDSet a -> r -strictFoldUniqDSet k r s = foldl' (\r e -> k e r) r $ +strictFoldUniqDSet k r s = foldl' (\ !r e -> k e r) r $ uniqDSetToList s -- Two 'UniqDSet's are considered equal if they contain the same View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6f06963c8e6dc0b027323dfcfb3cc5637ee5d3b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6f06963c8e6dc0b027323dfcfb3cc5637ee5d3b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 00:47:03 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 05 Mar 2024 19:47:03 -0500 Subject: [Git][ghc/ghc][wip/T24471] 2 commits: ghc-experimental: Add dummy dependencies to work around #23942 Message-ID: <65e7bd076b230_28e20e11efeadc1538e3@gitlab.mail> Ben Gamari pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 3e892fe5 by Ben Gamari at 2024-03-05T19:45:07-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 8d1384b1 by Simon Peyton Jones at 2024-03-05T19:45:53-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 8 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -80,4 +80,5 @@ module Data.Sum.Experimental ( Sum63#, ) where +import GHC.Num.BigNat () -- for build ordering import GHC.Types ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,4 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes +import GHC.Num.BigNat () -- for build ordering ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [ collect_compiler_stats('all', 5) ], + multimod_compile, ['T24471', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c227bca89edb27b4328b9ed8b28c393d4cc312a...8d1384b1156be380b3d64eefbba4de756cd3f366 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c227bca89edb27b4328b9ed8b28c393d4cc312a...8d1384b1156be380b3d64eefbba4de756cd3f366 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 00:51:00 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Tue, 05 Mar 2024 19:51:00 -0500 Subject: [Git][ghc/ghc][wip/T23942] Keep explicit imports for built-in deps in ghc-prim Message-ID: <65e7bdf4b0f7c_28e20e121e6bb41629f7@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 7ed41803 by Matthew Craven at 2024-03-05T19:49:06-05:00 Keep explicit imports for built-in deps in ghc-prim It's very sad to have to do so, but see wrinkle TID3. Hopefully this changes soon. - - - - - 2 changed files: - compiler/GHC/Driver/MakeFile.hs - libraries/ghc-prim/GHC/Tuple.hs Changes: ===================================== compiler/GHC/Driver/MakeFile.hs ===================================== @@ -306,7 +306,7 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ node)) mhome_unit = hsc_home_unit_maybe hsc_env mb_found <- findExactModule fc fopts other_fopts unit_state mhome_unit im case mb_found of - InstalledFound ml _ -> handle_hi_file (ml_hi_file ml) + InstalledFound modLoc _ -> handle_hi_file (ml_hi_file modLoc) InstalledNoPackage _ -> panic "processDeps.do_implicit_import" InstalledNotFound _ _ -> panic "processDeps.do_implicit_import" @@ -314,12 +314,16 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ node)) ; unless (ms_mod node == gHC_TYPES) $ do_implicit_import gHC_TYPES - -- A module may implicitly depend on GHC.Tuple if ListTuplePuns is set ; unless (isHomeUnitInstanceOf (hsc_home_unit hsc_env) primUnitId) $ do - { -- see Note [Tracking implicit dependencies], wrinkle TID2 - when (xopt ListTuplePuns dflags) $ - do_implicit_import gHC_INTERNAL_TUPLE - -- see Note [Tracking implicit dependencies], wrinkle TID4 + { -- A module may implicitly depend on GHC.Tuple and GHC.Classes + -- if ListTuplePuns is set, but see wrinkle TID2. + when (xopt ListTuplePuns dflags) $ do + { do_implicit_import gHC_INTERNAL_TUPLE + ; do_implicit_import gHC_CLASSES + } + + -- Any module containing a string literal implicitly + -- depends on GHC.CString, but see wrinkle TID4. ; do_implicit_import gHC_CSTRING } } @@ -332,6 +336,7 @@ files to look up even if they are not imported. They include * Monad-related stuff in GHC.Internal.Base, if `do` notation is used * Tuple-related stuff in GHC.Tuple, if the built-in tuple syntax is used + * Constraint tuples in GHC.Classes, if the built-in tuple syntax is used * TypeRep-related stuff in GHC.Types, unless `-dno-typeable-binds` is set * deriving-related stuff mostly elsewhere in ghc-prim * GHC.CString.unpackCString# et al, if string literals are used @@ -342,13 +347,13 @@ interfaces. So we include them in our -M output if -include-pkg-deps is set, with the following wrinkles: (TID1) We don't actually bother adding implicit dependencies for - Monad, Arrow, etc. because the program will presumably fail to - typecheck unless these are reachable via explicit imports anyway. + Monad, Arrow, etc. because the program will fail to typecheck anyway + unless these are reachable via explicit imports. -(TID2) Users can opt out of implicitly depending on GHC.Tuple with the - NoListTuplePuns languge extension. Ideally we would just turn off - ListTuplePuns in the bits of ghc-prim that GHC.Tuple depends on, but - when I tried, I got stupid errors like this: +(TID2) Users can opt out of implicitly depending on GHC.Tuple and + GHC.Classes with the NoListTuplePuns languge extension. Ideally we + would just turn off ListTuplePuns in the bits of ghc-prim that these + modules depend on, but when I tried, I got stupid errors like this: libraries/ghc-prim/GHC/Types.hs:371:15: error: [GHC-46574] Cannot parse data constructor in a data/newtype declaration: [] @@ -358,22 +363,41 @@ is set, with the following wrinkles: So for now we don't emit this dependency in the `ghc-prim` package, which must explicitly import GHC.Tuple for build-order reasons. - Yuck! But this doesn't make things in `ghc-prim` much worse, because - -(TID3) We don't even try to track dependencies involving `deriving`. - We try to prevent this from causing problems by ensuring that any - machinery `deriving` needs to reference related to a typeclass is - imported from the defining module for that class. For example, the - class Eq is defined in GHC.Classes, and derived Eq instances can - reference GHC.Magic.dataToTag#. So we make sure that GHC.Magic is - imported in GHC.Classes. + Yuck! But this doesn't make things in `ghc-prim` much worse, because... + +(TID3) Although we emit these extra dependencies with -M, this happens + via special handling in this file and GHC's downsweep does not + report these dependencies properly. Doing so would require a + breaking change to ModSummary to create a place to store these + built-in implicit dependencies in the output of downsweep, and is + left as future work. + + But for now this causes problems with documentation generation for + ghc-prim unless its internal dependencies are indicated by actual + import statements. Since ghc-prim is fairly small and generally + plays by its own rules anyway, this situation is deemed acceptable + for now. + +(TID4) Since we don't have a flag to disable string literals, any + module could potentially contain one and thus reference GHC.CString. + To avoid cyclic dependency problems, we don't emit this potential + implicit dependency on GHC.CString for any modules in `ghc-prim`. + + If there were any string literals in ghc-prim, their containing + modules would need to explicitly import GHC.CString. (But as of + March 2024 there are none anyway.) + +(TID5) We only indirectly track dependencies introduced by `deriving`. + Instead, we ensure that any machinery that might be referenced in a + derived instance for a class is imported in the module that defines + that class. For example, the class Eq is defined in GHC.Classes, + and derived Eq instances can reference GHC.Magic.dataToTag#. So we + make sure that GHC.Magic is imported in GHC.Classes. Then, since + any module containing a derived Eq instance must import Eq, such a + module automatically transitively depends on GHC.Magic. Failing to do this for the Lift class caused #22229, which is sadly still open as of March 2024. - -(TID4) Likewise, since we don't have a flag to disable string - literals, we always add an implicit dependency on GHC.CString for - any modules outside of `ghc-prim`. -} findDependency :: HscEnv ===================================== libraries/ghc-prim/GHC/Tuple.hs ===================================== @@ -29,6 +29,8 @@ module GHC.Tuple ( Tuple60(..), Tuple61(..), Tuple62(..), Tuple63(..), Tuple64(..), ) where +import GHC.Types () -- This import is for build ordering. (wrinkle TID3) + default () -- Double and Integer aren't available yet -- | The unit datatype @Unit@ has one non-undefined member, the nullary View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ed418039b26d7cc6ca442e41273caf589523c8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ed418039b26d7cc6ca442e41273caf589523c8a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 02:44:57 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 21:44:57 -0500 Subject: [Git][ghc/ghc][master] base: Reflect new era profiling RTS flags in GHC.RTS.Flags Message-ID: <65e7d8a93a8ce_33764fb3e2086e9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - 6 changed files: - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Add `HeapByEra`, `eraSelector` and `automaticEraIncrement` to `GHC.RTS.Flags` to + reflect the new RTS flags: `-he` profiling mode, `-he` selector and `--automatic-era-increment`. + ([CLC proposal #254](https://github.com/haskell/core-libraries-committee/issues/254)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -274,6 +274,7 @@ data DoHeapProfile | HeapByLDV | HeapByClosureType | HeapByInfoTable + | HeapByEra -- ^ @since base-4.20.0.0 deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -289,6 +290,7 @@ instance Enum DoHeapProfile where fromEnum HeapByLDV = #{const HEAP_BY_LDV} fromEnum HeapByClosureType = #{const HEAP_BY_CLOSURE_TYPE} fromEnum HeapByInfoTable = #{const HEAP_BY_INFO_TABLE} + fromEnum HeapByEra = #{const HEAP_BY_ERA} toEnum #{const NO_HEAP_PROFILING} = NoHeapProfiling toEnum #{const HEAP_BY_CCS} = HeapByCCS @@ -299,6 +301,7 @@ instance Enum DoHeapProfile where toEnum #{const HEAP_BY_LDV} = HeapByLDV toEnum #{const HEAP_BY_CLOSURE_TYPE} = HeapByClosureType toEnum #{const HEAP_BY_INFO_TABLE} = HeapByInfoTable + toEnum #{const HEAP_BY_ERA} = HeapByEra toEnum e = errorWithoutStackTrace ("invalid enum for DoHeapProfile: " ++ show e) -- | Parameters of the cost-center profiler @@ -311,6 +314,7 @@ data ProfFlags = ProfFlags , startHeapProfileAtStartup :: Bool , startTimeProfileAtStartup :: Bool -- ^ @since base-4.20.0.0 , showCCSOnException :: Bool + , automaticEraIncrement :: Bool -- ^ @since 4.20.0.0 , maxRetainerSetSize :: Word , ccsLength :: Word , modSelector :: Maybe String @@ -320,6 +324,7 @@ data ProfFlags = ProfFlags , ccsSelector :: Maybe String , retainerSelector :: Maybe String , bioSelector :: Maybe String + , eraSelector :: Word -- ^ @since base-4.20.0.0 } deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -633,6 +638,8 @@ getProfFlags = do (#{peek PROFILING_FLAGS, startTimeProfileAtStartup} ptr :: IO CBool)) <*> (toBool <$> (#{peek PROFILING_FLAGS, showCCSOnException} ptr :: IO CBool)) + <*> (toBool <$> + (#{peek PROFILING_FLAGS, incrementUserEra} ptr :: IO CBool)) <*> #{peek PROFILING_FLAGS, maxRetainerSetSize} ptr <*> #{peek PROFILING_FLAGS, ccsLength} ptr <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, modSelector} ptr) @@ -642,6 +649,7 @@ getProfFlags = do <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, ccsSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, retainerSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, bioSelector} ptr) + <*> #{peek PROFILING_FLAGS, eraSelector} ptr getTraceFlags :: IO TraceFlags getTraceFlags = do ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -12071,7 +12071,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -12122,6 +12122,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -12130,7 +12131,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -9253,7 +9253,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9304,6 +9304,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9312,7 +9313,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4074a3f2007a118f7ee0c953559c4ba7bc61d6dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4074a3f2007a118f7ee0c953559c4ba7bc61d6dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 02:45:37 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 21:45:37 -0500 Subject: [Git][ghc/ghc][master] JS: faster implementation for some numeric primitives (#23597) Message-ID: <65e7d8d1c7814_3376411530a0115e7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 1 changed file: - rts/js/arith.js Changes: ===================================== rts/js/arith.js ===================================== @@ -44,19 +44,23 @@ function h$hs_remWord64(h1,l1,h2,l2) { } function h$hs_timesWord64(h1,l1,h2,l2) { - var a = W64(h1,l1); - var b = W64(h2,l2); - var r = BigInt.asUintN(64, a * b); - TRACE_ARITH("Word64: " + a + " * " + b + " ==> " + r) - RETURN_W64(r); + var rh = h$mul2Word32(l1,l2); + var rl = h$ret1; + + rh += Math.imul(l1,h2)>>>0; + rh += Math.imul(l2,h1)>>>0; + rh >>>= 0; + + TRACE_ARITH("Word64: " + (h1,l1) + " * " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_minusWord64(h1,l1,h2,l2) { - var a = (BigInt(h1) << BigInt(32)) | BigInt(l1>>>0); - var b = (BigInt(h2) << BigInt(32)) | BigInt(l2>>>0); - var r = BigInt.asUintN(64, a - b); - TRACE_ARITH("Word64: " + a + " - " + b + " ==> " + r) - RETURN_W64(r); + var l = l1-l2; + var rl = l>>>0; + var rh = (h1-h2-(l!=rl?1:0))>>>0; + TRACE_ARITH("Word64: " + (h1,l1) + " - " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_plusWord64(h1,l1,h2,l2) { @@ -68,11 +72,15 @@ function h$hs_plusWord64(h1,l1,h2,l2) { } function h$hs_timesInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a * b); - TRACE_ARITH("Int64: " + a + " * " + b + " ==> " + r) - RETURN_I64(r); + var rh = h$mul2Word32(l1,l2); + var rl = h$ret1; + + rh += Math.imul(l1,h2)|0; + rh += Math.imul(l2,h1)|0; + rh |= 0; + + TRACE_ARITH("Int64: " + (h1,l1) + " * " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_quotInt64(h1,l1,h2,l2) { @@ -92,19 +100,19 @@ function h$hs_remInt64(h1,l1,h2,l2) { } function h$hs_plusInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a + b); - TRACE_ARITH("Int64: " + a + " + " + b + " ==> " + r) - RETURN_I64(r); + var l = l1+l2; + var rl = l>>>0; + var rh = (h1+h2+(l!=rl?1:0))|0; + TRACE_ARITH("Int64: " + (h1,l1) + " + " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_minusInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a - b); - TRACE_ARITH("Int64: " + a + " - " + b + " ==> " + r) - RETURN_I64(r); + var l = l1-l2; + var rl = l>>>0; + var rh = (h1-h2-(l!=rl?1:0))|0; + TRACE_ARITH("Int64: " + (h1,l1) + " - " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_uncheckedShiftLWord64(h,l,n) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a8c0e31b203a912484e9faf9d903ab5b141d82f3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a8c0e31b203a912484e9faf9d903ab5b141d82f3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 02:46:22 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 21:46:22 -0500 Subject: [Git][ghc/ghc][master] rts: add -xr option to control two step allocator reserved space size Message-ID: <65e7d8fed4461_33764136a9741665c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 6 changed files: - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/sm/MBlock.c - testsuite/tests/rts/all.T Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -232,6 +232,11 @@ Runtime system - Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. +- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual + memory address space reserved by the two step allocator on a 64-bit + platform. The default size is now 1T on aarch64 as well. See + :ghc-ticket:`24498`. + ``base`` library ~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -368,6 +368,18 @@ Miscellaneous RTS options thread can execute its exception handlers. The ``-xq`` controls the size of this additional quota. +.. rts-flag:: -xr ⟨size⟩ + + :default: 1T + + This option controls the size of virtual memory address space + reserved by the two step allocator on a 64-bit platform. It can be + useful in scenarios where even reserving a large address range + without committing can be expensive (e.g. WSL1), or when you + actually have enough physical memory and want to support a Haskell + heap larger than 1T. ``-xr`` is a no-op if GHC is configured with + ``--disable-large-address-space`` or if the platform is 32-bit. + .. _rts-options-gc: RTS options to control the garbage collector ===================================== rts/RtsFlags.c ===================================== @@ -186,6 +186,9 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.ringBell = false; RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */ + // 1 TBytes + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40; + RtsFlags.DebugFlags.scheduler = false; RtsFlags.DebugFlags.interpreter = false; RtsFlags.DebugFlags.weak = false; @@ -552,6 +555,11 @@ usage_text[] = { " -xq The allocation limit given to a thread after it receives", " an AllocationLimitExceeded exception. (default: 100k)", "", +#if defined(USE_LARGE_ADDRESS_SPACE) +" -xr The size of virtual memory address space reserved by the", +" two step allocator (default: 1T)", +"", +#endif " -Mgrace=", " The amount of allocation after the program receives a", " HeapOverflow exception before the exception is thrown again, if", @@ -1820,6 +1828,12 @@ error = true; / BLOCK_SIZE; break; + case 'r': + OPTION_UNSAFE; + RtsFlags.GcFlags.addressSpaceSize + = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_WORD64_MAX); + break; + default: OPTION_SAFE; errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -2118,7 +2132,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) m = atof(s); c = s[strlen(s)-1]; - if (c == 'g' || c == 'G') + if (c == 't' || c == 'T') + m *= (StgWord64)1024*1024*1024*1024; + else if (c == 'g' || c == 'G') m *= 1024*1024*1024; else if (c == 'm' || c == 'M') m *= 1024*1024; @@ -2737,4 +2753,3 @@ doingErasProfiling( void ) || RtsFlags.ProfFlags.eraSelector != 0); } #endif /* PROFILING */ - ===================================== rts/include/rts/Flags.h ===================================== @@ -89,6 +89,8 @@ typedef struct _GC_FLAGS { bool numa; /* Use NUMA */ StgWord numaMask; + + StgWord64 addressSpaceSize; /* large address space size in bytes */ } GC_FLAGS; /* See Note [Synchronization of flags and base APIs] */ ===================================== rts/sm/MBlock.c ===================================== @@ -659,20 +659,14 @@ initMBlocks(void) #if defined(USE_LARGE_ADDRESS_SPACE) { - W_ size; -#if defined(aarch64_HOST_ARCH) - size = (W_)1 << 38; // 1/4 TByte -#else - size = (W_)1 << 40; // 1 TByte -#endif void *startAddress = NULL; if (RtsFlags.GcFlags.heapBase) { startAddress = (void*) RtsFlags.GcFlags.heapBase; } - void *addr = osReserveHeapMemory(startAddress, &size); + void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize); mblock_address_space.begin = (W_)addr; - mblock_address_space.end = (W_)addr + size; + mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize; mblock_high_watermark = (W_)addr; } #elif SIZEOF_VOID_P == 8 ===================================== testsuite/tests/rts/all.T ===================================== @@ -3,7 +3,7 @@ test('testblockalloc', compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'), + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'), when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21e3f3250e88640087a1a60bee2cc113bf04509f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21e3f3250e88640087a1a60bee2cc113bf04509f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 03:47:03 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 05 Mar 2024 22:47:03 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: base: Reflect new era profiling RTS flags in GHC.RTS.Flags Message-ID: <65e7e736f2c98_33764334cbc020041@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - abb7e60b by Cheng Shao at 2024-03-05T22:46:52-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - fa2b8f22 by Cheng Shao at 2024-03-05T22:46:52-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - af81b7f2 by Ben Gamari at 2024-03-05T22:46:52-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - d0083779 by Simon Peyton Jones at 2024-03-05T22:46:52-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - libraries/base/changelog.md - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - rts/RtsFlags.c - rts/Sparks.c - rts/include/rts/Flags.h - rts/include/rts/storage/Block.h - rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h - rts/js/arith.js - rts/posix/OSMem.c - rts/rts.cabal - rts/sm/CNF.c - rts/sm/GC.h - rts/sm/MBlock.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/Sanity.c - rts/wasm/OSMem.c - rts/win32/OSMem.c - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - + testsuite/tests/perf/compiler/T24471.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/efcce4aab88b2d85ec3aa8670680217f78b6b341...d008377958d1790e4de54535dd2028685e2f2ecd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/efcce4aab88b2d85ec3aa8670680217f78b6b341...d008377958d1790e4de54535dd2028685e2f2ecd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 06:14:23 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Wed, 06 Mar 2024 01:14:23 -0500 Subject: [Git][ghc/ghc][wip/T24471] 5 commits: base: Reflect new era profiling RTS flags in GHC.RTS.Flags Message-ID: <65e809bfbb2cb_33764733d748320e5@gitlab.mail> Cheng Shao pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 74cb79b1 by Ben Gamari at 2024-03-06T06:12:17+00:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - d8161acc by Simon Peyton Jones at 2024-03-06T06:13:48+00:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 21 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - libraries/base/changelog.md - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/js/arith.js - rts/sm/MBlock.c - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/rts/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -232,6 +232,11 @@ Runtime system - Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. +- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual + memory address space reserved by the two step allocator on a 64-bit + platform. The default size is now 1T on aarch64 as well. See + :ghc-ticket:`24498`. + ``base`` library ~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -368,6 +368,18 @@ Miscellaneous RTS options thread can execute its exception handlers. The ``-xq`` controls the size of this additional quota. +.. rts-flag:: -xr ⟨size⟩ + + :default: 1T + + This option controls the size of virtual memory address space + reserved by the two step allocator on a 64-bit platform. It can be + useful in scenarios where even reserving a large address range + without committing can be expensive (e.g. WSL1), or when you + actually have enough physical memory and want to support a Haskell + heap larger than 1T. ``-xr`` is a no-op if GHC is configured with + ``--disable-large-address-space`` or if the platform is 32-bit. + .. _rts-options-gc: RTS options to control the garbage collector ===================================== libraries/base/changelog.md ===================================== @@ -50,6 +50,10 @@ * Treat all FDs as "nonblocking" on wasm32 ([CLC proposal #234](https://github.com/haskell/core-libraries-committee/issues/234)) + * Add `HeapByEra`, `eraSelector` and `automaticEraIncrement` to `GHC.RTS.Flags` to + reflect the new RTS flags: `-he` profiling mode, `-he` selector and `--automatic-era-increment`. + ([CLC proposal #254](https://github.com/haskell/core-libraries-committee/issues/254)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -80,4 +80,5 @@ module Data.Sum.Experimental ( Sum63#, ) where +import GHC.Num.BigNat () -- for build ordering import GHC.Types ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,4 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes +import GHC.Num.BigNat () -- for build ordering ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -274,6 +274,7 @@ data DoHeapProfile | HeapByLDV | HeapByClosureType | HeapByInfoTable + | HeapByEra -- ^ @since base-4.20.0.0 deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -289,6 +290,7 @@ instance Enum DoHeapProfile where fromEnum HeapByLDV = #{const HEAP_BY_LDV} fromEnum HeapByClosureType = #{const HEAP_BY_CLOSURE_TYPE} fromEnum HeapByInfoTable = #{const HEAP_BY_INFO_TABLE} + fromEnum HeapByEra = #{const HEAP_BY_ERA} toEnum #{const NO_HEAP_PROFILING} = NoHeapProfiling toEnum #{const HEAP_BY_CCS} = HeapByCCS @@ -299,6 +301,7 @@ instance Enum DoHeapProfile where toEnum #{const HEAP_BY_LDV} = HeapByLDV toEnum #{const HEAP_BY_CLOSURE_TYPE} = HeapByClosureType toEnum #{const HEAP_BY_INFO_TABLE} = HeapByInfoTable + toEnum #{const HEAP_BY_ERA} = HeapByEra toEnum e = errorWithoutStackTrace ("invalid enum for DoHeapProfile: " ++ show e) -- | Parameters of the cost-center profiler @@ -311,6 +314,7 @@ data ProfFlags = ProfFlags , startHeapProfileAtStartup :: Bool , startTimeProfileAtStartup :: Bool -- ^ @since base-4.20.0.0 , showCCSOnException :: Bool + , automaticEraIncrement :: Bool -- ^ @since 4.20.0.0 , maxRetainerSetSize :: Word , ccsLength :: Word , modSelector :: Maybe String @@ -320,6 +324,7 @@ data ProfFlags = ProfFlags , ccsSelector :: Maybe String , retainerSelector :: Maybe String , bioSelector :: Maybe String + , eraSelector :: Word -- ^ @since base-4.20.0.0 } deriving ( Show -- ^ @since base-4.8.0.0 , Generic -- ^ @since base-4.15.0.0 ) @@ -633,6 +638,8 @@ getProfFlags = do (#{peek PROFILING_FLAGS, startTimeProfileAtStartup} ptr :: IO CBool)) <*> (toBool <$> (#{peek PROFILING_FLAGS, showCCSOnException} ptr :: IO CBool)) + <*> (toBool <$> + (#{peek PROFILING_FLAGS, incrementUserEra} ptr :: IO CBool)) <*> #{peek PROFILING_FLAGS, maxRetainerSetSize} ptr <*> #{peek PROFILING_FLAGS, ccsLength} ptr <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, modSelector} ptr) @@ -642,6 +649,7 @@ getProfFlags = do <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, ccsSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, retainerSelector} ptr) <*> (peekCStringOpt =<< #{peek PROFILING_FLAGS, bioSelector} ptr) + <*> #{peek PROFILING_FLAGS, eraSelector} ptr getTraceFlags :: IO TraceFlags getTraceFlags = do ===================================== rts/RtsFlags.c ===================================== @@ -186,6 +186,9 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.ringBell = false; RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */ + // 1 TBytes + RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40; + RtsFlags.DebugFlags.scheduler = false; RtsFlags.DebugFlags.interpreter = false; RtsFlags.DebugFlags.weak = false; @@ -552,6 +555,11 @@ usage_text[] = { " -xq The allocation limit given to a thread after it receives", " an AllocationLimitExceeded exception. (default: 100k)", "", +#if defined(USE_LARGE_ADDRESS_SPACE) +" -xr The size of virtual memory address space reserved by the", +" two step allocator (default: 1T)", +"", +#endif " -Mgrace=", " The amount of allocation after the program receives a", " HeapOverflow exception before the exception is thrown again, if", @@ -1820,6 +1828,12 @@ error = true; / BLOCK_SIZE; break; + case 'r': + OPTION_UNSAFE; + RtsFlags.GcFlags.addressSpaceSize + = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_WORD64_MAX); + break; + default: OPTION_SAFE; errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -2118,7 +2132,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) m = atof(s); c = s[strlen(s)-1]; - if (c == 'g' || c == 'G') + if (c == 't' || c == 'T') + m *= (StgWord64)1024*1024*1024*1024; + else if (c == 'g' || c == 'G') m *= 1024*1024*1024; else if (c == 'm' || c == 'M') m *= 1024*1024; @@ -2737,4 +2753,3 @@ doingErasProfiling( void ) || RtsFlags.ProfFlags.eraSelector != 0); } #endif /* PROFILING */ - ===================================== rts/include/rts/Flags.h ===================================== @@ -89,6 +89,8 @@ typedef struct _GC_FLAGS { bool numa; /* Use NUMA */ StgWord numaMask; + + StgWord64 addressSpaceSize; /* large address space size in bytes */ } GC_FLAGS; /* See Note [Synchronization of flags and base APIs] */ ===================================== rts/js/arith.js ===================================== @@ -44,19 +44,23 @@ function h$hs_remWord64(h1,l1,h2,l2) { } function h$hs_timesWord64(h1,l1,h2,l2) { - var a = W64(h1,l1); - var b = W64(h2,l2); - var r = BigInt.asUintN(64, a * b); - TRACE_ARITH("Word64: " + a + " * " + b + " ==> " + r) - RETURN_W64(r); + var rh = h$mul2Word32(l1,l2); + var rl = h$ret1; + + rh += Math.imul(l1,h2)>>>0; + rh += Math.imul(l2,h1)>>>0; + rh >>>= 0; + + TRACE_ARITH("Word64: " + (h1,l1) + " * " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_minusWord64(h1,l1,h2,l2) { - var a = (BigInt(h1) << BigInt(32)) | BigInt(l1>>>0); - var b = (BigInt(h2) << BigInt(32)) | BigInt(l2>>>0); - var r = BigInt.asUintN(64, a - b); - TRACE_ARITH("Word64: " + a + " - " + b + " ==> " + r) - RETURN_W64(r); + var l = l1-l2; + var rl = l>>>0; + var rh = (h1-h2-(l!=rl?1:0))>>>0; + TRACE_ARITH("Word64: " + (h1,l1) + " - " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_plusWord64(h1,l1,h2,l2) { @@ -68,11 +72,15 @@ function h$hs_plusWord64(h1,l1,h2,l2) { } function h$hs_timesInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a * b); - TRACE_ARITH("Int64: " + a + " * " + b + " ==> " + r) - RETURN_I64(r); + var rh = h$mul2Word32(l1,l2); + var rl = h$ret1; + + rh += Math.imul(l1,h2)|0; + rh += Math.imul(l2,h1)|0; + rh |= 0; + + TRACE_ARITH("Int64: " + (h1,l1) + " * " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_quotInt64(h1,l1,h2,l2) { @@ -92,19 +100,19 @@ function h$hs_remInt64(h1,l1,h2,l2) { } function h$hs_plusInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a + b); - TRACE_ARITH("Int64: " + a + " + " + b + " ==> " + r) - RETURN_I64(r); + var l = l1+l2; + var rl = l>>>0; + var rh = (h1+h2+(l!=rl?1:0))|0; + TRACE_ARITH("Int64: " + (h1,l1) + " + " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_minusInt64(h1,l1,h2,l2) { - var a = I64(h1,l1); - var b = I64(h2,l2); - var r = BigInt.asIntN(64, a - b); - TRACE_ARITH("Int64: " + a + " - " + b + " ==> " + r) - RETURN_I64(r); + var l = l1-l2; + var rl = l>>>0; + var rh = (h1-h2-(l!=rl?1:0))|0; + TRACE_ARITH("Int64: " + (h1,l1) + " - " + (h2,l2) + " ==> " + (rh,rl)) + RETURN_UBX_TUP2(rh,rl); } function h$hs_uncheckedShiftLWord64(h,l,n) { ===================================== rts/sm/MBlock.c ===================================== @@ -659,20 +659,14 @@ initMBlocks(void) #if defined(USE_LARGE_ADDRESS_SPACE) { - W_ size; -#if defined(aarch64_HOST_ARCH) - size = (W_)1 << 38; // 1/4 TByte -#else - size = (W_)1 << 40; // 1 TByte -#endif void *startAddress = NULL; if (RtsFlags.GcFlags.heapBase) { startAddress = (void*) RtsFlags.GcFlags.heapBase; } - void *addr = osReserveHeapMemory(startAddress, &size); + void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize); mblock_address_space.begin = (W_)addr; - mblock_address_space.end = (W_)addr + size; + mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize; mblock_high_watermark = (W_)addr; } #elif SIZEOF_VOID_P == 8 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -12071,7 +12071,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -12122,6 +12122,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -12130,7 +12131,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -9253,7 +9253,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9304,6 +9304,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9312,7 +9313,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -9029,7 +9029,7 @@ module GHC.RTS.Flags where type DoCostCentres :: * data DoCostCentres = CostCentresNone | CostCentresSummary | CostCentresVerbose | CostCentresAll | CostCentresJSON type DoHeapProfile :: * - data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable + data DoHeapProfile = NoHeapProfiling | HeapByCCS | HeapByMod | HeapByDescr | HeapByType | HeapByRetainer | HeapByLDV | HeapByClosureType | HeapByInfoTable | HeapByEra type DoTrace :: * data DoTrace = TraceNone | TraceEventLog | TraceStderr type GCFlags :: * @@ -9080,6 +9080,7 @@ module GHC.RTS.Flags where startHeapProfileAtStartup :: GHC.Types.Bool, startTimeProfileAtStartup :: GHC.Types.Bool, showCCSOnException :: GHC.Types.Bool, + automaticEraIncrement :: GHC.Types.Bool, maxRetainerSetSize :: GHC.Types.Word, ccsLength :: GHC.Types.Word, modSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, @@ -9088,7 +9089,8 @@ module GHC.RTS.Flags where ccSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, ccsSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, retainerSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, - bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String} + bioSelector :: GHC.Internal.Maybe.Maybe GHC.Internal.Base.String, + eraSelector :: GHC.Types.Word} type RTSFlags :: * data RTSFlags = RTSFlags {gcFlags :: GCFlags, concurrentFlags :: ConcFlags, miscFlags :: MiscFlags, debugFlags :: DebugFlags, costCentreFlags :: CCFlags, profilingFlags :: ProfFlags, traceFlags :: TraceFlags, tickyFlags :: TickyFlags, parFlags :: ParFlags, hpcFlags :: HpcFlags} type RtsTime :: * ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [ req_th, collect_compiler_stats('all', 5) ], + multimod_compile, ['T24471', '-v0 -O']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -3,7 +3,7 @@ test('testblockalloc', compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'), + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'), when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d1384b1156be380b3d64eefbba4de756cd3f366...d8161acc13d72330d54c9176bb22ff6336ee9ee1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d1384b1156be380b3d64eefbba4de756cd3f366...d8161acc13d72330d54c9176bb22ff6336ee9ee1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 06:15:47 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Wed, 06 Mar 2024 01:15:47 -0500 Subject: [Git][ghc/ghc][wip/T24471] Three compile perf improvements with deep nesting Message-ID: <65e80a13c82db_337647428c843286f@gitlab.mail> Cheng Shao pushed to branch wip/T24471 at Glasgow Haskell Compiler / GHC Commits: b85111d1 by Simon Peyton Jones at 2024-03-06T06:15:30+00:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 6 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [req_th, collect_compiler_stats('all', 5)], + multimod_compile, ['T24471', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b85111d1219f99068f0435e3289ce265e9ac58c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b85111d1219f99068f0435e3289ce265e9ac58c7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 09:18:41 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 06 Mar 2024 04:18:41 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: expose HeapAlloc.h as public header Message-ID: <65e834f199afe_33764c1bd21056262@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6add6433 by Cheng Shao at 2024-03-06T04:18:29-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - ae72bf3f by Cheng Shao at 2024-03-06T04:18:29-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 044493e5 by Ben Gamari at 2024-03-06T04:18:30-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 99474b0a by Simon Peyton Jones at 2024-03-06T04:18:30-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 20 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - rts/Sparks.c - rts/include/rts/storage/Block.h - rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h - rts/posix/OSMem.c - rts/rts.cabal - rts/sm/CNF.c - rts/sm/GC.h - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/Sanity.c - rts/wasm/OSMem.c - rts/win32/OSMem.c - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -80,4 +80,5 @@ module Data.Sum.Experimental ( Sum63#, ) where +import GHC.Num.BigNat () -- for build ordering import GHC.Types ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,4 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes +import GHC.Num.BigNat () -- for build ordering ===================================== rts/Sparks.c ===================================== @@ -16,7 +16,7 @@ #include "Sparks.h" #include "ThreadLabels.h" #include "sm/NonMovingMark.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #if defined(THREADED_RTS) ===================================== rts/include/rts/storage/Block.h ===================================== @@ -10,6 +10,10 @@ #include "ghcconfig.h" +#if !defined(CMINUSMINUS) +#include "rts/storage/HeapAlloc.h" +#endif + /* The actual block and megablock-size constants are defined in * rts/include/Constants.h, all constants here are derived from these. */ @@ -190,6 +194,7 @@ typedef struct bdescr_ { EXTERN_INLINE bdescr *Bdescr(StgPtr p); EXTERN_INLINE bdescr *Bdescr(StgPtr p) { + ASSERT(HEAP_ALLOCED_GC(p)); return (bdescr *) ((((W_)p & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) | ((W_)p & ~MBLOCK_MASK) ===================================== rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h ===================================== @@ -8,8 +8,6 @@ #pragma once -#include "BeginPrivate.h" - #if defined(THREADED_RTS) // needed for HEAP_ALLOCED below extern SpinLock gc_alloc_block_sync; @@ -227,5 +225,3 @@ StgBool HEAP_ALLOCED_GC(const void *p) #else # error HEAP_ALLOCED not defined #endif - -#include "EndPrivate.h" ===================================== rts/posix/OSMem.c ===================================== @@ -13,7 +13,7 @@ #include "RtsUtils.h" #include "sm/OSMem.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #if defined(HAVE_UNISTD_H) #include ===================================== rts/rts.cabal ===================================== @@ -303,6 +303,7 @@ library rts/storage/Closures.h rts/storage/FunTypes.h rts/storage/Heap.h + rts/storage/HeapAlloc.h rts/storage/GC.h rts/storage/InfoTables.h rts/storage/MBlock.h ===================================== rts/sm/CNF.c ===================================== @@ -20,7 +20,7 @@ #include "Storage.h" #include "CNF.h" #include "Hash.h" -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "BlockAlloc.h" #include "Trace.h" #include "sm/ShouldCompact.h" ===================================== rts/sm/GC.h ===================================== @@ -13,7 +13,7 @@ #pragma once -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "BeginPrivate.h" ===================================== rts/sm/NonMoving.h ===================================== @@ -11,7 +11,7 @@ #if !defined(CMINUSMINUS) #include -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "NonMovingMark.h" #include "BeginPrivate.h" ===================================== rts/sm/NonMovingMark.c ===================================== @@ -14,7 +14,7 @@ #include "NonMovingShortcut.h" #include "NonMoving.h" #include "BlockAlloc.h" /* for countBlocks */ -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "Task.h" #include "Trace.h" #include "HeapUtils.h" ===================================== rts/sm/Sanity.c ===================================== @@ -32,7 +32,7 @@ #include "sm/NonMoving.h" #include "sm/NonMovingMark.h" #include "Profiling.h" // prof_arena -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" /* ----------------------------------------------------------------------------- Forward decls. ===================================== rts/wasm/OSMem.c ===================================== @@ -52,7 +52,7 @@ #include "RtsUtils.h" #include "sm/OSMem.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include <__macro_PAGESIZE.h> ===================================== rts/win32/OSMem.c ===================================== @@ -8,7 +8,7 @@ #include "Rts.h" #include "sm/OSMem.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "RtsUtils.h" #include ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [req_th, collect_compiler_stats('all', 5)], + multimod_compile, ['T24471', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d008377958d1790e4de54535dd2028685e2f2ecd...99474b0aed8a30d4a3a024f4f88a94abbd1a6e01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d008377958d1790e4de54535dd2028685e2f2ecd...99474b0aed8a30d4a3a024f4f88a94abbd1a6e01 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 10:02:05 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 06 Mar 2024 05:02:05 -0500 Subject: [Git][ghc/ghc][wip/no-mi-globals] Don't store a GlobalRdrEnv in `mi_globals` for GHCi. Message-ID: <65e83f1cf1656_33764d4a8d0c71013@gitlab.mail> Zubin pushed to branch wip/no-mi-globals at Glasgow Haskell Compiler / GHC Commits: 918daaef by Zubin Duggal at 2024-03-06T15:31:42+05:30 Don't store a GlobalRdrEnv in `mi_globals` for GHCi. GHCi only needs the `mi_globals` field for modules imported with :module +*SomeModule. It uses this field to make the top level environment in `SomeModule` available to the repl. By default, only the first target in the command line parameters is "star" loaded into GHCi. Other modules have to be manually "star" loaded into the repl. Storing the top level GlobalRdrEnv for each module is very wasteful, especially given that we will most likely never need most of these environments. Instead we store only the information needed to reconstruct the top level environment in a module, which is the `IfaceTopEnv` data structure, consisting of all import statements as well as all top level symbols defined in the module (not taking export lists into account) When a particular module is "star-loaded" into GHCi (as the first commandline target, or via an explicit `:module +*SomeModule`, we reconstruct the top level environment on demand using the `IfaceTopEnv`. - - - - - 24 changed files: - compiler/GHC.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Types/PkgQual.hs - compiler/GHC/Types/Unique/Set.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/Language/Haskell/Syntax/ImpExp.hs - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - ghc/GHCi/UI/Monad.hs - utils/dump-decls/Main.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -86,14 +86,12 @@ module GHC ( ModuleInfo, getModuleInfo, modInfoTyThings, - modInfoTopLevelScope, modInfoExports, modInfoExportsWithSelectors, modInfoInstances, modInfoIsExportedName, modInfoLookupName, modInfoIface, - modInfoRdrEnv, modInfoSafe, lookupGlobalName, findGlobalAnns, @@ -1223,9 +1221,6 @@ typecheckModule pmod = do details <- makeSimpleDetails lcl_logger tc_gbl_env safe <- finalSafeMode lcl_dflags tc_gbl_env - let !rdr_env = forceGlobalRdrEnv $ tcg_rdr_env tc_gbl_env - -- See Note [Forcing GREInfo] in GHC.Types.GREInfo. - return $ TypecheckedModule { tm_internals_ = (tc_gbl_env, details), @@ -1236,7 +1231,6 @@ typecheckModule pmod = do ModuleInfo { minf_type_env = md_types details, minf_exports = md_exports details, - minf_rdr_env = Just rdr_env, minf_instances = fixSafeInstances safe $ instEnvElts $ md_insts details, minf_iface = Nothing, minf_safe = safe, @@ -1389,7 +1383,6 @@ getNamePprCtx = withSession $ \hsc_env -> do data ModuleInfo = ModuleInfo { minf_type_env :: TypeEnv, minf_exports :: [AvailInfo], - minf_rdr_env :: Maybe IfGlobalRdrEnv, -- Nothing for a compiled/package mod minf_instances :: [ClsInst], minf_iface :: Maybe ModIface, minf_safe :: SafeHaskellMode, @@ -1416,13 +1409,9 @@ getPackageModuleInfo hsc_env mdl tys = [ ty | name <- concatMap availNames avails, Just ty <- [lookupTypeEnv pte name] ] - let !rdr_env = availsToGlobalRdrEnv hsc_env mdl avails - -- See Note [Forcing GREInfo] in GHC.Types.GREInfo. - return (Just (ModuleInfo { minf_type_env = mkTypeEnv tys, minf_exports = avails, - minf_rdr_env = Just rdr_env, minf_instances = error "getModuleInfo: instances for package module unimplemented", minf_iface = Just iface, minf_safe = getSafeMode $ mi_trust iface, @@ -1439,7 +1428,7 @@ availsToGlobalRdrEnv hsc_env mod avails -- all the specified modules into the global interactive module imp_spec = ImpSpec { is_decl = decl, is_item = ImpAll} decl = ImpDeclSpec { is_mod = mod, is_as = moduleName mod, - is_qual = False, + is_qual = False, is_isboot = NotBoot, is_pkg_qual = NoPkgQual, is_dloc = srcLocSpan interactiveSrcLoc } getHomeModuleInfo :: HscEnv -> Module -> IO (Maybe ModuleInfo) @@ -1452,7 +1441,6 @@ getHomeModuleInfo hsc_env mdl = return (Just (ModuleInfo { minf_type_env = md_types details, minf_exports = md_exports details, - minf_rdr_env = mi_globals $ hm_iface hmi, -- NB: already forced. See Note [Forcing GREInfo] in GHC.Types.GREInfo. minf_instances = instEnvElts $ md_insts details, minf_iface = Just iface, @@ -1464,12 +1452,6 @@ getHomeModuleInfo hsc_env mdl = modInfoTyThings :: ModuleInfo -> [TyThing] modInfoTyThings minf = typeEnvElts (minf_type_env minf) -modInfoTopLevelScope :: ModuleInfo -> Maybe [Name] -modInfoTopLevelScope minf - = fmap (map greName . globalRdrEnvElts) (minf_rdr_env minf) - -- NB: no need to force this again. - -- See Note [Forcing GREInfo] in GHC.Types.GREInfo. - modInfoExports :: ModuleInfo -> [Name] modInfoExports minf = concatMap availNames $! minf_exports minf @@ -1486,12 +1468,13 @@ modInfoIsExportedName minf name = elemNameSet name (availsToNameSet (minf_export mkNamePprCtxForModule :: GhcMonad m => + Module -> ModuleInfo -> - m (Maybe NamePprCtx) -- XXX: returns a Maybe X -mkNamePprCtxForModule minf = withSession $ \hsc_env -> do - let mk_name_ppr_ctx = mkNamePprCtx ptc (hsc_unit_env hsc_env) + m NamePprCtx +mkNamePprCtxForModule mod minf = withSession $ \hsc_env -> do + let name_ppr_ctx = mkNamePprCtx ptc (hsc_unit_env hsc_env) (availsToGlobalRdrEnv hsc_env mod (minf_exports minf)) ptc = initPromotionTickContext (hsc_dflags hsc_env) - return (fmap mk_name_ppr_ctx (minf_rdr_env minf)) + return name_ppr_ctx modInfoLookupName :: GhcMonad m => ModuleInfo -> Name @@ -1504,9 +1487,6 @@ modInfoLookupName minf name = withSession $ \hsc_env -> do modInfoIface :: ModuleInfo -> Maybe ModIface modInfoIface = minf_iface -modInfoRdrEnv :: ModuleInfo -> Maybe IfGlobalRdrEnv -modInfoRdrEnv = minf_rdr_env - -- | Retrieve module safe haskell mode modInfoSafe :: ModuleInfo -> SafeHaskellMode modInfoSafe = minf_safe ===================================== compiler/GHC/Driver/Backend.hs ===================================== @@ -511,7 +511,7 @@ backendRespectsSpecialise (Named JavaScript) = True backendRespectsSpecialise (Named Interpreter) = False backendRespectsSpecialise (Named NoBackend) = False --- | This back end wants the `mi_globals` field of a +-- | This back end wants the `mi_top_env` field of a -- `ModIface` to be populated (with the top-level bindings -- of the original source). Only true for the interpreter. backendWantsGlobalBindings :: Backend -> Bool ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1100,7 +1100,7 @@ hscDesugarAndSimplify summary (FrontendTypecheck tc_result) tc_warnings mb_old_h {-# SCC "GHC.Driver.Main.mkPartialIface" #-} -- This `force` saves 2M residency in test T10370 -- See Note [Avoiding space leaks in toIface*] for details. - force (mkPartialIface hsc_env (cg_binds cg_guts) details summary simplified_guts) + force (mkPartialIface hsc_env (cg_binds cg_guts) details summary (tcg_import_decls tc_result) simplified_guts) return HscRecomp { hscs_guts = cg_guts, hscs_mod_location = ms_location summary, ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -27,6 +27,7 @@ import GHC.StgToCmm.Types (CmmCgInfos (..)) import GHC.Tc.Utils.TcType import GHC.Tc.Utils.Monad +import GHC.Tc.Gen.Export import GHC.Iface.Decl import GHC.Iface.Syntax @@ -106,9 +107,10 @@ mkPartialIface :: HscEnv -> CoreProgram -> ModDetails -> ModSummary + -> [ImportUserSpec] -> ModGuts -> PartialModIface -mkPartialIface hsc_env core_prog mod_details mod_summary +mkPartialIface hsc_env core_prog mod_details mod_summary import_decls ModGuts{ mg_module = this_mod , mg_hsc_src = hsc_src , mg_usages = usages @@ -122,7 +124,7 @@ mkPartialIface hsc_env core_prog mod_details mod_summary , mg_trust_pkg = self_trust , mg_docs = docs } - = mkIface_ hsc_env this_mod core_prog hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust + = mkIface_ hsc_env this_mod core_prog hsc_src used_th deps rdr_env import_decls fix_env warns hpc_info self_trust safe_mode usages docs mod_summary mod_details -- | Fully instantiate an interface. Adds fingerprints and potentially code @@ -194,6 +196,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program tc_result at TcGblEnv{ tcg_mod = this_mod, tcg_src = hsc_src, tcg_imports = imports, + tcg_import_decls = import_decls, tcg_rdr_env = rdr_env, tcg_fix_env = fix_env, tcg_merged = merged, @@ -232,7 +235,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program let partial_iface = mkIface_ hsc_env this_mod (fromMaybe [] mb_program) hsc_src - used_th deps rdr_env + used_th deps rdr_env import_decls fix_env warns hpc_info (imp_trust_own_pkg imports) safe_mode usages docs mod_summary @@ -241,7 +244,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program mkFullIface hsc_env partial_iface Nothing Nothing mkIface_ :: HscEnv -> Module -> CoreProgram -> HscSource - -> Bool -> Dependencies -> GlobalRdrEnv + -> Bool -> Dependencies -> GlobalRdrEnv -> [ImportUserSpec] -> NameEnv FixItem -> Warnings GhcRn -> HpcInfo -> Bool -> SafeHaskellMode @@ -251,7 +254,7 @@ mkIface_ :: HscEnv -> Module -> CoreProgram -> HscSource -> ModDetails -> PartialModIface mkIface_ hsc_env - this_mod core_prog hsc_src used_th deps rdr_env fix_env src_warns + this_mod core_prog hsc_src used_th deps rdr_env import_decls fix_env src_warns hpc_info pkg_trust_req safe_mode usages docs mod_summary ModDetails{ md_insts = insts, @@ -323,7 +326,7 @@ mkIface_ hsc_env mi_fixities = fixities, mi_warns = warns, mi_anns = annotations, - mi_globals = rdrs, + mi_top_env = rdrs, mi_used_th = used_th, mi_decls = decls, mi_extra_decls = extra_decls, @@ -345,16 +348,18 @@ mkIface_ hsc_env dflags = hsc_dflags hsc_env - -- We only fill in mi_globals if the module was compiled to byte + -- We only fill in mi_top_env if the module was compiled to byte -- code. Otherwise, the compiler may not have retained all the -- top-level bindings and they won't be in the TypeEnv (see - -- Desugar.addExportFlagsAndRules). The mi_globals field is used + -- Desugar.addExportFlagsAndRules). The mi_top_env field is used -- by GHCi to decide whether the module has its full top-level -- scope available. (#5534) - maybeGlobalRdrEnv :: GlobalRdrEnv -> Maybe IfGlobalRdrEnv + maybeGlobalRdrEnv :: GlobalRdrEnv -> Maybe IfaceTopEnv maybeGlobalRdrEnv rdr_env | backendWantsGlobalBindings (backend dflags) - = Just $! forceGlobalRdrEnv rdr_env + = Just $! let !exports = mkIfaceExports $ all_rdr_exports rdr_env + !imports = mkIfaceImports import_decls + in IfaceTopEnv exports imports -- See Note [Forcing GREInfo] in GHC.Types.GREInfo. | otherwise = Nothing @@ -472,6 +477,13 @@ mkIfaceAnnotation (Annotation { ann_target = target, ann_value = payload }) ifAnnotatedValue = payload } +mkIfaceImports :: [ImportUserSpec] -> [IfaceImport] +mkIfaceImports = map go + where + go (ImpUserSpec decl ImpUserAll) = IfaceImport decl ImpIfaceAll + go (ImpUserSpec decl (ImpUserExplicit env)) = IfaceImport decl (ImpIfaceExplicit (forceGlobalRdrEnv env)) + go (ImpUserSpec decl (ImpUserEverythingBut ns)) = IfaceImport decl (ImpIfaceEverythingBut ns) + mkIfaceExports :: [AvailInfo] -> [IfaceExport] -- Sort to make canonical mkIfaceExports exports = sortBy stableAvailCmp (map sort_subs exports) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -25,6 +25,8 @@ module GHC.Iface.Syntax ( IfaceTyConParent(..), IfaceCompleteMatch(..), IfaceLFInfo(..), IfaceTopBndrInfo(..), + IfaceImport(..), + ImpIfaceList(..), -- * Binding names IfaceTopBndr, @@ -63,6 +65,7 @@ import GHC.Types.FieldLabel import GHC.Types.Name.Set import GHC.Core.Coercion.Axiom ( BranchIndex ) import GHC.Types.Name +import GHC.Types.Name.Reader import GHC.Types.CostCentre import GHC.Types.Literal import GHC.Types.ForeignCall @@ -105,6 +108,13 @@ infixl 3 &&& ************************************************************************ -} +data IfaceImport = IfaceImport ImpDeclSpec ImpIfaceList + +data ImpIfaceList + = ImpIfaceAll -- ^ no user import list + | ImpIfaceExplicit !IfGlobalRdrEnv + | ImpIfaceEverythingBut !NameSet + -- | A binding top-level 'Name' in an interface file (e.g. the name of an -- 'IfaceDecl'). type IfaceTopBndr = Name @@ -128,7 +138,6 @@ putIfaceTopBndr bh name = --pprTrace "putIfaceTopBndr" (ppr name) $ put_binding_name bh name - data IfaceDecl = IfaceId { ifName :: IfaceTopBndr, ifType :: IfaceType, @@ -2725,6 +2734,14 @@ instance Binary IfaceCompleteMatch where ************************************************************************ -} +instance NFData IfaceImport where + rnf (IfaceImport a b) = rnf a `seq` rnf b + +instance NFData ImpIfaceList where + rnf ImpIfaceAll = () + rnf (ImpIfaceEverythingBut ns) = rnf ns + rnf (ImpIfaceExplicit gre) = rnf gre + instance NFData IfaceDecl where rnf = \case IfaceId f1 f2 f3 f4 -> ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -28,6 +28,7 @@ module GHC.IfaceToCore ( tcIfaceExpr, -- Desired by HERMIT (#7683) tcIfaceGlobal, tcIfaceOneShot, tcTopIfaceBindings, + tcIfaceImport, hydrateCgBreakInfo ) where @@ -54,6 +55,7 @@ import GHC.Tc.Errors.Types import GHC.Tc.TyCl.Build import GHC.Tc.Utils.Monad import GHC.Tc.Utils.TcType +import GHC.Tc.Utils.Env import GHC.Core.Type import GHC.Core.Coercion @@ -111,6 +113,7 @@ import GHC.Types.Literal import GHC.Types.Var as Var import GHC.Types.Var.Set import GHC.Types.Name +import GHC.Types.Name.Reader import GHC.Types.Name.Env import GHC.Types.Id import GHC.Types.Id.Make @@ -2176,3 +2179,12 @@ hydrateCgBreakInfo CgBreakInfo{..} = do result_ty <- tcIfaceType cgb_resty mbVars <- mapM (traverse (\(if_gbl, offset) -> (,offset) <$> bindIfaceId if_gbl return)) cgb_vars return (mbVars, result_ty) + +-- | This function is only used to construct the environment for GHCi, +-- so we make up fake locations +tcIfaceImport :: HscEnv -> IfaceImport -> ImportUserSpec +tcIfaceImport _ (IfaceImport spec ImpIfaceAll) = ImpUserSpec spec ImpUserAll +tcIfaceImport _ (IfaceImport spec (ImpIfaceEverythingBut ns)) = ImpUserSpec spec (ImpUserEverythingBut ns) +tcIfaceImport hsc_env (IfaceImport spec (ImpIfaceExplicit gre)) = ImpUserSpec spec (ImpUserExplicit (hydrateGlobalRdrEnv get_GRE_info gre)) + where + get_GRE_info nm = tyThingGREInfo <$> lookupGlobal hsc_env nm ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1958,7 +1958,7 @@ lookupQualifiedNameGHCi fos rdr_name , gre_info = info } where info = lookupGREInfo hsc_env nm - spec = ImpDeclSpec { is_mod = mod, is_as = moduleName mod, is_qual = True, is_dloc = noSrcSpan } + spec = ImpDeclSpec { is_mod = mod, is_as = moduleName mod, is_pkg_qual = NoPkgQual, is_qual = True, is_isboot = NotBoot, is_dloc = noSrcSpan } is = ImpSpec { is_decl = spec, is_item = ImpAll } -- | Look up the 'GREInfo' associated with the given 'Name' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -14,6 +14,8 @@ Extracting imported and top-level names in scope module GHC.Rename.Names ( rnImports, getLocalNonValBinders, newRecordFieldLabel, + importsFromIface, + ImportUserSpec(..), extendGlobalRdrEnvRn, gresFromAvails, calculateAvails, @@ -48,7 +50,8 @@ import GHC.Tc.Types.LclEnv import GHC.Tc.Zonk.TcType ( tcInitTidyEnv ) import GHC.Hs -import GHC.Iface.Load ( loadSrcInterface ) +import GHC.Iface.Load ( loadSrcInterface, cannotFindModule ) +import GHC.Iface.Errors.Types import GHC.Iface.Syntax ( fromIfaceWarnings ) import GHC.Builtin.Names import GHC.Parser.PostProcess ( setRdrNameSpace ) @@ -107,6 +110,7 @@ import qualified Data.Set as S import System.FilePath (()) import System.IO +import GHC.Unit.Finder {- ************************************************************************ @@ -200,7 +204,7 @@ with yes we have gone with no for now. -- Note: Do the non SOURCE ones first, so that we get a helpful warning -- for SOURCE ones that are unnecessary rnImports :: [(LImportDecl GhcPs, SDoc)] - -> RnM ([LImportDecl GhcRn], GlobalRdrEnv, ImportAvails, AnyHpcUsage) + -> RnM ([LImportDecl GhcRn], [ImportUserSpec], GlobalRdrEnv, ImportAvails, AnyHpcUsage) rnImports imports = do tcg_env <- getGblEnv -- NB: want an identity module here, because it's OK for a signature @@ -211,14 +215,14 @@ rnImports imports = do stuff1 <- mapAndReportM (rnImportDecl this_mod) ordinary stuff2 <- mapAndReportM (rnImportDecl this_mod) source -- Safe Haskell: See Note [Tracking Trust Transitively] - let (decls, rdr_env, imp_avails, hpc_usage) = combine (stuff1 ++ stuff2) + let (decls, imp_user_spec, rdr_env, imp_avails, hpc_usage) = combine (stuff1 ++ stuff2) -- Update imp_boot_mods if imp_direct_mods mentions any of them let merged_import_avail = clobberSourceImports imp_avails dflags <- getDynFlags let final_import_avail = merged_import_avail { imp_dep_direct_pkgs = S.fromList (implicitPackageDeps dflags) `S.union` imp_dep_direct_pkgs merged_import_avail} - return (decls, rdr_env, final_import_avail, hpc_usage) + return (decls, imp_user_spec, rdr_env, final_import_avail, hpc_usage) where clobberSourceImports imp_avails = @@ -231,19 +235,20 @@ rnImports imports = do combJ (GWIB _ IsBoot) x = Just x combJ r _ = Just r -- See Note [Combining ImportAvails] - combine :: [(LImportDecl GhcRn, GlobalRdrEnv, ImportAvails, AnyHpcUsage)] - -> ([LImportDecl GhcRn], GlobalRdrEnv, ImportAvails, AnyHpcUsage) + combine :: [(LImportDecl GhcRn, ImportUserSpec, GlobalRdrEnv, ImportAvails, AnyHpcUsage)] + -> ([LImportDecl GhcRn], [ImportUserSpec], GlobalRdrEnv, ImportAvails, AnyHpcUsage) combine ss = - let (decls, rdr_env, imp_avails, hpc_usage, finsts) = foldr + let (decls, imp_user_spec, rdr_env, imp_avails, hpc_usage, finsts) = foldr plus - ([], emptyGlobalRdrEnv, emptyImportAvails, False, emptyModuleSet) + ([], [], emptyGlobalRdrEnv, emptyImportAvails, False, emptyModuleSet) ss - in (decls, rdr_env, imp_avails { imp_finsts = moduleSetElts finsts }, + in (decls, imp_user_spec, rdr_env, imp_avails { imp_finsts = moduleSetElts finsts }, hpc_usage) - plus (decl, gbl_env1, imp_avails1, hpc_usage1) - (decls, gbl_env2, imp_avails2, hpc_usage2, finsts_set) + plus (decl, us, gbl_env1, imp_avails1, hpc_usage1) + (decls, uss, gbl_env2, imp_avails2, hpc_usage2, finsts_set) = ( decl:decls, + us:uss, gbl_env1 `plusGlobalRdrEnv` gbl_env2, imp_avails1' `plusImportAvails` imp_avails2, hpc_usage1 || hpc_usage2, @@ -295,6 +300,26 @@ Running generateModules from #14693 with DEPTH=16, WIDTH=30 finishes in -} +importSpec :: LImportDecl GhcPs -> RnM (ImpDeclSpec, Maybe (ImportListInterpretation, LocatedL [LIE GhcPs])) +importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name + , ideclPkgQual = raw_pkg_qual + , ideclSource = want_boot + , ideclQualified = qual_style + , ideclAs = as_mod, ideclImportList = imp_details })) + = do hsc_env <- getTopEnv + let unit_env = hsc_unit_env hsc_env + let imp_mod_name = unLoc loc_imp_mod_name + let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual + res <- liftIO $ findImportedModule hsc_env imp_mod_name pkg_qual + imp_mod <- case res of + Found _ mod -> pure mod + err -> failWithTc $ TcRnInterfaceError $ Can'tFindInterface (cannotFindModule hsc_env imp_mod_name err) $ LookingForModule imp_mod_name want_boot + let qual_only = isImportDeclQualified qual_style + qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name + imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, is_pkg_qual = pkg_qual, + is_dloc = locA loc, is_as = qual_mod_name, is_isboot = want_boot } + pure (imp_spec, imp_details) + -- | Given a located import declaration @decl@ from @this_mod@, -- calculate the following pieces of information: @@ -312,32 +337,31 @@ Running generateModules from #14693 with DEPTH=16, WIDTH=30 finishes in -- 4. A boolean 'AnyHpcUsage' which is true if the imported module -- used HPC. rnImportDecl :: Module -> (LImportDecl GhcPs, SDoc) - -> RnM (LImportDecl GhcRn, GlobalRdrEnv, ImportAvails, AnyHpcUsage) + -> RnM (LImportDecl GhcRn, ImportUserSpec , GlobalRdrEnv, ImportAvails, AnyHpcUsage) rnImportDecl this_mod - (L loc decl@(ImportDecl { ideclName = loc_imp_mod_name - , ideclPkgQual = raw_pkg_qual - , ideclSource = want_boot, ideclSafe = mod_safe - , ideclQualified = qual_style - , ideclExt = XImportDeclPass { ideclImplicit = implicit } - , ideclAs = as_mod, ideclImportList = imp_details }), import_reason) + ( ldecl@(L loc decl@(ImportDecl { ideclSafe = mod_safe + , ideclExt = XImportDeclPass { ideclImplicit = implicit }})) + , import_reason) = setSrcSpanA loc $ do - case raw_pkg_qual of - NoRawPkgQual -> pure () - RawPkgQual _ -> do + (imp_spec,imp_details) <- importSpec ldecl + + let pkg_qual = is_pkg_qual imp_spec + want_boot = is_isboot imp_spec + case pkg_qual of + NoPkgQual -> pure () + _ -> do pkg_imports <- xoptM LangExt.PackageImports when (not pkg_imports) $ addErr TcRnPackageImportsDisabled - let qual_only = isImportDeclQualified qual_style + let qual_only = is_qual imp_spec -- If there's an error in loadInterface, (e.g. interface -- file not found) we get lots of spurious errors from 'filterImports' - let imp_mod_name = unLoc loc_imp_mod_name + let imp_mod_name = moduleName $ is_mod imp_spec doc = ppr imp_mod_name <+> import_reason hsc_env <- getTopEnv - unit_env <- hsc_unit_env <$> getTopEnv - let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual -- Check for self-import, which confuses the typechecker (#9032) -- ghc --make rejects self-import cycles already, but batch-mode may not @@ -390,21 +414,14 @@ rnImportDecl this_mod when (mod_safe && not (safeImportsOn dflags)) $ addErr (TcRnSafeImportsDisabled imp_mod_name) - let imp_mod = mi_module iface - qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name - imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, - is_dloc = locA loc, is_as = qual_mod_name } - -- filter the imports according to the import declaration - (new_imp_details, gres) <- filterImports hsc_env iface imp_spec imp_details + (new_imp_details, imp_user_list, gbl_env) <- filterImports hsc_env iface imp_spec imp_details -- for certain error messages, we’d like to know what could be imported -- here, if everything were imported - potential_gres <- mkGlobalRdrEnv . snd <$> filterImports hsc_env iface imp_spec Nothing + potential_gres <- (\(_,_,x) -> x) <$> filterImports hsc_env iface imp_spec Nothing - let gbl_env = mkGlobalRdrEnv gres - - is_hiding | Just (EverythingBut,_) <- imp_details = True + let is_hiding | Just (EverythingBut,_) <- imp_details = True | otherwise = False -- should the import be safe? @@ -416,7 +433,7 @@ rnImportDecl this_mod let home_unit = hsc_home_unit hsc_env other_home_units = hsc_all_home_unit_ids hsc_env imv = ImportedModsVal - { imv_name = qual_mod_name + { imv_name = is_as imp_spec , imv_span = locA loc , imv_is_safe = mod_safe' , imv_is_hiding = is_hiding @@ -444,7 +461,7 @@ rnImportDecl this_mod , ideclImportList = new_imp_details } - return (L loc new_imp_decl, gbl_env, imports, mi_hpc iface) + return (L loc new_imp_decl, ImpUserSpec imp_spec imp_user_list, gbl_env, imports, mi_hpc iface) -- | Rename raw package imports @@ -1188,6 +1205,14 @@ gresFromAvail hsc_env prov avail = gresFromAvails :: HscEnv -> Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt] gresFromAvails hsc_env prov = concatMap (gresFromAvail hsc_env prov) +importsFromIface :: HscEnv -> ModIface -> ImpDeclSpec -> Maybe NameSet -> GlobalRdrEnv +importsFromIface hsc_env iface decl_spec hidden = mkGlobalRdrEnv $ case hidden of + Nothing -> all_gres + Just hidden_names -> filter (not . (`elemNameSet` hidden_names) . greName) all_gres + where + all_gres = gresFromAvails hsc_env (Just imp_spec) (mi_exports iface) + imp_spec = ImpSpec { is_decl = decl_spec, is_item = ImpAll } + filterImports :: HasDebugCallStack => HscEnv @@ -1197,13 +1222,10 @@ filterImports -> Maybe (ImportListInterpretation, LocatedL [LIE GhcPs]) -- ^ Whether this is a "hiding" import list -> RnM (Maybe (ImportListInterpretation, LocatedL [LIE GhcRn]), -- Import spec w/ Names - [GlobalRdrElt]) -- Same again, but in GRE form + ImpUserList, -- same, but designed for storage in interfaces + GlobalRdrEnv) -- Same again, but in GRE form filterImports hsc_env iface decl_spec Nothing - = return (Nothing, gresFromAvails hsc_env (Just imp_spec) all_avails) - where - all_avails = mi_exports iface - imp_spec = ImpSpec { is_decl = decl_spec, is_item = ImpAll } - + = return (Nothing, ImpUserAll, importsFromIface hsc_env iface decl_spec Nothing) filterImports hsc_env iface decl_spec (Just (want_hiding, L l import_items)) = do -- check for errors, convert RdrNames to Names items1 <- mapM lookup_lie import_items @@ -1213,20 +1235,18 @@ filterImports hsc_env iface decl_spec (Just (want_hiding, L l import_items)) -- NB we may have duplicates, and several items -- for the same parent; e.g N(x) and N(y) - gres = case want_hiding of + (gres, imp_user_list) = case want_hiding of Exactly -> - concatMap (gresFromIE decl_spec) items2 + let gre_env = mkGlobalRdrEnv $ concatMap (gresFromIE decl_spec) items2 + in (gre_env, ImpUserExplicit gre_env) EverythingBut -> let hidden_names = mkNameSet $ concatMap (map greName . snd) items2 - keep n = not (n `elemNameSet` hidden_names) - all_gres = gresFromAvails hsc_env (Just hiding_spec) all_avails - in filter (keep . greName) all_gres + in (importsFromIface hsc_env iface decl_spec (Just hidden_names), ImpUserEverythingBut hidden_names) - return (Just (want_hiding, L l (map fst items2)), gres) + return (Just (want_hiding, L l (map fst items2)), imp_user_list, gres) where import_mod = mi_module iface all_avails = mi_exports iface - hiding_spec = ImpSpec { is_decl = decl_spec, is_item = ImpAll } imp_occ_env = mkImportOccEnv hsc_env decl_spec all_avails -- Look up a parent (type constructor, class or data constructor) ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -24,6 +25,7 @@ module GHC.Runtime.Eval ( setupBreakpoint, back, forward, setContext, getContext, + mkTopLevEnv, getNamesInScope, getRdrNamesInScope, moduleIsInterpreted, @@ -53,6 +55,8 @@ import GHC.Driver.DynFlags import GHC.Driver.Ppr import GHC.Driver.Config +import GHC.Rename.Names (gresFromAvails, importsFromIface) + import GHC.Runtime.Eval.Types import GHC.Runtime.Interpreter as GHCi import GHC.Runtime.Heap.Inspect @@ -75,6 +79,7 @@ import GHC.Core.Type hiding( typeKind ) import qualified GHC.Core.Type as Type import GHC.Iface.Env ( newInteractiveBinder ) +import GHC.Iface.Load ( loadSrcInterface ) import GHC.Tc.Utils.TcType import GHC.Tc.Types.Constraint import GHC.Tc.Types.Origin @@ -117,7 +122,7 @@ import GHC.Unit.Home.ModInfo import GHC.Tc.Module ( runTcInteractive, tcRnType, loadUnqualIfaces ) import GHC.Tc.Solver (simplifyWantedsTcM) -import GHC.Tc.Utils.Env (tcGetInstEnvs, lookupGlobal) +import GHC.Tc.Utils.Env (tcGetInstEnvs) import GHC.Tc.Utils.Instantiate (instDFunType) import GHC.Tc.Utils.Monad import GHC.Tc.Zonk.Env ( ZonkFlexi (SkolemiseFlexi) ) @@ -806,14 +811,9 @@ findGlobalRdrEnv :: HscEnv -> [InteractiveImport] findGlobalRdrEnv hsc_env imports = do { idecls_env <- hscRnImportDecls hsc_env idecls -- This call also loads any orphan modules - ; return $ case partitionWith mkEnv imods of - (err : _, _) -> Left err - ([], imods_env0) -> - -- Need to rehydrate the 'GlobalRdrEnv' to recover the 'GREInfo's. - -- This is done in order to avoid space leaks. - -- See Note [Forcing GREInfo] in GHC.Types.GREInfo. - let imods_env = map (hydrateGlobalRdrEnv get_GRE_info) imods_env0 - in Right (foldr plusGlobalRdrEnv idecls_env imods_env) + ; partitionWithM mkEnv imods >>= \case + (err : _, _) -> return $ Left err + ([], imods_env) -> return $ Right (foldr plusGlobalRdrEnv idecls_env imods_env) } where idecls :: [LImportDecl GhcPs] @@ -822,23 +822,33 @@ findGlobalRdrEnv hsc_env imports imods :: [ModuleName] imods = [m | IIModule m <- imports] - mkEnv mod = case mkTopLevEnv (hsc_HPT hsc_env) mod of - Left err -> Left (mod, err) - Right env -> Right env - - get_GRE_info nm = tyThingGREInfo <$> lookupGlobal hsc_env nm + mkEnv mod = mkTopLevEnv hsc_env mod >>= \case + Left err -> pure $ Left (mod, err) + Right env -> pure $ Right env -mkTopLevEnv :: HomePackageTable -> ModuleName -> Either String IfGlobalRdrEnv -mkTopLevEnv hpt modl +mkTopLevEnv :: HscEnv -> ModuleName -> IO (Either String GlobalRdrEnv) +mkTopLevEnv hsc_env modl = case lookupHpt hpt modl of - Nothing -> Left "not a home module" + Nothing -> pure $ Left "not a home module" Just details -> - case mi_globals (hm_iface details) of - Nothing -> Left "not interpreted" - Just env -> Right env - -- It's OK to be lazy here; we force the GlobalRdrEnv before storing it - -- in ModInfo; see GHCi.UI.Info. - -- See Note [Forcing GREInfo] in GHC.Types.GREInfo. + case mi_top_env (hm_iface details) of + Nothing -> pure $ Left "not interpreted" + Just (IfaceTopEnv exports imports) -> do + imports_env <- + runInteractiveHsc hsc_env + $ ioMsgMaybe $ hoistTcRnMessage $ runTcInteractive hsc_env + $ fmap (foldr plusGlobalRdrEnv emptyGlobalRdrEnv) + $ forM imports $ \iface_import -> do + let ImpUserSpec spec details = tcIfaceImport hsc_env iface_import + iface <- loadSrcInterface (text "imported by GHCi") (moduleName $ is_mod spec) (is_isboot spec) (is_pkg_qual spec) + pure $ case details of + ImpUserAll -> importsFromIface hsc_env iface spec Nothing + ImpUserEverythingBut ns -> importsFromIface hsc_env iface spec (Just ns) + ImpUserExplicit x -> x + let exports_env = mkGlobalRdrEnv $ gresFromAvails hsc_env Nothing exports + pure $ Right $ plusGlobalRdrEnv imports_env exports_env + where + hpt = hsc_HPT hsc_env -- | Get the interactive evaluation context, consisting of a pair of the -- set of modules from which we take the full top-level scope, and the set @@ -854,7 +864,7 @@ moduleIsInterpreted modl = withSession $ \h -> if notHomeModule (hsc_home_unit h) modl then return False else case lookupHpt (hsc_HPT h) (moduleName modl) of - Just details -> return (isJust (mi_globals (hm_iface details))) + Just details -> return (isJust (mi_top_env (hm_iface details))) _not_a_home_module -> return False -- | Looks up an identifier in the current interactive context (for :info) ===================================== compiler/GHC/Runtime/Loader.hs ===================================== @@ -49,6 +49,7 @@ import GHC.Core.TyCon ( TyCon(tyConName) ) import GHC.Types.SrcLoc ( noSrcSpan ) import GHC.Types.Name ( Name, nameModule, nameModule_maybe ) import GHC.Types.Id ( idType ) +import GHC.Types.PkgQual import GHC.Types.TyThing import GHC.Types.Name.Occurrence ( OccName, mkVarOccFS ) import GHC.Types.Name.Reader @@ -57,7 +58,7 @@ import GHC.Types.Unique.DFM import GHC.Unit.Finder ( findPluginModule, FindResult(..) ) import GHC.Driver.Config.Finder ( initFinderOpts ) import GHC.Driver.Config.Diagnostic ( initIfaceMessageOpts ) -import GHC.Unit.Module ( Module, ModuleName, thisGhcUnit, GenModule(moduleUnit) ) +import GHC.Unit.Module ( Module, ModuleName, thisGhcUnit, GenModule(moduleUnit), IsBootInterface(NotBoot) ) import GHC.Unit.Module.ModIface import GHC.Unit.Env @@ -357,8 +358,8 @@ lookupRdrNameInModuleForPlugins hsc_env mod_name rdr_name = do case mb_iface of Just iface -> do -- Try and find the required name in the exports - let decl_spec = ImpDeclSpec { is_mod = mod, is_as = mod_name - , is_qual = False, is_dloc = noSrcSpan } + let decl_spec = ImpDeclSpec { is_mod = mod, is_as = mod_name, is_pkg_qual = NoPkgQual + , is_qual = False, is_dloc = noSrcSpan, is_isboot = NotBoot } imp_spec = ImpSpec decl_spec ImpAll env = mkGlobalRdrEnv $ gresFromAvails hsc_env (Just imp_spec) (mi_exports iface) ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -4,7 +4,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TupleSections #-} -module GHC.Tc.Gen.Export (rnExports, exports_from_avail, classifyGREs) where +module GHC.Tc.Gen.Export (rnExports, exports_from_avail, classifyGREs, all_rdr_exports) where import GHC.Prelude @@ -243,6 +243,21 @@ type ExportWarnSpanNames = [(Name, WarningTxt GhcRn, SrcSpan)] -- the spans of export list items that are missing those warnings type DontWarnExportNames = NameEnv (NE.NonEmpty SrcSpan) +all_rdr_exports :: GlobalRdrEnv -> Avails +all_rdr_exports rdr_env = map fix_faminst . gresToAvailInfo . filter isLocalGRE . globalRdrEnvElts $ rdr_env + where + -- #11164: when we define a data instance + -- but not data family, re-export the family + -- Even though we don't check whether this is actually a data family + -- only data families can locally define subordinate things (`ns` here) + -- without locally defining (and instead importing) the parent (`n`) + fix_faminst avail@(AvailTC n ns) + | availExportsDecl avail + = avail + | otherwise + = AvailTC n (n:ns) + fix_faminst avail = avail + exports_from_avail :: Maybe (LocatedL [LIE GhcPs]) -- ^ 'Nothing' means no explicit export list -> GlobalRdrEnv @@ -264,23 +279,8 @@ exports_from_avail Nothing rdr_env _imports _this_mod = do { ; addDiagnostic (TcRnMissingExportList $ moduleName _this_mod) - ; let avails = - map fix_faminst . gresToAvailInfo - . filter isLocalGRE . globalRdrEnvElts $ rdr_env + ; let avails = all_rdr_exports rdr_env ; return (Nothing, avails, []) } - where - -- #11164: when we define a data instance - -- but not data family, re-export the family - -- Even though we don't check whether this is actually a data family - -- only data families can locally define subordinate things (`ns` here) - -- without locally defining (and instead importing) the parent (`n`) - fix_faminst avail@(AvailTC n ns) - | availExportsDecl avail - = avail - | otherwise - = AvailTC n (n:ns) - fix_faminst avail = avail - exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod = do (ie_avails, export_warn_spans, dont_warn_export) ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -373,7 +373,7 @@ tcRnModuleTcRnM hsc_env mod_sum tcRnImports :: HscEnv -> [(LImportDecl GhcPs, SDoc)] -> TcM TcGblEnv tcRnImports hsc_env import_decls - = do { (rn_imports, rdr_env, imports, hpc_info) <- rnImports import_decls ; + = do { (rn_imports, imp_user_spec, rdr_env, imports, hpc_info) <- rnImports import_decls ; ; this_mod <- getModule ; gbl_env <- getGblEnv @@ -402,6 +402,7 @@ tcRnImports hsc_env import_decls gbl { tcg_rdr_env = tcg_rdr_env gbl `plusGlobalRdrEnv` rdr_env, tcg_imports = tcg_imports gbl `plusImportAvails` imports, + tcg_import_decls = imp_user_spec, tcg_rn_imports = rn_imports, tcg_inst_env = tcg_inst_env gbl `unionInstEnv` home_insts, tcg_fam_inst_env = extendFamInstEnvList (tcg_fam_inst_env gbl) ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -43,6 +43,8 @@ module GHC.Tc.Types( -- Renamer types ErrCtxt, ImportAvails(..), emptyImportAvails, plusImportAvails, + ImportUserSpec(..), + ImpUserList(..), mkModDeps, -- Typechecker types @@ -179,6 +181,30 @@ import Data.Map ( Map ) import Data.Typeable ( TypeRep ) import Data.Maybe ( mapMaybe ) +-- | The import specification as written by the user, including +-- the list of explicitly imported names. Used in 'ModIface' to +-- allow GHCi to reconstruct the top level environment on demand. +-- +-- This is distinct from 'ImportSpec' because we don't want to store +-- the list of explicitly imported names along with each 'GRE' +-- +-- We don't want to store the entire GlobalRdrEnv for modules that +-- are imported without explicit export lists, as these may grow +-- to be very large. However, GlobalRdrEnvs which are the result +-- of explicit import lists are typically quite small. +-- +-- Why do we not store something like (Maybe (ImportListInterpretation, [IE GhcPs]) in such a case? +-- Because we don't want to store source syntax including annotations in +-- interface files. +data ImportUserSpec + = ImpUserSpec { ius_decl :: !ImpDeclSpec + , ius_imports :: !ImpUserList + } + +data ImpUserList + = ImpUserAll -- ^ no user import list + | ImpUserExplicit !GlobalRdrEnv + | ImpUserEverythingBut !NameSet -- | A 'NameShape' is a substitution on 'Name's that can be used -- to refine the identities of a hole while we are renaming interfaces @@ -507,6 +533,7 @@ data TcGblEnv -- These three fields track unused bindings and imports -- See Note [Tracking unused binding and imports] + tcg_import_decls :: ![ImportUserSpec], tcg_dus :: DefUses, tcg_used_gres :: TcRef [GlobalRdrElt], -- ^ INVARIANT: all these GREs were imported; that is, ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -635,10 +635,12 @@ mergeSignatures -- because we need module -- LocalSig (from the local -- export list) to match it! - is_mod = mi_module ireq_iface, - is_as = mod_name, - is_qual = False, - is_dloc = locA loc + is_mod = mi_module ireq_iface, + is_as = mod_name, + is_pkg_qual = NoPkgQual, + is_qual = False, + is_isboot = NotBoot, + is_dloc = locA loc } ImpAll rdr_env = mkGlobalRdrEnv $ gresFromAvails hsc_env (Just ispec) as1 setGblEnv tcg_env { ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -318,6 +318,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this tcg_th_needed_deps = th_needed_deps_var, tcg_exports = [], tcg_imports = emptyImportAvails, + tcg_import_decls = [], tcg_used_gres = used_gre_var, tcg_dus = emptyDUs, ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -121,6 +121,7 @@ import GHC.Types.Name import GHC.Types.Name.Env ( NameEnv, nonDetNameEnvElts, emptyNameEnv, extendNameEnv_Acc ) import GHC.Types.Name.Set +import GHC.Types.PkgQual import GHC.Types.SrcLoc as SrcLoc import GHC.Types.Unique import GHC.Types.Unique.FM @@ -1780,7 +1781,9 @@ shadowNames drop_only_qualified env new_gres = minusOccEnv_C_Ns do_shadowing env old_mod_name = moduleName old_mod id_spec = ImpDeclSpec { is_mod = old_mod , is_as = old_mod_name + , is_pkg_qual = NoPkgQual , is_qual = True + , is_isboot = NotBoot , is_dloc = greDefinitionSrcSpan old_gre } set_qual :: ImportSpec -> ImportSpec @@ -1939,10 +1942,15 @@ data ImpDeclSpec -- TODO: either should be Module, or there -- should be a Maybe UnitId here too. is_as :: !ModuleName, -- ^ Import alias, e.g. from @as M@ (or @Muggle@ if there is no @as@ clause) + is_pkg_qual :: !PkgQual, -- ^ Was this a package import? is_qual :: !Bool, -- ^ Was this import qualified? - is_dloc :: !SrcSpan -- ^ The location of the entire import declaration + is_dloc :: !SrcSpan, -- ^ The location of the entire import declaration + is_isboot :: !IsBootInterface -- ^ Was this a SOURCE import? } deriving (Eq, Data) +instance NFData ImpDeclSpec where + rnf = rwhnf -- Already strict in all fields + -- | Import Item Specification -- -- Describes import info a particular Name ===================================== compiler/GHC/Types/PkgQual.hs ===================================== @@ -22,8 +22,8 @@ data RawPkgQual -- package qualifier. data PkgQual = NoPkgQual -- ^ No package qualifier - | ThisPkg UnitId -- ^ Import from home-unit - | OtherPkg UnitId -- ^ Import from another unit + | ThisPkg !UnitId -- ^ Import from home-unit + | OtherPkg !UnitId -- ^ Import from another unit deriving (Data, Ord, Eq) instance Outputable RawPkgQual where ===================================== compiler/GHC/Types/Unique/Set.hs ===================================== @@ -55,6 +55,7 @@ import Data.Coerce import GHC.Utils.Outputable import Data.Data import qualified Data.Semigroup as Semi +import Control.DeepSeq -- Note [UniqSet invariant] -- ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -66,6 +67,9 @@ import qualified Data.Semigroup as Semi newtype UniqSet a = UniqSet {getUniqSet' :: UniqFM a a} deriving (Data, Semi.Semigroup, Monoid) +instance NFData a => NFData (UniqSet a) where + rnf = forceUniqSet rnf + emptyUniqSet :: UniqSet a emptyUniqSet = UniqSet emptyUFM @@ -200,3 +204,7 @@ pprUniqSet :: (a -> SDoc) -> UniqSet a -> SDoc -- It's OK to use nonDetUFMToList here because we only use it for -- pretty-printing. pprUniqSet f = braces . pprWithCommas f . nonDetEltsUniqSet + + +forceUniqSet :: (a -> ()) -> UniqSet a -> () +forceUniqSet f (UniqSet fm) = seqEltsUFM f fm ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -15,6 +15,8 @@ module GHC.Unit.Module.ModIface , IfaceExport , WhetherHasOrphans , WhetherHasFamInst + , IfaceTopEnv (..) + , IfaceImport(..) , mi_boot , mi_fix , mi_semantic_module @@ -45,7 +47,6 @@ import GHC.Types.Fixity import GHC.Types.Fixity.Env import GHC.Types.HpcInfo import GHC.Types.Name -import GHC.Types.Name.Reader import GHC.Types.SafeHaskell import GHC.Types.SourceFile import GHC.Types.Unique.DSet @@ -208,8 +209,8 @@ data ModIface_ (phase :: ModIfacePhase) -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), - -- ^ Binds all the things defined at the top level in + mi_top_env :: !(Maybe IfaceTopEnv), + -- ^ Just enough information to reconstruct the top level environment in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which -- may contains declarations for things not actually @@ -266,6 +267,16 @@ data ModIface_ (phase :: ModIfacePhase) -- ^ Hash of the .hs source, used for recompilation checking. } +-- Enough information to reconstruct the top level environment for a module +data IfaceTopEnv + = IfaceTopEnv + { ifaceTopExports :: ![IfaceExport] -- ^ all top level things in this module, including unexported stuff + , ifaceImports :: ![IfaceImport] -- ^ all the imports in this module + } + +instance NFData IfaceTopEnv where + rnf (IfaceTopEnv a b) = rnf a `seq` rnf b + {- Note [Strictness in ModIface] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -458,7 +469,7 @@ instance Binary ModIface where mi_warns = warns, mi_decls = decls, mi_extra_decls = extra_decls, - mi_globals = Nothing, + mi_top_env = Nothing, mi_insts = insts, mi_fam_insts = fam_insts, mi_rules = rules, @@ -508,7 +519,7 @@ emptyPartialModIface mod mi_rules = [], mi_decls = [], mi_extra_decls = Nothing, - mi_globals = Nothing, + mi_top_env = Nothing, mi_hpc = False, mi_trust = noIfaceTrustInfo, mi_trust_pkg = False, @@ -559,7 +570,7 @@ instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts + , mi_decls, mi_extra_decls, mi_top_env, mi_insts , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg , mi_complete_matches, mi_docs, mi_final_exts , mi_ext_fields, mi_src_hash }) @@ -575,7 +586,7 @@ instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) `seq` rnf mi_anns `seq` rnf mi_decls `seq` rnf mi_extra_decls - `seq` rnf mi_globals + `seq` rnf mi_top_env `seq` rnf mi_insts `seq` rnf mi_fam_insts `seq` rnf mi_rules ===================================== compiler/Language/Haskell/Syntax/ImpExp.hs ===================================== @@ -14,6 +14,8 @@ import Data.Maybe (Maybe) import Data.String (String) import Data.Int (Int) +import Control.DeepSeq + import GHC.Hs.Doc -- ROMES:TODO Discuss in #21592 whether this is parsed AST or base AST {- @@ -48,6 +50,9 @@ data ImportDeclQualifiedStyle data IsBootInterface = NotBoot | IsBoot deriving (Eq, Ord, Show, Data) +instance NFData IsBootInterface where + rnf = rwhnf + -- | Import Declaration -- -- A single Haskell @import@ declaration. @@ -86,6 +91,9 @@ data ImportDecl pass data ImportListInterpretation = Exactly | EverythingBut deriving (Eq, Data) +instance NFData ImportListInterpretation where + rnf = rwhnf + -- | Located Import or Export type LIE pass = XRec pass (IE pass) -- ^ When in a list this may have ===================================== ghc/GHCi/UI.hs ===================================== @@ -36,6 +36,7 @@ import GHCi.UI.Monad hiding ( args, runStmt ) import GHCi.UI.Info import GHCi.UI.Exception import GHC.Runtime.Debugger +import GHC.Runtime.Eval (mkTopLevEnv) -- The GHC interface import GHC.Runtime.Interpreter @@ -75,7 +76,7 @@ import GHC.Types.Var ( varType ) import GHC.Iface.Syntax ( showToHeader ) import GHC.Builtin.Names import GHC.Builtin.Types( stringTyCon_RDR ) -import GHC.Types.Name.Reader as RdrName ( getGRE_NameQualifier_maybes, getRdrName ) +import GHC.Types.Name.Reader as RdrName ( getGRE_NameQualifier_maybes, getRdrName, greName, globalRdrEnvElts) import GHC.Types.SrcLoc as SrcLoc import qualified GHC.Parser.Lexer as Lexer import GHC.Parser.Header ( toArgs ) @@ -98,7 +99,7 @@ import GHC.Data.Graph.Directed import GHC.Utils.Encoding import GHC.Data.FastString import qualified GHC.Linker.Loader as Loader -import GHC.Data.Maybe ( orElse, expectJust ) +import GHC.Data.Maybe ( expectJust ) import GHC.Types.Name.Set import GHC.Utils.Panic hiding ( showException, try ) import GHC.Utils.Misc @@ -206,7 +207,6 @@ ghciCommands = map mkCmd [ ("browse", keepGoing' (browseCmd False), completeModule), ("browse!", keepGoing' (browseCmd True), completeModule), ("cd", keepGoingMulti' changeDirectory, completeFilename), - ("check", keepGoing' checkModule, completeHomeModule), ("continue", keepGoing continueCmd, noCompletion), ("cmd", keepGoing cmdCmd, completeExpression), ("def", keepGoing (defineMacro False), completeExpression), @@ -1892,28 +1892,6 @@ getGhciStepIO = do nlHsFunTy ghciM ioM return $ noLocA $ ExprWithTySig noAnn body tySig ------------------------------------------------------------------------------ --- :check - -checkModule :: GhciMonad m => String -> m () -checkModule m = do - let modl = GHC.mkModuleName m - ok <- handleSourceError (\e -> printErrAndMaybeExit e >> return False) $ do - r <- GHC.typecheckModule =<< GHC.parseModule =<< GHC.getModSummary modl - dflags <- getDynFlags - liftIO $ putStrLn $ showSDoc dflags $ - case GHC.moduleInfo r of - cm | Just scope <- GHC.modInfoTopLevelScope cm -> - let - (loc, glob) = assert (all isExternalName scope) $ - partition ((== modl) . GHC.moduleName . GHC.nameModule) scope - in - (text "global names: " <+> ppr glob) $$ - (text "local names: " <+> ppr loc) - _ -> empty - return True - afterLoad (successIf ok) False - ----------------------------------------------------------------------------- -- :doc @@ -2355,9 +2333,7 @@ typeAtCmd str = runExceptGhciMonad $ do (span',sample) <- exceptT $ parseSpanArg str infos <- lift $ mod_infos <$> getGHCiState (info, ty) <- findType infos span' sample - let mb_rdr_env = case modinfoRdrEnv info of - Strict.Just rdrs -> Just rdrs - Strict.Nothing -> Nothing + let mb_rdr_env = Just (modinfoRdrEnv info) lift $ printForUserGlobalRdrEnv mb_rdr_env (sep [text sample,nest 2 (dcolon <+> ppr ty)]) @@ -2643,10 +2619,16 @@ browseModule bang modl exports_only = do Nothing -> throwGhcException (CmdLineError ("unknown module: " ++ GHC.moduleNameString (GHC.moduleName modl))) Just mod_info -> do - let names - | exports_only = GHC.modInfoExports mod_info - | otherwise = GHC.modInfoTopLevelScope mod_info - `orElse` [] + names <- + if exports_only + then pure $ GHC.modInfoExports mod_info + else do + hsc_env <- GHC.getSession + mmod_env <- liftIO $ mkTopLevEnv hsc_env (moduleName modl) + case mmod_env of + Left err -> throwGhcException (CmdLineError (GHC.moduleNameString (GHC.moduleName modl) ++ " " ++ err)) + Right mod_env -> pure $ map greName . globalRdrEnvElts $ mod_env + let -- sort alphabetically name, but putting locally-defined -- identifiers first. We would like to improve this; see #1799. @@ -3558,7 +3540,7 @@ completeCmd argLine0 = case parseLine argLine0 of completeGhciCommand, completeMacro, completeIdentifier, completeModule, completeSetModule, completeSeti, completeShowiOptions, - completeHomeModule, completeSetOptions, completeShowOptions, + completeSetOptions, completeShowOptions, completeHomeModuleOrFile, completeExpression, completeBreakpoint :: GhciMonad m => CompletionFunc m @@ -3707,8 +3689,6 @@ completeSetModule = wrapIdentCompleterWithModifier "+-" $ \m w -> do return $ loaded_mods ++ pkg_mods return $ filter (w `isPrefixOf`) $ map (showPpr (hsc_dflags hsc_env)) modules -completeHomeModule = wrapIdentCompleterMod listHomeModules - listHomeModules :: GHC.GhcMonad m => String -> m [String] listHomeModules w = do g <- GHC.getModuleGraph ===================================== ghc/GHCi/UI/Info.hs ===================================== @@ -42,6 +42,7 @@ import GHC.Driver.Monad import GHC.Driver.Env import GHC.Driver.Ppr import GHC.Types.Name +import GHC.Tc.Types import GHC.Types.Name.Reader import GHC.Types.Name.Set import GHC.Utils.Outputable @@ -59,7 +60,7 @@ data ModInfo = ModInfo -- ^ Generated set of information about all spans in the -- module that correspond to some kind of identifier for -- which there will be type info and/or location info. - , modinfoRdrEnv :: !(Strict.Maybe IfGlobalRdrEnv) + , modinfoRdrEnv :: !IfGlobalRdrEnv -- ^ What's in scope in the module. , modinfoLastUpdate :: !UTCTime -- ^ The timestamp of the file used to generate this record. @@ -313,27 +314,19 @@ getModInfo name = do p <- parseModule m typechecked <- typecheckModule p let allTypes = processAllTypeCheckedModule typechecked - module_info = tm_checked_module_info typechecked - !rdr_env = case modInfoRdrEnv module_info of - Just rdrs -> Strict.Just rdrs - -- NB: this has already been deeply forced; no need to do that again. - -- See test case T15369 and Note [Forcing GREInfo] in GHC.Types.GREInfo. - Nothing -> Strict.Nothing + let !rdr_env = tcg_rdr_env (fst $ tm_internals_ typechecked) ts <- liftIO $ getModificationTime $ srcFilePath m return $ ModInfo { modinfoSummary = m , modinfoSpans = allTypes - , modinfoRdrEnv = rdr_env + , modinfoRdrEnv = forceGlobalRdrEnv rdr_env , modinfoLastUpdate = ts } -- | Get the 'Name's from the 'GlobalRdrEnv' of the 'ModInfo', if any. modInfo_rdrs :: ModInfo -> [Name] -modInfo_rdrs mi = - case modinfoRdrEnv mi of - Strict.Nothing -> [] - Strict.Just env -> map greName $ globalRdrEnvElts env +modInfo_rdrs mi = map greName $ globalRdrEnvElts $ modinfoRdrEnv mi -- | Get ALL source spans in the module. processAllTypeCheckedModule :: TypecheckedModule -> [SpanInfo] ===================================== ghc/GHCi/UI/Monad.hs ===================================== @@ -25,7 +25,7 @@ module GHCi.UI.Monad ( ActionStats(..), runAndPrintStats, runWithStats, printStats, printForUserNeverQualify, - printForUserModInfo, printForUserGlobalRdrEnv, + printForUserGlobalRdrEnv, printForUser, printForUserPartWay, prettyLocations, compileGHCiExpr, @@ -365,9 +365,6 @@ printForUserNeverQualify doc = do dflags <- GHC.getInteractiveDynFlags liftIO $ Ppr.printForUser dflags stdout neverQualify AllTheWay doc -printForUserModInfo :: GhcMonad m => GHC.ModuleInfo -> SDoc -> m () -printForUserModInfo info = printForUserGlobalRdrEnv (GHC.modInfoRdrEnv info) - printForUserGlobalRdrEnv :: (GhcMonad m, Outputable info) => Maybe (GlobalRdrEnvX info) -> SDoc -> m () printForUserGlobalRdrEnv mb_rdr_env doc = do ===================================== utils/dump-decls/Main.hs ===================================== @@ -177,7 +177,7 @@ reportModuleDecls unit_id modl_nm Nothing -> fail "Failed to find module" Just mod_info -> return mod_info - Just name_ppr_ctx <- mkNamePprCtxForModule mod_info + name_ppr_ctx <- mkNamePprCtxForModule modl mod_info let names = GHC.modInfoExports mod_info sorted_names = sortBy (compare `on` nameOccName) names View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/918daaef1ff86268b35a801294b71d44bb509f6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/918daaef1ff86268b35a801294b71d44bb509f6f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 10:03:29 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 06 Mar 2024 05:03:29 -0500 Subject: [Git][ghc/ghc][wip/no-mi-globals] 106 commits: EPA: Move EpAnn out of extension points Message-ID: <65e83f71e7e8a_33764d58abe47206e@gitlab.mail> Zubin pushed to branch wip/no-mi-globals at Glasgow Haskell Compiler / GHC Commits: 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 921cacbb by Zubin Duggal at 2024-03-06T15:33:16+05:30 Don't store a GlobalRdrEnv in `mi_globals` for GHCi. GHCi only needs the `mi_globals` field for modules imported with :module +*SomeModule. It uses this field to make the top level environment in `SomeModule` available to the repl. By default, only the first target in the command line parameters is "star" loaded into GHCi. Other modules have to be manually "star" loaded into the repl. Storing the top level GlobalRdrEnv for each module is very wasteful, especially given that we will most likely never need most of these environments. Instead we store only the information needed to reconstruct the top level environment in a module, which is the `IfaceTopEnv` data structure, consisting of all import statements as well as all top level symbols defined in the module (not taking export lists into account) When a particular module is "star-loaded" into GHCi (as the first commandline target, or via an explicit `:module +*SomeModule`, we reconstruct the top level environment on demand using the `IfaceTopEnv`. - - - - - 22 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.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/918daaef1ff86268b35a801294b71d44bb509f6f...921cacbb3111f4ef2b4c571837cef1d04fc6d30f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/918daaef1ff86268b35a801294b71d44bb509f6f...921cacbb3111f4ef2b4c571837cef1d04fc6d30f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 11:12:41 2024 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 06 Mar 2024 06:12:41 -0500 Subject: [Git][ghc/ghc][wip/exception-context] Disable T9930fail for the JS target (cf #19174) Message-ID: <65e84fa9ea4bf_38980e2f594029ed@gitlab.mail> Sylvain Henry pushed to branch wip/exception-context at Glasgow Haskell Compiler / GHC Commits: 8d4786dd by Sylvain Henry at 2024-03-06T12:12:16+01:00 Disable T9930fail for the JS target (cf #19174) - - - - - 1 changed file: - testsuite/tests/ghc-e/should_fail/all.T Changes: ===================================== testsuite/tests/ghc-e/should_fail/all.T ===================================== @@ -12,7 +12,12 @@ test('ghc-e-fail2', req_interp, makefile_test, ['ghc-e-fail2']) # Don't run on Windows, as executable is written to T9930.exe # and no failure is induced. -test('T9930fail', [extra_files(['T9930']), when(opsys('mingw32'), skip)], +test('T9930fail', + [extra_files(['T9930']), + when(opsys('mingw32'), skip), + # broken for JS until cross-compilers become stage2 compilers (#19174) + # or until we bootstrap with a 9.10 compiler + js_broken(19174)], makefile_test, ['T9930fail']) test('T18441fail0', req_interp, makefile_test, ['T18441fail0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d4786ddd608f72127f4fe8f7bf69746d1f38fd1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d4786ddd608f72127f4fe8f7bf69746d1f38fd1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 11:24:17 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 06 Mar 2024 06:24:17 -0500 Subject: [Git][ghc/ghc][wip/T22423] 510 commits: Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. Message-ID: <65e852613bafa_38980ec9a2c05875@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22423 at Glasgow Haskell Compiler / GHC Commits: e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 1d0ad63c by Simon Peyton Jones at 2024-03-05T14:57:34+00:00 Solve #22423 by inlining only values in callSiteInline Needs a proper commit message ... this is just to try it out. - - - - - 85d8099a by Simon Peyton Jones at 2024-03-06T11:23:09+00:00 Refine exprIsWorkFree This makes it a bit less eager to inline multi-branch cases. - - - - - 15 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/merge_request_templates/Default.md - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/upload.sh - .gitmodules - CODEOWNERS - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1c525ee1f08a51a88df75a152c54b2a867f2d99e...85d8099a261e7c890620c1ac7cfd81268f60a723 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1c525ee1f08a51a88df75a152c54b2a867f2d99e...85d8099a261e7c890620c1ac7cfd81268f60a723 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 12:11:56 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 06 Mar 2024 07:11:56 -0500 Subject: [Git][ghc/ghc][wip/T22423] Wibble Message-ID: <65e85d8cf33b4_38980e1ead7f0165cb@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22423 at Glasgow Haskell Compiler / GHC Commits: dea92489 by Simon Peyton Jones at 2024-03-06T12:11:46+00:00 Wibble - - - - - 1 changed file: - compiler/GHC/Core/Utils.hs Changes: ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -1350,7 +1350,7 @@ exprIsWorkFree e = ok e go _ (Type {}) = True go _ (Coercion {}) = True go n (Cast e _) = go n e - go n (Case scrut _ _ alts) = ok_alts alts && ok scrut + go _ (Case scrut _ _ alts) = ok_alts alts && ok scrut go n (Tick t e) | tickishCounts t = False | otherwise = go n e go n (Lam x e) | isRuntimeVar x = n==0 || go (n-1) e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dea9248975c4943e1554dc2f268a3d492bfe32ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dea9248975c4943e1554dc2f268a3d492bfe32ba You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 12:58:58 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 06 Mar 2024 07:58:58 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: rts: expose HeapAlloc.h as public header Message-ID: <65e868923a805_38980e36734fc2409c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2f70df21 by Cheng Shao at 2024-03-06T07:58:49-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - 40dd48c9 by Cheng Shao at 2024-03-06T07:58:49-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 23cf680a by Ben Gamari at 2024-03-06T07:58:49-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - e04d3828 by Simon Peyton Jones at 2024-03-06T07:58:49-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 5a1dd7cb by Hécate Moonlight at 2024-03-06T07:58:54-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs - libraries/base/src/System/IO.hs - libraries/base/src/System/Mem/Weak.hs - libraries/base/src/System/Posix/Internals.hs - libraries/base/src/Text/ParserCombinators/ReadP.hs - libraries/base/src/Text/ParserCombinators/ReadPrec.hs - libraries/base/src/Text/Read.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - rts/Sparks.c - rts/include/rts/storage/Block.h - rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h - rts/posix/OSMem.c - rts/rts.cabal - rts/sm/CNF.c - rts/sm/GC.h - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/Sanity.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/99474b0aed8a30d4a3a024f4f88a94abbd1a6e01...5a1dd7cba418cf0866db91cd81fa45f2445c93ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/99474b0aed8a30d4a3a024f4f88a94abbd1a6e01...5a1dd7cba418cf0866db91cd81fa45f2445c93ec You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 13:26:39 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 06 Mar 2024 08:26:39 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24031 Message-ID: <65e86f0fc9474_38980e41d9684357c8@gitlab.mail> Teo Camarasu pushed new branch wip/T24031 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24031 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 13:29:09 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 06 Mar 2024 08:29:09 -0500 Subject: [Git][ghc/ghc][wip/T24031] Deprecate PrimTyConI Message-ID: <65e86fa511f56_38980e443c0d4359eb@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: c6a95112 by Teo Camarasu at 2024-03-06T13:28:57+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 7 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/th/T16293b.hs - + testsuite/tests/th/T24031.hs - + testsuite/tests/th/T24031.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2120,15 +2120,6 @@ reifyTyCon tc | Just cls <- tyConClass_maybe tc = reifyClass cls -{- Seems to be just a short cut for the next equation -- omit - | tc `hasKey` fUNTyConKey -- I'm not quite sure what is happening here - = return (TH.PrimTyConI (reifyName tc) 2 False) --} - - | isPrimTyCon tc - = return (TH.PrimTyConI (reifyName tc) (length (tyConVisibleTyVars tc)) - (isUnliftedTypeKind (tyConResKind tc))) - | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2068,6 +2068,7 @@ data Info Name Type -- What it is bound to deriving( Show, Eq, Ord, Data, Generic ) +{-# DEPRECATED PrimTyConI "TyConI is now produced instead." #-} -- | Obtained from 'reifyModule' in the 'Q' Monad. data ModuleInfo = ===================================== libraries/template-haskell/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`template-haskell` package](http://hackage.haskell.org/package/template-haskell) +## 2.23.0.0 + * Deprecate `PrimTyConI`. `TyConI` will now produced to represent primitive types. + ## 2.22.0.0 * The kind of `Code` was changed from `forall r. (Type -> Type) -> TYPE r -> Type` ===================================== testsuite/tests/th/T16293b.hs ===================================== @@ -7,7 +7,8 @@ import GHC.Exts import Language.Haskell.TH f :: () -f = $(do PrimTyConI _ arity _ <- reify ''Proxy# +f = $(do TyConI (DataD _ _ targs _ _ _) <- reify ''Proxy# + let arity = length targs unless (arity == 1) $ fail $ "Unexpected arity for Proxy#: " ++ show arity [| () |]) ===================================== testsuite/tests/th/T24031.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE LinearTypes #-} +-- | This test shows that we can reify a bunch of wired-in types. +-- Additionally it acts as a golden test to ensure that we don't accidentally change +-- our output for these types. +module T24031 where + +import Control.Monad +import Data.Char +import GHC.Exts +import Language.Haskell.TH + +f :: () +f = $(do let types = + [ ''Int# + , ''Word# + , ''Array# + , ''SmallArray# + , ''ByteArray# + , ''MutableByteArray# + , unboxedTupleTypeName 2 + , unboxedSumTypeName 2 + , ''(->) + , ''[] + , tupleTypeName 2 + ] + reified <- mapM reify types + let stripInt [] = [] + stripInt (x:xs) + | isDigit x = stripInt xs + | otherwise = x:xs + -- remove _[0-9]* sequences + let stripUniques ('_':xs) = stripUniques $ stripInt xs + stripUniques (x:xs)= x:stripUniques xs + stripUniques [] = [] + mapM_ (runIO . putStrLn . stripUniques . show) reified + [| () |]) ===================================== testsuite/tests/th/T24031.stderr ===================================== @@ -0,0 +1,11 @@ +TyConI (DataD [] GHC.Prim.Int# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Array# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallArray# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.ByteArray# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableByteArray# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Types.Tuple2# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k0)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k1))] Nothing [NormalC GHC.Types.(#,#) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a),(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) +TyConI (DataD [] GHC.Types.Sum2# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k0)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k1))] Nothing [NormalC GHC.Types.(# | #) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a)],NormalC GHC.Types.(# | #) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) +TyConI (TySynD GHC.Types.-> [] (AppT (ConT GHC.Prim.FUN) (PromotedT GHC.Types.Many))) +TyConI (DataD [] GHC.Types.List [KindedTV a BndrReq StarT] Nothing [NormalC GHC.Types.[] [],InfixC (Bang NoSourceUnpackedness NoSourceStrictness,VarT a) GHC.Types.: (Bang NoSourceUnpackedness NoSourceStrictness,AppT ListT (VarT a))] []) +TyConI (DataD [] GHC.Tuple.Tuple2 [KindedTV a BndrReq StarT,KindedTV b BndrReq StarT] Nothing [NormalC GHC.Tuple.(,) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a),(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24031', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6a95112495c5da4667900421266263a9ad4b908 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6a95112495c5da4667900421266263a9ad4b908 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 13:31:07 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 06 Mar 2024 08:31:07 -0500 Subject: [Git][ghc/ghc][wip/T24031] Deprecate PrimTyConI Message-ID: <65e8701b8093d_38980e46ae0ec3772b@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: bf081986 by Teo Camarasu at 2024-03-06T13:30:58+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 7 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/th/T16293b.hs - + testsuite/tests/th/T24031.hs - + testsuite/tests/th/T24031.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2120,15 +2120,6 @@ reifyTyCon tc | Just cls <- tyConClass_maybe tc = reifyClass cls -{- Seems to be just a short cut for the next equation -- omit - | tc `hasKey` fUNTyConKey -- I'm not quite sure what is happening here - = return (TH.PrimTyConI (reifyName tc) 2 False) --} - - | isPrimTyCon tc - = return (TH.PrimTyConI (reifyName tc) (length (tyConVisibleTyVars tc)) - (isUnliftedTypeKind (tyConResKind tc))) - | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2068,6 +2068,7 @@ data Info Name Type -- What it is bound to deriving( Show, Eq, Ord, Data, Generic ) +{-# DEPRECATED PrimTyConI "TyConI is now produced instead." #-} -- | Obtained from 'reifyModule' in the 'Q' Monad. data ModuleInfo = ===================================== libraries/template-haskell/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`template-haskell` package](http://hackage.haskell.org/package/template-haskell) +## 2.23.0.0 + * Deprecate `PrimTyConI`. `TyConI` will now be produced to represent primitive types. + ## 2.22.0.0 * The kind of `Code` was changed from `forall r. (Type -> Type) -> TYPE r -> Type` ===================================== testsuite/tests/th/T16293b.hs ===================================== @@ -7,7 +7,8 @@ import GHC.Exts import Language.Haskell.TH f :: () -f = $(do PrimTyConI _ arity _ <- reify ''Proxy# +f = $(do TyConI (DataD _ _ targs _ _ _) <- reify ''Proxy# + let arity = length targs unless (arity == 1) $ fail $ "Unexpected arity for Proxy#: " ++ show arity [| () |]) ===================================== testsuite/tests/th/T24031.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE LinearTypes #-} +-- | This test shows that we can reify a bunch of wired-in types. +-- Additionally it acts as a golden test to ensure that we don't accidentally change +-- our output for these types. +module T24031 where + +import Control.Monad +import Data.Char +import GHC.Exts +import Language.Haskell.TH + +f :: () +f = $(do let types = + [ ''Int# + , ''Word# + , ''Array# + , ''SmallArray# + , ''ByteArray# + , ''MutableByteArray# + , unboxedTupleTypeName 2 + , unboxedSumTypeName 2 + , ''(->) + , ''[] + , tupleTypeName 2 + ] + reified <- mapM reify types + let stripInt [] = [] + stripInt (x:xs) + | isDigit x = stripInt xs + | otherwise = x:xs + -- remove _[0-9]* sequences + let stripUniques ('_':xs) = stripUniques $ stripInt xs + stripUniques (x:xs)= x:stripUniques xs + stripUniques [] = [] + mapM_ (runIO . putStrLn . stripUniques . show) reified + [| () |]) ===================================== testsuite/tests/th/T24031.stderr ===================================== @@ -0,0 +1,11 @@ +TyConI (DataD [] GHC.Prim.Int# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Array# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallArray# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.ByteArray# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableByteArray# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Types.Tuple2# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k0)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k1))] Nothing [NormalC GHC.Types.(#,#) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a),(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) +TyConI (DataD [] GHC.Types.Sum2# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k0)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k1))] Nothing [NormalC GHC.Types.(# | #) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a)],NormalC GHC.Types.(# | #) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) +TyConI (TySynD GHC.Types.-> [] (AppT (ConT GHC.Prim.FUN) (PromotedT GHC.Types.Many))) +TyConI (DataD [] GHC.Types.List [KindedTV a BndrReq StarT] Nothing [NormalC GHC.Types.[] [],InfixC (Bang NoSourceUnpackedness NoSourceStrictness,VarT a) GHC.Types.: (Bang NoSourceUnpackedness NoSourceStrictness,AppT ListT (VarT a))] []) +TyConI (DataD [] GHC.Tuple.Tuple2 [KindedTV a BndrReq StarT,KindedTV b BndrReq StarT] Nothing [NormalC GHC.Tuple.(,) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a),(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24031', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf081986c318dd63302ac5f93b9ef591696e7152 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf081986c318dd63302ac5f93b9ef591696e7152 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 13:37:54 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 06 Mar 2024 08:37:54 -0500 Subject: [Git][ghc/ghc][wip/T24031] Deprecate PrimTyConI Message-ID: <65e871b27f9ba_38980e49aa19c3829@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: e4238ae8 by Teo Camarasu at 2024-03-06T13:37:46+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 7 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/th/T16293b.hs - + testsuite/tests/th/T24031.hs - + testsuite/tests/th/T24031.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2120,15 +2120,6 @@ reifyTyCon tc | Just cls <- tyConClass_maybe tc = reifyClass cls -{- Seems to be just a short cut for the next equation -- omit - | tc `hasKey` fUNTyConKey -- I'm not quite sure what is happening here - = return (TH.PrimTyConI (reifyName tc) 2 False) --} - - | isPrimTyCon tc - = return (TH.PrimTyConI (reifyName tc) (length (tyConVisibleTyVars tc)) - (isUnliftedTypeKind (tyConResKind tc))) - | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2068,6 +2068,7 @@ data Info Name Type -- What it is bound to deriving( Show, Eq, Ord, Data, Generic ) +{-# DEPRECATED PrimTyConI "TyConI is now produced instead." #-} -- | Obtained from 'reifyModule' in the 'Q' Monad. data ModuleInfo = ===================================== libraries/template-haskell/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`template-haskell` package](http://hackage.haskell.org/package/template-haskell) +## 2.23.0.0 + * `PrimTyConI` has been deprecated. `TyConI` will now be used to represent primitive types. + ## 2.22.0.0 * The kind of `Code` was changed from `forall r. (Type -> Type) -> TYPE r -> Type` ===================================== testsuite/tests/th/T16293b.hs ===================================== @@ -7,7 +7,8 @@ import GHC.Exts import Language.Haskell.TH f :: () -f = $(do PrimTyConI _ arity _ <- reify ''Proxy# +f = $(do TyConI (DataD _ _ targs _ _ _) <- reify ''Proxy# + let arity = length targs unless (arity == 1) $ fail $ "Unexpected arity for Proxy#: " ++ show arity [| () |]) ===================================== testsuite/tests/th/T24031.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE LinearTypes #-} +-- | This test shows that we can reify a bunch of wired-in types. +-- Additionally it acts as a golden test to ensure that we don't accidentally change +-- our output for these types. +module T24031 where + +import Control.Monad +import Data.Char +import GHC.Exts +import Language.Haskell.TH + +f :: () +f = $(do let types = + [ ''Int# + , ''Word# + , ''Array# + , ''SmallArray# + , ''ByteArray# + , ''MutableByteArray# + , unboxedTupleTypeName 2 + , unboxedSumTypeName 2 + , ''(->) + , ''[] + , tupleTypeName 2 + ] + reified <- mapM reify types + let stripInt [] = [] + stripInt (x:xs) + | isDigit x = stripInt xs + | otherwise = x:xs + -- remove _[0-9]* sequences + let stripUniques ('_':xs) = stripUniques $ stripInt xs + stripUniques (x:xs)= x:stripUniques xs + stripUniques [] = [] + mapM_ (runIO . putStrLn . stripUniques . show) reified + [| () |]) ===================================== testsuite/tests/th/T24031.stderr ===================================== @@ -0,0 +1,11 @@ +TyConI (DataD [] GHC.Prim.Int# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Array# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallArray# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.ByteArray# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableByteArray# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Types.Tuple2# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k0)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k1))] Nothing [NormalC GHC.Types.(#,#) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a),(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) +TyConI (DataD [] GHC.Types.Sum2# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k0)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT k1))] Nothing [NormalC GHC.Types.(# | #) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a)],NormalC GHC.Types.(# | #) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) +TyConI (TySynD GHC.Types.-> [] (AppT (ConT GHC.Prim.FUN) (PromotedT GHC.Types.Many))) +TyConI (DataD [] GHC.Types.List [KindedTV a BndrReq StarT] Nothing [NormalC GHC.Types.[] [],InfixC (Bang NoSourceUnpackedness NoSourceStrictness,VarT a) GHC.Types.: (Bang NoSourceUnpackedness NoSourceStrictness,AppT ListT (VarT a))] []) +TyConI (DataD [] GHC.Tuple.Tuple2 [KindedTV a BndrReq StarT,KindedTV b BndrReq StarT] Nothing [NormalC GHC.Tuple.(,) [(Bang NoSourceUnpackedness NoSourceStrictness,VarT a),(Bang NoSourceUnpackedness NoSourceStrictness,VarT b)]] []) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24031', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e4238ae80bcec3fc44e6972bb19f3e0232b7937d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e4238ae80bcec3fc44e6972bb19f3e0232b7937d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 14:09:52 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Wed, 06 Mar 2024 09:09:52 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/supersven/AArch64_takeRegRegMoveInst Message-ID: <65e879308bac7_38980e57bb1c84056c@gitlab.mail> Sven Tennie pushed new branch wip/supersven/AArch64_takeRegRegMoveInst at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/supersven/AArch64_takeRegRegMoveInst You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 14:53:22 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 06 Mar 2024 09:53:22 -0500 Subject: [Git][ghc/ghc][wip/T24031] Deprecate PrimTyConI Message-ID: <65e8836277893_38980e68bd020513f7@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: 60aa8a74 by Teo Camarasu at 2024-03-06T14:53:09+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 7 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/th/T16293b.hs - + testsuite/tests/th/T24031.hs - + testsuite/tests/th/T24031.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -26,7 +26,7 @@ module GHC.Tc.Gen.Splice( runMetaE, runMetaP, runMetaT, runMetaD, runQuasi, tcTopSpliceExpr, lookupThName_maybe, defaultRunMeta, runMeta', runRemoteModFinalizers, - finishTH, runTopSplice + finishTH, runTopSplice, reifyName ) where import GHC.Prelude @@ -2120,15 +2120,6 @@ reifyTyCon tc | Just cls <- tyConClass_maybe tc = reifyClass cls -{- Seems to be just a short cut for the next equation -- omit - | tc `hasKey` fUNTyConKey -- I'm not quite sure what is happening here - = return (TH.PrimTyConI (reifyName tc) 2 False) --} - - | isPrimTyCon tc - = return (TH.PrimTyConI (reifyName tc) (length (tyConVisibleTyVars tc)) - (isUnliftedTypeKind (tyConResKind tc))) - | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2068,6 +2068,7 @@ data Info Name Type -- What it is bound to deriving( Show, Eq, Ord, Data, Generic ) +{-# DEPRECATED PrimTyConI "TyConI is now produced instead." #-} -- | Obtained from 'reifyModule' in the 'Q' Monad. data ModuleInfo = ===================================== libraries/template-haskell/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`template-haskell` package](http://hackage.haskell.org/package/template-haskell) +## 2.23.0.0 + * `PrimTyConI` has been deprecated. `TyConI` will now be used to represent primitive types. + ## 2.22.0.0 * The kind of `Code` was changed from `forall r. (Type -> Type) -> TYPE r -> Type` ===================================== testsuite/tests/th/T16293b.hs ===================================== @@ -7,7 +7,8 @@ import GHC.Exts import Language.Haskell.TH f :: () -f = $(do PrimTyConI _ arity _ <- reify ''Proxy# +f = $(do TyConI (DataD _ _ targs _ _ _) <- reify ''Proxy# + let arity = length targs unless (arity == 1) $ fail $ "Unexpected arity for Proxy#: " ++ show arity [| () |]) ===================================== testsuite/tests/th/T24031.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE LinearTypes #-} +-- | This test shows that we can reify a bunch of primitive types. +-- Additionally it acts as a golden test to ensure that we don't +-- accidentally change our output for these types. +module T24031 where + +import Control.Monad +import Data.Char +import GHC.Exts +import Language.Haskell.TH +import GHC.Builtin.Types.Prim +import GHC.Tc.Gen.Splice + +f :: () +f = $(do let types = map reifyName primTyCons + reified <- mapM reify types + let stripInt [] = [] + stripInt (x:xs) + | isDigit x = stripInt xs + | otherwise = x:xs + -- remove _[0-9]* sequences + let stripUniques ('_':xs) = stripUniques $ stripInt xs + stripUniques (x:xs)= x:stripUniques xs + stripUniques [] = [] + mapM_ (runIO . putStrLn . stripUniques . show) reified + [| () |]) ===================================== testsuite/tests/th/T24031.stderr ===================================== @@ -0,0 +1,74 @@ +TyConI (DataD [] GHC.Prim.~# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.~R# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.~P# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.=> [KindedTV a BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.==> [KindedTV a BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.-=> [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Addr# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Array# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.ByteArray# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallArray# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Char# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Double# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Float# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.BCO [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Weak# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableArray# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableByteArray# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallMutableArray# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.IOPort# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.TVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.RealWorld [] Nothing [] []) +TyConI (DataD [] GHC.Prim.StablePtr# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.StableName# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Compact# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.State# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.Proxy# [KindedTV a BndrReq (VarT k)] Nothing [] []) +TyConI (DataD [] GHC.Prim.ThreadId# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.StackSnapshot# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.PromptTag# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.FUN [KindedTV n BndrReq (ConT GHC.Types.Multiplicity),KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.TYPE [KindedTV a BndrReq (ConT GHC.Types.RuntimeRep)] Nothing [] []) +TyConI (DataD [] GHC.Prim.CONSTRAINT [KindedTV a BndrReq (ConT GHC.Types.RuntimeRep)] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX8# [] Nothing [] []) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24031', normal, compile, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60aa8a7448ce3c528244841457fe19330e0fc8eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60aa8a7448ce3c528244841457fe19330e0fc8eb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 15:14:04 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 06 Mar 2024 10:14:04 -0500 Subject: [Git][ghc/ghc][wip/T24031] Deprecate PrimTyConI Message-ID: <65e8883c423bd_38980e74ae50056494@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: a7072520 by Teo Camarasu at 2024-03-06T15:13:55+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 8 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/th/T16293b.hs - + testsuite/tests/th/T24031.hs - + testsuite/tests/th/T24031.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -26,7 +26,7 @@ module GHC.Tc.Gen.Splice( runMetaE, runMetaP, runMetaT, runMetaD, runQuasi, tcTopSpliceExpr, lookupThName_maybe, defaultRunMeta, runMeta', runRemoteModFinalizers, - finishTH, runTopSplice + finishTH, runTopSplice, reifyName ) where import GHC.Prelude @@ -2120,15 +2120,6 @@ reifyTyCon tc | Just cls <- tyConClass_maybe tc = reifyClass cls -{- Seems to be just a short cut for the next equation -- omit - | tc `hasKey` fUNTyConKey -- I'm not quite sure what is happening here - = return (TH.PrimTyConI (reifyName tc) 2 False) --} - - | isPrimTyCon tc - = return (TH.PrimTyConI (reifyName tc) (length (tyConVisibleTyVars tc)) - (isUnliftedTypeKind (tyConResKind tc))) - | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc ===================================== libraries/template-haskell/Language/Haskell/TH/Ppr.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE Safe #-} {-# LANGUAGE LambdaCase #-} +{-# OPTIONS_GHC -Wno-deprecations #-} -- | contains a prettyprinter for the -- Template Haskell datatypes ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2068,6 +2068,7 @@ data Info Name Type -- What it is bound to deriving( Show, Eq, Ord, Data, Generic ) +{-# DEPRECATED PrimTyConI "TyConI is now produced instead." #-} -- | Obtained from 'reifyModule' in the 'Q' Monad. data ModuleInfo = ===================================== libraries/template-haskell/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`template-haskell` package](http://hackage.haskell.org/package/template-haskell) +## 2.23.0.0 + * `PrimTyConI` has been deprecated. `TyConI` will now be used to represent primitive types. + ## 2.22.0.0 * The kind of `Code` was changed from `forall r. (Type -> Type) -> TYPE r -> Type` ===================================== testsuite/tests/th/T16293b.hs ===================================== @@ -7,7 +7,8 @@ import GHC.Exts import Language.Haskell.TH f :: () -f = $(do PrimTyConI _ arity _ <- reify ''Proxy# +f = $(do TyConI (DataD _ _ targs _ _ _) <- reify ''Proxy# + let arity = length targs unless (arity == 1) $ fail $ "Unexpected arity for Proxy#: " ++ show arity [| () |]) ===================================== testsuite/tests/th/T24031.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE LinearTypes #-} +-- | This test shows that we can reify a bunch of primitive types. +-- Additionally it acts as a golden test to ensure that we don't +-- accidentally change our output for these types. +module T24031 where + +import Control.Monad +import Data.Char +import GHC.Exts +import Language.Haskell.TH +import GHC.Builtin.Types.Prim +import GHC.Tc.Gen.Splice + +f :: () +f = $(do let types = map reifyName primTyCons + reified <- mapM reify types + let stripInt [] = [] + stripInt (x:xs) + | isDigit x = stripInt xs + | otherwise = x:xs + -- remove _[0-9]* sequences + let stripUniques ('_':xs) = stripUniques $ stripInt xs + stripUniques (x:xs)= x:stripUniques xs + stripUniques [] = [] + mapM_ (runIO . putStrLn . stripUniques . show) reified + [| () |]) ===================================== testsuite/tests/th/T24031.stderr ===================================== @@ -0,0 +1,74 @@ +TyConI (DataD [] GHC.Prim.~# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.~R# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.~P# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.=> [KindedTV a BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.==> [KindedTV a BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.-=> [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Addr# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Array# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.ByteArray# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallArray# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Char# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Double# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Float# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.BCO [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Weak# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableArray# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableByteArray# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallMutableArray# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.IOPort# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.TVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.RealWorld [] Nothing [] []) +TyConI (DataD [] GHC.Prim.StablePtr# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.StableName# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Compact# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.State# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.Proxy# [KindedTV a BndrReq (VarT k)] Nothing [] []) +TyConI (DataD [] GHC.Prim.ThreadId# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.StackSnapshot# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.PromptTag# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.FUN [KindedTV n BndrReq (ConT GHC.Types.Multiplicity),KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.TYPE [KindedTV a BndrReq (ConT GHC.Types.RuntimeRep)] Nothing [] []) +TyConI (DataD [] GHC.Prim.CONSTRAINT [KindedTV a BndrReq (ConT GHC.Types.RuntimeRep)] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX8# [] Nothing [] []) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24031', normal, compile, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a707252053e03bcf89a5ca4a82d2766d2d22b89a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a707252053e03bcf89a5ca4a82d2766d2d22b89a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 16:50:54 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 06 Mar 2024 11:50:54 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/stm Message-ID: <65e89eee7724b_38980e9bfee9868512@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/stm at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/stm You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 16:53:12 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 06 Mar 2024 11:53:12 -0500 Subject: [Git][ghc/ghc][wip/andreask/stm] 173 commits: Bump bytestring submodule to something closer to 0.12.1 Message-ID: <65e89f784fba2_38980e9d5c3e470412@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stm at Glasgow Haskell Compiler / GHC Commits: 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - b64a5949 by Andreas Klebinger at 2024-03-06T17:39:43+01:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 18 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/12b442bf9802690fc1efb450e40724bfc0082d2b...b64a59491eab7d12b6a6c50764438ad5c55b5dcb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/12b442bf9802690fc1efb450e40724bfc0082d2b...b64a59491eab7d12b6a6c50764438ad5c55b5dcb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 17:26:53 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 12:26:53 -0500 Subject: [Git][ghc/ghc][ghc-9.10] 39 commits: rts: Fix symbol references in Wasm RTS Message-ID: <65e8a75dcf020_38980eae0f3a874128@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/294c93a580e85e242d90349ae92fa6a7818002bb...21e3f3250e88640087a1a60bee2cc113bf04509f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/294c93a580e85e242d90349ae92fa6a7818002bb...21e3f3250e88640087a1a60bee2cc113bf04509f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 18:18:09 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 13:18:09 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.10 Message-ID: <65e8b361238c0_38980ec798f2c761b8@gitlab.mail> Ben Gamari pushed new branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 18:39:31 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 06 Mar 2024 13:39:31 -0500 Subject: [Git][ghc/ghc][master] 2 commits: rts: expose HeapAlloc.h as public header Message-ID: <65e8b863c87ea_38980ed17a73480034@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 12 changed files: - rts/Sparks.c - rts/include/rts/storage/Block.h - rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h - rts/posix/OSMem.c - rts/rts.cabal - rts/sm/CNF.c - rts/sm/GC.h - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/Sanity.c - rts/wasm/OSMem.c - rts/win32/OSMem.c Changes: ===================================== rts/Sparks.c ===================================== @@ -16,7 +16,7 @@ #include "Sparks.h" #include "ThreadLabels.h" #include "sm/NonMovingMark.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #if defined(THREADED_RTS) ===================================== rts/include/rts/storage/Block.h ===================================== @@ -10,6 +10,10 @@ #include "ghcconfig.h" +#if !defined(CMINUSMINUS) +#include "rts/storage/HeapAlloc.h" +#endif + /* The actual block and megablock-size constants are defined in * rts/include/Constants.h, all constants here are derived from these. */ @@ -190,6 +194,7 @@ typedef struct bdescr_ { EXTERN_INLINE bdescr *Bdescr(StgPtr p); EXTERN_INLINE bdescr *Bdescr(StgPtr p) { + ASSERT(HEAP_ALLOCED_GC(p)); return (bdescr *) ((((W_)p & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) | ((W_)p & ~MBLOCK_MASK) ===================================== rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h ===================================== @@ -8,8 +8,6 @@ #pragma once -#include "BeginPrivate.h" - #if defined(THREADED_RTS) // needed for HEAP_ALLOCED below extern SpinLock gc_alloc_block_sync; @@ -227,5 +225,3 @@ StgBool HEAP_ALLOCED_GC(const void *p) #else # error HEAP_ALLOCED not defined #endif - -#include "EndPrivate.h" ===================================== rts/posix/OSMem.c ===================================== @@ -13,7 +13,7 @@ #include "RtsUtils.h" #include "sm/OSMem.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #if defined(HAVE_UNISTD_H) #include ===================================== rts/rts.cabal ===================================== @@ -303,6 +303,7 @@ library rts/storage/Closures.h rts/storage/FunTypes.h rts/storage/Heap.h + rts/storage/HeapAlloc.h rts/storage/GC.h rts/storage/InfoTables.h rts/storage/MBlock.h ===================================== rts/sm/CNF.c ===================================== @@ -20,7 +20,7 @@ #include "Storage.h" #include "CNF.h" #include "Hash.h" -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "BlockAlloc.h" #include "Trace.h" #include "sm/ShouldCompact.h" ===================================== rts/sm/GC.h ===================================== @@ -13,7 +13,7 @@ #pragma once -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "BeginPrivate.h" ===================================== rts/sm/NonMoving.h ===================================== @@ -11,7 +11,7 @@ #if !defined(CMINUSMINUS) #include -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "NonMovingMark.h" #include "BeginPrivate.h" ===================================== rts/sm/NonMovingMark.c ===================================== @@ -14,7 +14,7 @@ #include "NonMovingShortcut.h" #include "NonMoving.h" #include "BlockAlloc.h" /* for countBlocks */ -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "Task.h" #include "Trace.h" #include "HeapUtils.h" ===================================== rts/sm/Sanity.c ===================================== @@ -32,7 +32,7 @@ #include "sm/NonMoving.h" #include "sm/NonMovingMark.h" #include "Profiling.h" // prof_arena -#include "HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" /* ----------------------------------------------------------------------------- Forward decls. ===================================== rts/wasm/OSMem.c ===================================== @@ -52,7 +52,7 @@ #include "RtsUtils.h" #include "sm/OSMem.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include <__macro_PAGESIZE.h> ===================================== rts/win32/OSMem.c ===================================== @@ -8,7 +8,7 @@ #include "Rts.h" #include "sm/OSMem.h" -#include "sm/HeapAlloc.h" +#include "rts/storage/HeapAlloc.h" #include "RtsUtils.h" #include View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21e3f3250e88640087a1a60bee2cc113bf04509f...d19441d7981778ab9463557d812d9d7cf586f9e7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21e3f3250e88640087a1a60bee2cc113bf04509f...d19441d7981778ab9463557d812d9d7cf586f9e7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 18:40:21 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 06 Mar 2024 13:40:21 -0500 Subject: [Git][ghc/ghc][master] 2 commits: ghc-experimental: Add dummy dependencies to work around #23942 Message-ID: <65e8b895294cd_38980ed4281ac836a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - 8 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - + testsuite/tests/perf/compiler/T24471.hs - + testsuite/tests/perf/compiler/T24471a.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1270,8 +1270,14 @@ arityLam id (AT oss div) floatIn :: Cost -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn IsCheap at = at -floatIn IsExpensive at = addWork at +-- NB: be as lazy as possible in the Cost-of-E argument; +-- we can often get away without ever looking at it +-- See Note [Care with nested expressions] +floatIn ch at@(AT lams div) + = case lams of + [] -> at + (IsExpensive,_):_ -> at + (_,os):lams -> AT ((ch,os):lams) div addWork :: ArityType -> ArityType -- Add work to the outermost level of the arity type @@ -1354,6 +1360,25 @@ That gives \1.T (see Note [Combining case branches: andWithTail], first bullet). So 'go2' gets an arityType of \(C?)(C1).T, which is what we want. +Note [Care with nested expressions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + arityType (Just ) +We will take + arityType Just = AT [(IsCheap,os)] topDiv +and then do + arityApp (AT [(IsCheap os)] topDiv) (exprCost ) +The result will be AT [] topDiv. It doesn't matter what +is! The same is true of + arityType (let x = in ) +where the cost of doesn't matter unless has a useful +arityType. + +TL;DR in `floatIn`, do not to look at the Cost argument until you have to. + +I found this when looking at #24471, although I don't think it was really +the main culprit. + Note [Combining case branches: andWithTail] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When combining the ArityTypes for two case branches (with andArityType) @@ -1576,7 +1601,7 @@ arityType env (Case scrut bndr _ alts) = alts_type | otherwise -- In the remaining cases we may not push - = addWork alts_type -- evaluation of the scrutinee in + = addWork alts_type -- evaluation of the scrutinee in where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -643,7 +643,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) = lvlExpr env e -- See Note [Case MFEs] lvlMFE env strict_ctxt ann_expr - | floatTopLvlOnly env && not (isTopLvl dest_lvl) + | not float_me + || floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. || hasFreeJoin env fvs -- If there is a free join, don't float -- See Note [Free join points] @@ -652,8 +653,9 @@ lvlMFE env strict_ctxt ann_expr -- how it will be represented at runtime. -- See Note [Representation polymorphism invariants] in GHC.Core || notWorthFloating expr abs_vars - || not float_me - = -- Don't float it out + -- Test notWorhtFloating last; + -- See Note [Large free-variable sets] + = -- Don't float it out lvlExpr env ann_expr | float_is_new_lam || exprIsTopLevelBindable expr expr_ty @@ -822,6 +824,28 @@ early loses opportunities for RULES which (needless to say) are important in some nofib programs (gcd is an example). [SPJ note: I think this is obsolete; the flag seems always on.] +Note [Large free-variable sets] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #24471 we had something like + x1 = I# 1 + ... + x1000 = I# 1000 + foo = f x1 (f x2 (f x3 ....)) +So every sub-expression in `foo` has lots and lots of free variables. But +none of these sub-expressions float anywhere; the entire float-out pass is a +no-op. + +In lvlMFE, we want to find out quickly if the MFE is not-floatable; that is +the common case. In #24471 it turned out that we were testing `abs_vars` (a +relatively complicated calculation that takes at least O(n-free-vars) time to +compute) for every sub-expression. + +Better instead to test `float_me` early. That still involves looking at +dest_lvl, which means looking at every free variable, but the constant factor +is a lot better. + +ToDo: find a way to fix the bad asymptotic complexity. + Note [Floating join point bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly we only float a join point if it can /stay/ a join point. But ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1469,8 +1469,7 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - dec = wantFloatLocal NonRecursive dmd is_unlifted - floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted floats1 arg1 ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1482,23 +1481,29 @@ cpeArg env dmd arg then return (floats2, arg2) else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] - ; let arg3 = cpeEtaExpandArg env arg2 + ; let arity = cpeArgArity env dec arg2 + arg3 = cpeEtaExpand arity arg2 arg_float = mkNonRecFloat env dmd is_unlifted v arg3 ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } -cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg +cpeArgArity :: CorePrepEnv -> FloatDecision -> CoreArg -> Arity -- ^ See Note [Eta expansion of arguments in CorePrep] -cpeEtaExpandArg env arg = cpeEtaExpand arity arg - where - arity | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 - , not (has_join_in_tail_context arg) +-- Returning 0 means "no eta-expansion"; see cpeEtaExpand +cpeArgArity env float_decision arg + | FloatNone <- float_decision + = 0 -- Crucial short-cut + -- See wrinkle (EA2) in Note [Eta expansion of arguments in CorePrep] + + | Just ao <- cp_arityOpts (cpe_config env) -- Just <=> -O1 or -O2 + , not (has_join_in_tail_context arg) -- See Wrinkle (EA1) of Note [Eta expansion of arguments in CorePrep] - = case exprEtaExpandArity ao arg of - Nothing -> 0 - Just at -> arityTypeArity at - | otherwise - = exprArity arg -- this is cheap enough for -O0 + = case exprEtaExpandArity ao arg of + Nothing -> 0 + Just at -> arityTypeArity at + + | otherwise + = exprArity arg -- this is cheap enough for -O0 has_join_in_tail_context :: CoreExpr -> Bool -- ^ Identify the cases where we'd generate invalid `CpeApp`s as described in @@ -1510,34 +1515,10 @@ has_join_in_tail_context (Tick _ e) = has_join_in_tail_context e has_join_in_tail_context (Case _ _ _ alts) = any has_join_in_tail_context (rhssOfAlts alts) has_join_in_tail_context _ = False -{- -Note [Eta expansion of arguments with join heads] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See Note [Eta expansion for join points] in GHC.Core.Opt.Arity -Eta expanding the join point would introduce crap that we can't -generate code for - ------------------------------------------------------------------------------- --- Building the saturated syntax --- --------------------------------------------------------------------------- - -Note [Eta expansion of hasNoBinding things in CorePrep] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -maybeSaturate deals with eta expanding to saturate things that can't deal with -unsaturated applications (identified by 'hasNoBinding', currently -foreign calls, unboxed tuple/sum constructors, and representation-polymorphic -primitives such as 'coerce' and 'unsafeCoerce#'). - -Historical Note: Note that eta expansion in CorePrep used to be very fragile -due to the "prediction" of CAFfyness that we used to make during tidying. -We previously saturated primop -applications here as well but due to this fragility (see #16846) we now deal -with this another way, as described in Note [Primop wrappers] in GHC.Builtin.PrimOps. --} - maybeSaturate :: Id -> CpeApp -> Int -> [CoreTickish] -> UniqSM CpeRhs maybeSaturate fn expr n_args unsat_ticks | hasNoBinding fn -- There's no binding + -- See Note [Eta expansion of hasNoBinding things in CorePrep] = return $ wrapLamBody (\body -> foldr mkTick body unsat_ticks) sat_expr | mark_arity > 0 -- A call-by-value function. See Note [CBV Function Ids] @@ -1567,24 +1548,14 @@ maybeSaturate fn expr n_args unsat_ticks fn_arity = idArity fn excess_arity = (max fn_arity mark_arity) - n_args sat_expr = cpeEtaExpand excess_arity expr - applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) + applied_marks = n_args >= (length . dropWhile (not . isMarkedCbv) . + reverse . expectJust "maybeSaturate" $ (idCbvMarks_maybe fn)) -- For join points we never eta-expand (See Note [Do not eta-expand join points]) - -- so we assert all arguments that need to be passed cbv are visible so that the backend can evalaute them if required.. -{- -************************************************************************ -* * - Simple GHC.Core operations -* * -************************************************************************ --} + -- so we assert all arguments that need to be passed cbv are visible so that the + -- backend can evalaute them if required.. -{- --- ----------------------------------------------------------------------------- --- Eta reduction --- ----------------------------------------------------------------------------- - -Note [Eta expansion] -~~~~~~~~~~~~~~~~~~~~~ +{- Note [Eta expansion] +~~~~~~~~~~~~~~~~~~~~~~~ Eta expand to match the arity claimed by the binder Remember, CorePrep must not change arity @@ -1603,6 +1574,19 @@ NB2: we have to be careful that the result of etaExpand doesn't an SCC note - we're now careful in etaExpand to make sure the SCC is pushed inside any new lambdas that are generated. +Note [Eta expansion of hasNoBinding things in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +maybeSaturate deals with eta expanding to saturate things that can't deal +with unsaturated applications (identified by 'hasNoBinding', currently +foreign calls, unboxed tuple/sum constructors, and representation-polymorphic +primitives such as 'coerce' and 'unsafeCoerce#'). + +Historical Note: Note that eta expansion in CorePrep used to be very fragile +due to the "prediction" of CAFfyness that we used to make during tidying. We +previously saturated primop applications here as well but due to this +fragility (see #16846) we now deal with this another way, as described in +Note [Primop wrappers] in GHC.Builtin.PrimOps. + Note [Eta expansion and the CorePrep invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out to be much much easier to do eta expansion @@ -1685,6 +1669,22 @@ There is a nasty Wrinkle: This scenario occurs rarely; hence it's OK to generate sub-optimal code. The alternative would be to fix Note [Eta expansion for join points], but that's quite challenging due to unfoldings of (recursive) join points. + +(EA2) In cpeArgArity, if float_decision = FloatNone) the `arg` will look like + let in rhs + where is non-empty and can't be floated out of a lazy context (see + `wantFloatLocal`). So we can't eta-expand it anyway, so we can return 0 + forthwith. Without this short-cut we will call exprEtaExpandArity on the + `arg`, and might be enormous. exprEtaExpandArity be very expensive + on this: it uses arityType, and may look at . + + On the other hand, if float_decision = FloatAll, there will be no + let-bindings around 'arg'; they will have floated out. So + exprEtaExpandArity is cheap. + + This can make a huge difference on deeply nested expressions like + f (f (f (f (f ...)))) + #24471 is a good example, where Prep took 25% of compile time! -} cpeEtaExpand :: Arity -> CpeRhs -> CpeRhs @@ -1899,7 +1899,7 @@ instance Outputable FloatInfo where -- See Note [Floating in CorePrep] -- and Note [BindInfo and FloatInfo] data FloatingBind - = Float !CoreBind !BindInfo !FloatInfo + = Float !CoreBind !BindInfo !FloatInfo -- Never a join-point binding | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish @@ -2126,19 +2126,16 @@ data FloatDecision | FloatAll executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) -executeFloatDecision dec floats rhs = do - let (float,stay) = case dec of - _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) - FloatNone -> (emptyFloats, floats) - FloatAll -> (floats, emptyFloats) - -- Wrap `stay` around `rhs`. - -- NB: `rhs` might have lambdas, and we can't - -- put them inside a wrapBinds, which expects a `CpeBody`. - if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` - then return (float, rhs) - else do - (floats', body) <- rhsToBody rhs - return (float, wrapBinds stay $ wrapBinds floats' body) +executeFloatDecision dec floats rhs + = case dec of + FloatAll -> return (floats, rhs) + FloatNone + | isEmptyFloats floats -> return (emptyFloats, rhs) + | otherwise -> do { (floats', body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats $ + wrapBinds floats' body) } + -- FloatNone case: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. wantFloatTop :: Floats -> FloatDecision wantFloatTop fs ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -80,4 +80,5 @@ module Data.Sum.Experimental ( Sum63#, ) where +import GHC.Num.BigNat () -- for build ordering import GHC.Types ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -161,3 +161,4 @@ module Data.Tuple.Experimental ( import GHC.Tuple import GHC.Types import GHC.Classes +import GHC.Num.BigNat () -- for build ordering ===================================== testsuite/tests/perf/compiler/T24471.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471 where + +import T24471a + +{-# OPAQUE foo #-} +foo :: (List_ Int a -> a) -> a +foo alg = $$(between [|| alg ||] 0 1000) ===================================== testsuite/tests/perf/compiler/T24471a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24471a where + +data List_ a f = Nil_ | Cons_ a f deriving Functor + +between alg a b + | a == b = [|| $$alg Nil_ ||] + | otherwise = [|| $$alg (Cons_ a $$(between alg (a + 1) b)) ||] ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -712,3 +712,7 @@ test ('LookupFusion', [collect_stats('bytes allocated',2), when(wordsize(32), skip)], compile_and_run, ['-O2 -package base']) + +test('T24471', + [req_th, collect_compiler_stats('all', 5)], + multimod_compile, ['T24471', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d19441d7981778ab9463557d812d9d7cf586f9e7...1e84b924c40cbfad9e1a0cf5f7d3a40fdc1c88ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d19441d7981778ab9463557d812d9d7cf586f9e7...1e84b924c40cbfad9e1a0cf5f7d3a40fdc1c88ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 18:41:04 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 06 Mar 2024 13:41:04 -0500 Subject: [Git][ghc/ghc][master] Use "module" instead of "library" when applicable in base haddocks Message-ID: <65e8b8c026bff_38980ed63a01c867e0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 15 changed files: - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs - libraries/base/src/System/IO.hs - libraries/base/src/System/Mem/Weak.hs - libraries/base/src/System/Posix/Internals.hs - libraries/base/src/Text/ParserCombinators/ReadP.hs - libraries/base/src/Text/ParserCombinators/ReadPrec.hs - libraries/base/src/Text/Read.hs Changes: ===================================== libraries/base/src/Control/Concurrent.hs ===================================== @@ -147,7 +147,7 @@ by using 'forkOS' instead of 'forkIO'. Haskell threads can communicate via 'MVar's, a kind of synchronised mutable variable (see "Control.Concurrent.MVar"). Several common concurrency abstractions can be built from 'MVar's, and these are -provided by the "Control.Concurrent" library. +provided by the "Control.Concurrent" module. In GHC, threads may also communicate via exceptions. -} @@ -384,7 +384,7 @@ foreign import ccall safe "fdReady" multiple Haskell threads can be involved in external calls simultaneously. - The "System.IO" library manages multiplexing in its own way. On + The "System.IO" module manages multiplexing in its own way. On Windows systems it uses @safe@ foreign calls to ensure that threads doing I\/O operations don't block the whole runtime, whereas on Unix systems all the currently blocked I\/O requests @@ -401,7 +401,7 @@ foreign import ccall safe "fdReady" If you don't use the @-threaded@ option, then the runtime does not make use of multiple OS threads. Foreign calls will block all other running Haskell threads until the call returns. The - "System.IO" library still does multiplexing, so there can be multiple + "System.IO" module still does multiplexing, so there can be multiple threads doing I\/O, and this is handled internally by the runtime using @select at . -} ===================================== libraries/base/src/Control/Monad.hs ===================================== @@ -65,7 +65,7 @@ import GHC.Internal.Control.Monad {- $naming -The functions in this library use the following naming conventions: +The functions in this module use the following naming conventions: * A postfix \'@M@\' always stands for a function in the Kleisli category: The monad type constructor @m@ is added to function results ===================================== libraries/base/src/Control/Monad/ST.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : stable -- Portability : non-portable (requires universal quantification for runST) -- --- This library provides support for /strict/ state threads, as +-- This module provides support for /strict/ state threads, as -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton -- Jones /Lazy Functional State Threads/. -- ===================================== libraries/base/src/Control/Monad/ST/Safe.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : stable -- Portability : non-portable (requires universal quantification for runST) -- --- This library provides support for /strict/ state threads, as +-- This module provides support for /strict/ state threads, as -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton -- Jones /Lazy Functional State Threads/. -- ===================================== libraries/base/src/Control/Monad/ST/Unsafe.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : stable -- Portability : non-portable (requires universal quantification for runST) -- --- This library provides support for /strict/ state threads, as +-- This module provides support for /strict/ state threads, as -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton -- Jones /Lazy Functional State Threads/. -- ===================================== libraries/base/src/Data/Version.hs ===================================== @@ -9,7 +9,7 @@ -- Stability : stable -- Portability : non-portable (local universal quantification in ReadP) -- --- A general library for representation and manipulation of versions. +-- A general API for representation and manipulation of versions. -- -- Versioning schemes are many and varied, so the version -- representation provided by this library is intended to be a ===================================== libraries/base/src/GHC/IO/Encoding/UTF16.hs ===================================== @@ -32,4 +32,4 @@ module GHC.IO.Encoding.UTF16 utf16le_encode ) where -import GHC.Internal.IO.Encoding.UTF16 \ No newline at end of file +import GHC.Internal.IO.Encoding.UTF16 ===================================== libraries/base/src/GHC/TypeNats.hs ===================================== @@ -7,7 +7,7 @@ -- | -- This module is an internal GHC module. It declares the constants used -- in the implementation of type-level natural numbers. The programmer interface --- for working with type-level naturals should be defined in a separate library. +-- for working with type-level naturals should be defined in a separate module. -- -- @since 4.10.0.0 -- ===================================== libraries/base/src/System/Console/GetOpt.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : stable -- Portability : portable -- --- This library provides facilities for parsing the command-line options +-- This module provides facilities for parsing the command-line options -- in a standalone program. It is essentially a Haskell port of the GNU -- @getopt@ library. -- ===================================== libraries/base/src/System/IO.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : stable -- Portability : portable -- --- The standard IO library. +-- The standard IO API. -- module System.IO ===================================== libraries/base/src/System/Mem/Weak.hs ===================================== @@ -32,7 +32,7 @@ -- alive for ever. One way to solve this is to purge the table -- occasionally, by deleting entries whose keys have died. -- --- The weak pointers in this library +-- The weak pointers in this module -- support another approach, called /finalization/. -- When the key referred to by a weak pointer dies, the storage manager -- arranges to run a programmer-specified finalizer. In the case of memo @@ -43,7 +43,7 @@ -- key\/value pair might itself contain a pointer to the key. -- So the memo table keeps the value alive, which keeps the key alive, -- even though there may be no other references to the key so both should --- die. The weak pointers in this library provide a slight +-- die. The weak pointers in this module provide a slight -- generalisation of the basic weak-pointer idea, in which each -- weak pointer actually contains both a key and a value. -- ===================================== libraries/base/src/System/Posix/Internals.hs ===================================== @@ -17,7 +17,7 @@ -- bound, e.g., @base < 4.X@ rather than @base < 5@, because the interface can -- change rapidly without much warning. -- --- This library is built on *every* platform, including Win32. +-- This module is built on *every* platform, including Win32. -- -- Non-POSIX compliant in order to support the following features: -- * S_ISSOCK (no sockets in POSIX) ===================================== libraries/base/src/Text/ParserCombinators/ReadP.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : provisional -- Portability : non-portable (local universal quantification) -- --- This is a library of parser combinators, originally written by Koen Claessen. +-- This is a module of parser combinators, originally written by Koen Claessen. -- It parses all alternatives in parallel, so it never keeps hold of -- the beginning of the input string, a common source of space leaks with -- other parsers. The @('+++')@ choice combinator is genuinely commutative; @@ -60,4 +60,4 @@ module Text.ParserCombinators.ReadP -- $properties ) where -import GHC.Internal.Text.ParserCombinators.ReadP \ No newline at end of file +import GHC.Internal.Text.ParserCombinators.ReadP ===================================== libraries/base/src/Text/ParserCombinators/ReadPrec.hs ===================================== @@ -10,7 +10,7 @@ -- Stability : provisional -- Portability : non-portable (uses Text.ParserCombinators.ReadP) -- --- This library defines parser combinators for precedence parsing. +-- This module defines parser combinators for precedence parsing. module Text.ParserCombinators.ReadPrec (ReadPrec, @@ -37,4 +37,4 @@ module Text.ParserCombinators.ReadPrec readS_to_Prec ) where -import GHC.Internal.Text.ParserCombinators.ReadPrec \ No newline at end of file +import GHC.Internal.Text.ParserCombinators.ReadPrec ===================================== libraries/base/src/Text/Read.hs ===================================== @@ -12,7 +12,7 @@ -- -- Converting strings to values. -- --- The "Text.Read" library is the canonical library to import for +-- The "Text.Read" module is the canonical place to import for -- 'Read'-class facilities. For GHC only, it offers an extended and much -- improved 'Read' class, which constitutes a proposed alternative to the -- Haskell 2010 'Read'. In particular, writing parsers is easier, and View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4b131133e4cee35d2140eedfcf3b4e573a43a8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4b131133e4cee35d2140eedfcf3b4e573a43a8a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 18:56:36 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Wed, 06 Mar 2024 13:56:36 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] 16 commits: Trim trailing whitespace Message-ID: <65e8bc64b947a_38980ede2c6588862d@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 625493a4 by Sven Tennie at 2024-03-06T07:02:17+01:00 Trim trailing whitespace - - - - - 30dfe442 by Sven Tennie at 2024-03-06T08:09:57+01:00 No sign extension attribute in RISCV instructions RISCV takes the meaning of reduced instruction set much more serious: One cannot sign extend an operant in the same instruction. Delete this unused code - We're handling sign extension differently. - - - - - 811be0cb by Sven Tennie at 2024-03-06T08:45:23+01:00 There are no shifts in RISCV instructions Remove this unused code. RISCV does everything in small steps... - - - - - c50c232f by Sven Tennie at 2024-03-06T08:56:52+01:00 pprReg: Remove unused parameter - - - - - ae94eadd by Sven Tennie at 2024-03-06T10:21:25+01:00 Cleanup Cond - - - - - 50dc60b3 by Sven Tennie at 2024-03-06T12:29:44+01:00 More cleanup Mostly haddock, formatting, minor refactorings - - - - - 4317a296 by Sven Tennie at 2024-03-06T14:47:23+01:00 Implement takeRegRegMoveInstr - - - - - 6f258fb4 by Sven Tennie at 2024-03-06T15:17:01+01:00 Cleanup mkStackAllocInstr & mkStackDeallocInstr - - - - - f641e4fa by Sven Tennie at 2024-03-06T16:59:18+01:00 Move Reg definitions to Regs module - - - - - 4a3cd3e2 by Sven Tennie at 2024-03-06T17:00:12+01:00 Typo - - - - - 73195089 by Sven Tennie at 2024-03-06T17:00:37+01:00 Circumvent "incomplete pattern match" warning - - - - - d604f115 by Sven Tennie at 2024-03-06T17:01:16+01:00 Delete commented out / dead code - - - - - 970df83d by Sven Tennie at 2024-03-06T17:07:54+01:00 Add TODOs - - - - - f6d1a418 by Sven Tennie at 2024-03-06T18:31:52+01:00 Reduce duplication in stack alloc / free - - - - - 8d077038 by Sven Tennie at 2024-03-06T18:52:04+01:00 Delete unused instructions As they are unused, we don't even know if using them would work at all. - - - - - f6f310ee by Sven Tennie at 2024-03-06T18:54:41+01:00 Lint - - - - - 5 changed files: - compiler/GHC/CmmToAsm/RV64/CodeGen.hs - compiler/GHC/CmmToAsm/RV64/Cond.hs - compiler/GHC/CmmToAsm/RV64/Instr.hs - compiler/GHC/CmmToAsm/RV64/Ppr.hs - compiler/GHC/CmmToAsm/RV64/Regs.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/CodeGen.hs ===================================== @@ -911,10 +911,10 @@ getRegister' config plat expr = -- SLT is the same. ULE, and ULT will not return true for NaN. -- This is a bit counter-intuitive. Don't let yourself be fooled by -- the S/U prefix for floats, it's only meaningful for integers. - MO_F_Ge w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y OGE)) - MO_F_Le w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y OLE)) -- x <= y <=> y > x - MO_F_Gt w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y OGT)) - MO_F_Lt w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y OLT)) -- x < y <=> y >= x + MO_F_Ge w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y FGE)) + MO_F_Le w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y FLE)) -- x <= y <=> y > x + MO_F_Gt w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y FGT)) + MO_F_Lt w -> floatCond w (\d x y -> unitOL $ annExpr expr (CSET d x y FLT)) -- x < y <=> y >= x -- Bitwise operations MO_And w -> bitOp w (\d x y -> unitOL $ annExpr expr (AND d x y)) @@ -1278,10 +1278,10 @@ genCondJump bid expr = do MO_F_Eq w -> fbcond w EQ MO_F_Ne w -> fbcond w NE - MO_F_Gt w -> fbcond w OGT - MO_F_Ge w -> fbcond w OGE - MO_F_Lt w -> fbcond w OLT - MO_F_Le w -> fbcond w OLE + MO_F_Gt w -> fbcond w FGT + MO_F_Ge w -> fbcond w FGE + MO_F_Lt w -> fbcond w FLT + MO_F_Le w -> fbcond w FLE MO_Eq w -> sbcond w EQ MO_Ne w -> sbcond w NE ===================================== compiler/GHC/CmmToAsm/RV64/Cond.hs ===================================== @@ -1,93 +1,58 @@ -module GHC.CmmToAsm.RV64.Cond where +module GHC.CmmToAsm.RV64.Cond where import GHC.Prelude hiding (EQ) --- FIXME: These conditions originate from the Aarch64 backend. I'm not even sure --- we use all of them there. For RISCV we need to synthesize some of them, as --- RISCV has a much more reduced (ha!) set of condtionals. - --- TODO: This appears to go a bit overboard? Maybe we should stick with what LLVM --- settled on for fcmp? --- false: always yields false, regardless of operands. --- oeq: yields true if both operands are not a QNAN and op1 is equal to op2. --- ogt: yields true if both operands are not a QNAN and op1 is greater than op2. --- oge: yields true if both operands are not a QNAN and op1 is greater than or equal to op2. --- olt: yields true if both operands are not a QNAN and op1 is less than op2. --- ole: yields true if both operands are not a QNAN and op1 is less than or equal to op2. --- one: yields true if both operands are not a QNAN and op1 is not equal to op2. --- ord: yields true if both operands are not a QNAN. --- ueq: yields true if either operand is a QNAN or op1 is equal to op2. --- ugt: yields true if either operand is a QNAN or op1 is greater than op2. --- uge: yields true if either operand is a QNAN or op1 is greater than or equal to op2. --- ult: yields true if either operand is a QNAN or op1 is less than op2. --- ule: yields true if either operand is a QNAN or op1 is less than or equal to op2. --- une: yields true if either operand is a QNAN or op1 is not equal to op2. --- uno: yields true if either operand is a QNAN. --- true: always yields true, regardless of operands. +-- | Condition codes. -- --- LLVMs icmp knows about: --- eq: yields true if the operands are equal, false otherwise. No sign interpretation is necessary or performed. --- ne: yields true if the operands are unequal, false otherwise. No sign interpretation is necessary or performed. --- ugt: interprets the operands as unsigned values and yields true if op1 is greater than op2. --- uge: interprets the operands as unsigned values and yields true if op1 is greater than or equal to op2. --- ult: interprets the operands as unsigned values and yields true if op1 is less than op2. --- ule: interprets the operands as unsigned values and yields true if op1 is less than or equal to op2. --- sgt: interprets the operands as signed values and yields true if op1 is greater than op2. --- sge: interprets the operands as signed values and yields true if op1 is greater than or equal to op2. --- slt: interprets the operands as signed values and yields true if op1 is less than op2. --- sle: interprets the operands as signed values and yields true if op1 is less than or equal to op2. - +-- Used in conditional branches and bit setters. According to the available +-- instruction set, some conditions are encoded as their negated opposites. I.e. +-- these are logical things that don't necessarily map 1:1 to hardware/ISA. data Cond - = ALWAYS -- b.al - | EQ -- b.eq - | NE -- b.ne - -- signed - | SLT -- b.lt - | SLE -- b.le - | SGE -- b.ge - | SGT -- b.gt - -- unsigned - | ULT -- b.lo - | ULE -- b.ls - | UGE -- b.hs - | UGT -- b.hi - -- ordered - | OLT -- b.mi - | OLE -- b.ls - | OGE -- b.ge - | OGT -- b.gt - -- unordered - | UOLT -- b.lt - | UOLE -- b.le - | UOGE -- b.pl - | UOGT -- b.hi - -- others - | NEVER -- b.nv - | VS -- oVerflow set - | VC -- oVerflow clear - deriving (Eq, Show) + = -- | int and float + EQ + | -- | int and float + NE + | -- | signed less than + SLT + | -- | signed less than or equal + SLE + | -- | signed greater than or equal + SGE + | -- | signed greater than + SGT + | -- | unsigned less than + ULT + | -- | unsigned less than or equal + ULE + | -- | unsigned greater than or equal + UGE + | -- | unsigned greater than + UGT + | -- | floating point instruction @flt@ + FLT + | -- | floating point instruction @fle@ + FLE + | -- | floating point instruction @fge@ + FGE + | -- | floating point instruction @fgt@ + FGT + deriving (Eq, Show) -- | Negate a condition. +-- +-- This is useful to e.g. construct far branches from usual branches. negateCond :: Cond -> Cond -negateCond ALWAYS = NEVER -negateCond NEVER = ALWAYS -negateCond EQ = NE -negateCond NE = EQ -negateCond SLT = SGE -negateCond SLE = SGT -negateCond SGE = SLT -negateCond SGT = SLE -negateCond ULT = UGE -negateCond ULE = UGT -negateCond UGE = ULT -negateCond UGT = ULE -negateCond OLT = OGE -negateCond OLE = OGT -negateCond OGE = OLT -negateCond OGT = OLE -negateCond UOLT = UOGE -negateCond UOLE = UOGT -negateCond UOGE = UOLT -negateCond UOGT = UOLE -negateCond VS = VC -negateCond VC = VS +negateCond EQ = NE +negateCond NE = EQ +negateCond SLT = SGE +negateCond SLE = SGT +negateCond SGE = SLT +negateCond SGT = SLE +negateCond ULT = UGE +negateCond ULE = UGT +negateCond UGE = ULT +negateCond UGT = ULE +negateCond FLT = FGE +negateCond FLE = FGT +negateCond FGE = FLT +negateCond FGT = FLE ===================================== compiler/GHC/CmmToAsm/RV64/Instr.hs ===================================== @@ -28,7 +28,7 @@ import GHC.Types.Unique.Supply import GHC.Utils.Panic -import Data.Maybe (fromMaybe) +import Data.Maybe import GHC.Stack import qualified Data.List.NonEmpty as NE @@ -92,7 +92,6 @@ regUsageOfInstr platform instr = case instr of MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) NEG dst src -> usage (regOp src, regOp dst) SMULH dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - SMULL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) DIV dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) REM dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) REMU dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,12 +112,9 @@ regUsageOfInstr platform instr = case instr of LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) MOV dst src -> usage (regOp src, regOp dst) - MOVK dst src -> usage (regOp src, regOp dst) -- ORI's third operand is always an immediate ORI dst src1 _ -> usage (regOp src1, regOp dst) XORI dst src1 _ -> usage (regOp src1, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -130,8 +126,6 @@ regUsageOfInstr platform instr = case instr of -- 5. Atomic Instructions ---------------------------------------------------- -- 6. Conditional Instructions ----------------------------------------------- CSET dst l r _ -> usage (regOp l ++ regOp r, regOp dst) - CBZ src _ -> usage (regOp src, []) - CBNZ src _ -> usage (regOp src, []) -- 7. Load and Store Instructions -------------------------------------------- STR _ src dst -> usage (regOp src ++ regOp dst, []) -- STLR _ src dst L -> usage (regOp src ++ regOp dst, []) @@ -165,11 +159,8 @@ regUsageOfInstr platform instr = case instr of regAddr (AddrReg r1) = [r1] regOp :: Operand -> [Reg] regOp (OpReg _ r1) = [r1] - regOp (OpRegExt _ r1 _ _) = [r1] - regOp (OpRegShift _ r1 _ _) = [r1] regOp (OpAddr a) = regAddr a regOp (OpImm _) = [] - regOp (OpImmShift _ _ _) = [] regTarget :: Target -> [Reg] regTarget (TBlock _) = [] regTarget (TLabel _) = [] @@ -229,7 +220,6 @@ patchRegsOfInstr instr env = case instr of MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) NEG o1 o2 -> NEG (patchOp o1) (patchOp o2) SMULH o1 o2 o3 -> SMULH (patchOp o1) (patchOp o2) (patchOp o3) - SMULL o1 o2 o3 -> SMULL (patchOp o1) (patchOp o2) (patchOp o3) DIV o1 o2 o3 -> DIV (patchOp o1) (patchOp o2) (patchOp o3) REM o1 o2 o3 -> REM (patchOp o1) (patchOp o2) (patchOp o3) REMU o1 o2 o3 -> REMU (patchOp o1) (patchOp o2) (patchOp o3) @@ -252,12 +242,9 @@ patchRegsOfInstr instr env = case instr of LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) MOV o1 o2 -> MOV (patchOp o1) (patchOp o2) - MOVK o1 o2 -> MOVK (patchOp o1) (patchOp o2) -- o3 cannot be a register for ORI (always an immediate) ORI o1 o2 o3 -> ORI (patchOp o1) (patchOp o2) (patchOp o3) XORI o1 o2 o3 -> XORI (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -270,8 +257,6 @@ patchRegsOfInstr instr env = case instr of -- 5. Atomic Instructions -------------------------------------------------- -- 6. Conditional Instructions --------------------------------------------- CSET o l r c -> CSET (patchOp o) (patchOp l) (patchOp r) c - CBZ o l -> CBZ (patchOp o) l - CBNZ o l -> CBNZ (patchOp o) l -- 7. Load and Store Instructions ------------------------------------------ STR f o1 o2 -> STR f (patchOp o1) (patchOp o2) -- STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) @@ -293,8 +278,6 @@ patchRegsOfInstr instr env = case instr of where patchOp :: Operand -> Operand patchOp (OpReg w r) = OpReg w (env r) - patchOp (OpRegExt w r x s) = OpRegExt w (env r) x s - patchOp (OpRegShift w r m s) = OpRegShift w (env r) m s patchOp (OpAddr a) = OpAddr (patchAddr a) patchOp op = op patchTarget :: Target -> Target @@ -304,53 +287,48 @@ patchRegsOfInstr instr env = case instr of patchAddr (AddrRegImm r1 i) = AddrRegImm (env r1) i patchAddr (AddrReg r) = AddrReg (env r) -------------------------------------------------------------------------------- + -- | Checks whether this instruction is a jump/branch instruction. +-- -- One that can change the flow of control in a way that the -- register allocator needs to worry about. isJumpishInstr :: Instr -> Bool isJumpishInstr instr = case instr of - ANN _ i -> isJumpishInstr i - CBZ{} -> True - CBNZ{} -> True - J{} -> True - B{} -> True - B_FAR{} -> True - BL{} -> True - BCOND{} -> True - BCOND_FAR{} -> True - _ -> False - --- | Checks whether this instruction is a jump/branch instruction. --- One that can change the flow of control in a way that the --- register allocator needs to worry about. + ANN _ i -> isJumpishInstr i + J {} -> True + B {} -> True + B_FAR {} -> True + BL {} -> True + BCOND {} -> True + BCOND_FAR {} -> True + _ -> False + +-- | Get the `BlockId`s of the jump destinations (if any) jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] jumpDestsOfInstr (B_FAR t) = [t] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ _ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND_FAR _ _ _ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ _ _ t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND_FAR _ _ _ _ t) = [id | TBlock id <- [t]] jumpDestsOfInstr _ = [] --- | Change the destination of this jump instruction. +-- | Change the destination of this (potential) jump instruction. +-- -- Used in the linear allocator when adding fixup blocks for join -- points. patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr -patchJumpInstr instr patchF - = case instr of - ANN d i -> ANN d (patchJumpInstr i patchF) - CBZ r (TBlock bid) -> CBZ r (TBlock (patchF bid)) - CBNZ r (TBlock bid) -> CBNZ r (TBlock (patchF bid)) - J (TBlock bid) -> J (TBlock (patchF bid)) - B (TBlock bid) -> B (TBlock (patchF bid)) - B_FAR bid -> B_FAR (patchF bid) - BL (TBlock bid) ps rs -> BL (TBlock (patchF bid)) ps rs - BCOND c o1 o2 (TBlock bid) -> BCOND c o1 o2 (TBlock (patchF bid)) - BCOND_FAR c o1 o2 b (TBlock bid) -> BCOND_FAR c o1 o2 b (TBlock (patchF bid)) - _ -> panic $ "patchJumpInstr: " ++ instrCon instr +patchJumpInstr instr patchF = + case instr of + ANN d i -> ANN d (patchJumpInstr i patchF) + J (TBlock bid) -> J (TBlock (patchF bid)) + B (TBlock bid) -> B (TBlock (patchF bid)) + B_FAR bid -> B_FAR (patchF bid) + BL (TBlock bid) ps rs -> BL (TBlock (patchF bid)) ps rs + BCOND c o1 o2 (TBlock bid) -> BCOND c o1 o2 (TBlock (patchF bid)) + BCOND_FAR c o1 o2 b (TBlock bid) -> BCOND_FAR c o1 o2 b (TBlock (patchF bid)) + _ -> panic $ "patchJumpInstr: " ++ instrCon instr -- ----------------------------------------------------------------------------- -- Note [Spills and Reloads] @@ -372,11 +350,11 @@ patchJumpInstr instr patchF mkSpillInstr :: HasCallStack => NCGConfig -> - Reg -> -- register to spill - Int -> -- current stack delta - Int -> -- spill slot to use + Reg -> -- ^ register to spill + Int -> -- ^ current stack delta + Int -> -- ^ spill slot to use [Instr] -mkSpillInstr config reg delta slot = +mkSpillInstr _config reg delta slot = case off - delta of imm | fitsIn12bitImm imm -> [mkStrSpImm imm] imm -> @@ -397,9 +375,9 @@ mkSpillInstr config reg delta slot = mkLoadInstr :: NCGConfig - -> Reg -- register to load - -> Int -- current stack delta - -> Int -- spill slot to use + -> Reg -- ^ register to load + -> Int -- ^ current stack delta + -> Int -- ^ spill slot to use -> [Instr] mkLoadInstr _config reg delta slot = @@ -421,58 +399,77 @@ mkLoadInstr _config reg delta slot = off = spillSlotToOffset slot - -------------------------------------------------------------------------------- -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int takeDeltaInstr (ANN _ i) = takeDeltaInstr i takeDeltaInstr (DELTA i) = Just i takeDeltaInstr _ = Nothing --- Not real instructions. Just meta data +-- | Not real instructions. Just meta data isMetaInstr :: Instr -> Bool -isMetaInstr instr - = case instr of - ANN _ i -> isMetaInstr i - COMMENT{} -> True - MULTILINE_COMMENT{} -> True - LOCATION{} -> True - LDATA{} -> True - NEWBLOCK{} -> True - DELTA{} -> True +isMetaInstr instr = + case instr of + ANN _ i -> isMetaInstr i + COMMENT {} -> True + MULTILINE_COMMENT {} -> True + LOCATION {} -> True + LDATA {} -> True + NEWBLOCK {} -> True + DELTA {} -> True PUSH_STACK_FRAME -> True POP_STACK_FRAME -> True - _ -> False + _ -> False -- | Copy the value in a register to another one. +-- -- Must work for all register classes. mkRegRegMoveInstr :: Reg -> Reg -> Instr -mkRegRegMoveInstr src dst = ANN (text "Reg->Reg Move: " <> ppr src <> text " -> " <> ppr dst) $ MOV (OpReg W64 dst) (OpReg W64 src) +mkRegRegMoveInstr src dst = ANN desc instr + where + desc = text "Reg->Reg Move: " <> ppr src <> text " -> " <> ppr dst + instr = MOV (operandFromReg dst) (operandFromReg src) --- | Take the source and destination from this reg -> reg move instruction --- or Nothing if it's not one +-- | Take the source and destination from this (potential) reg -> reg move instruction +-- +-- We have to be a bit careful here: A `MOV` can also mean an implicit +-- conversion. This case is filtered out. takeRegRegMoveInstr :: Instr -> Maybe (Reg,Reg) ---takeRegRegMoveInstr (MOV (OpReg fmt dst) (OpReg fmt' src)) | fmt == fmt' = Just (src, dst) +takeRegRegMoveInstr (MOV (OpReg fmt dst) (OpReg fmt' src)) | fmt == fmt' = pure (src, dst) takeRegRegMoveInstr _ = Nothing -- | Make an unconditional jump instruction. mkJumpInstr :: BlockId -> [Instr] -mkJumpInstr id = [B (TBlock id)] +mkJumpInstr = pure . B . TBlock +-- | Decrement @sp@ to allocate stack space. +-- +-- The stack grows downwards, so we decrement the stack pointer by @n@ (bytes). +-- This is dual to `mkStackDeallocInstr`. @sp@ is the RISCV stack pointer, not +-- to be confused with the STG stack pointer. mkStackAllocInstr :: Platform -> Int -> [Instr] -mkStackAllocInstr platform n - | n == 0 = [] - | n > 0 && fitsIn12bitImm n = [ ANN (text "Alloc More Stack") $ SUB sp sp (OpImm (ImmInt n)) ] - -- TODO: This case may be optimized with the IP register for large n-s - | n > 0 = ANN (text "Alloc More Stack") (SUB sp sp (OpImm (ImmInt intMax12bit))) : mkStackAllocInstr platform (n - intMax12bit) -mkStackAllocInstr _platform n = pprPanic "mkStackAllocInstr" (int n) +mkStackAllocInstr _platform = moveSp . negate +-- | Increment SP to deallocate stack space. +-- +-- The stack grows downwards, so we increment the stack pointer by @n@ (bytes). +-- This is dual to `mkStackAllocInstr`. @sp@ is the RISCV stack pointer, not to +-- be confused with the STG stack pointer. mkStackDeallocInstr :: Platform -> Int -> [Instr] -mkStackDeallocInstr platform n - | n == 0 = [] - | n > 0 && fitsIn12bitImm n = [ ANN (text "Dealloc More Stack") $ ADD sp sp (OpImm (ImmInt n)) ] - -- TODO: This case may be optimized with the IP register for large n-s - | n > 0 = ANN (text "Dealloc More Stack") (ADD sp sp (OpImm (ImmInt intMax12bit))) : mkStackDeallocInstr platform (n - intMax12bit) -mkStackDeallocInstr _platform n = pprPanic "mkStackDeallocInstr" (int n) +mkStackDeallocInstr _platform = moveSp + +moveSp :: Int -> [Instr] +moveSp n + | n == 0 = [] + | n /= 0 && fitsIn12bitImm n = pure . ANN desc $ ADD sp sp (OpImm (ImmInt n)) + | otherwise = + -- This ends up in three effective instructions. We could get away with + -- two for intMax12bit < n < 3 * intMax12bit by recursing once. However, + -- this way is likely less surprising. + [ ANN desc (MOV ip (OpImm (ImmInt n))), + ADD sp sp ip + ] + where + desc = text "Move SP:" <+> int n -- -- See Note [extra spill slots] in X86/Instr.hs @@ -496,7 +493,7 @@ allocMoreStack platform slots proc@(CmmProc info lbl live (ListGraph code)) = do alloc = mkStackAllocInstr platform delta dealloc = mkStackDeallocInstr platform delta - retargetList = (zip entries (map mkBlockId uniqs)) + retargetList = zip entries (map mkBlockId uniqs) new_blockmap :: LabelMap BlockId new_blockmap = mapFromList retargetList @@ -520,8 +517,8 @@ allocMoreStack platform slots proc@(CmmProc info lbl live (ListGraph code)) = do where retarget b = fromMaybe b (mapLookup b new_blockmap) new_code = concatMap insert_stack_insn code - -- in return (CmmProc info lbl live (ListGraph new_code), retargetList) + -- ----------------------------------------------------------------------------- -- Machine's assembly language @@ -623,8 +620,6 @@ data Instr -- TODO: Rename: MULH | SMULH Operand Operand Operand - | SMULL Operand Operand Operand - | DIVU Operand Operand Operand -- rd = rn ÷ rm -- 2. Bit Manipulation Instructions ---------------------------------------- @@ -637,20 +632,16 @@ data Instr -- | AND Operand Operand Operand -- rd = rn & op2 -- | ANDS Operand Operand Operand -- rd = rn & op2 -- | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits + -- TODO: unused | BIC Operand Operand Operand -- rd = rn & ~op2 + -- TODO: unused | BICS Operand Operand Operand -- rd = rn & ~op2 | XOR Operand Operand Operand -- rd = rn ⊕ op2 -- | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits -- | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits | MOV Operand Operand -- rd = rn or rd = #i - | MOVK Operand Operand - -- | MOVN Operand Operand - -- | MOVZ Operand Operand - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORI Operand Operand Operand -- rd = rn | op2 | XORI Operand Operand Operand -- rd = rn `xor` imm - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. -- | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr @@ -664,10 +655,6 @@ data Instr -- This is a synthetic operation. | CSET Operand Operand Operand Cond -- if(o2 cond o3) op <- 1 else op <- 0 - -- TODO: Unused - | CBZ Operand Target -- if op == 0, then branch. - -- TODO: Unused - | CBNZ Operand Target -- if op /= 0, then branch. -- Branching. -- TODO: Unused | J Target -- like B, but only generated from genJump. Used to distinguish genJumps from others. @@ -707,22 +694,18 @@ instrCon i = POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" OR{} -> "OR" - -- CMN{} -> "CMN" - -- CMP{} -> "CMP" MUL{} -> "MUL" NEG{} -> "NEG" DIV{} -> "DIV" REM{} -> "REM" REMU{} -> "REMU" SMULH{} -> "SMULH" - SMULL{} -> "SMULL" SUB{} -> "SUB" DIVU{} -> "DIVU" SBFM{} -> "SBFM" UBFM{} -> "UBFM" UBFX{} -> "UBFX" AND{} -> "AND" - -- ANDS{} -> "ANDS" ASR{} -> "ASR" BIC{} -> "BIC" BICS{} -> "BICS" @@ -730,22 +713,12 @@ instrCon i = LSL{} -> "LSL" LSR{} -> "LSR" MOV{} -> "MOV" - MOVK{} -> "MOVK" - ORN{} -> "ORN" ORI{} -> "ORI" XORI{} -> "ORI" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" - -- STLR{} -> "STLR" LDR{} -> "LDR" LDRU{} -> "LDRU" - -- LDAR{} -> "LDAR" - -- STP{} -> "STP" - -- LDP{} -> "LDP" CSET{} -> "CSET" - CBZ{} -> "CBZ" - CBNZ{} -> "CBNZ" J{} -> "J" B{} -> "B" B_FAR{} -> "B_FAR" @@ -764,60 +737,12 @@ data Target | TLabel CLabel | TReg Reg - --- Extension --- {Unsigned|Signed}XT{Byte|Half|Word|Doube} -data ExtMode - = EUXTB | EUXTH | EUXTW | EUXTX - | ESXTB | ESXTH | ESXTW | ESXTX - deriving (Eq, Show) - -data ShiftMode - = SLSL | SLSR | SASR | SROR - deriving (Eq, Show) - - --- We can also add ExtShift to Extension. --- However at most 3bits. -type ExtShift = Int --- at most 6bits -type RegShift = Int - data Operand = OpReg Width Reg -- register - | OpRegExt Width Reg ExtMode ExtShift -- rm, [, ] - | OpRegShift Width Reg ShiftMode RegShift -- rm, , <0-64> | OpImm Imm -- immediate value - -- TODO: Does OpImmShift exist in RV64? - | OpImmShift Imm ShiftMode RegShift | OpAddr AddrMode -- memory reference deriving (Eq, Show) --- Note [The made-up RISCV64 IP register] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- --- RISCV64 has no inter-procedural register in its ABI. However, we need one to --- make register spills/loads to/from high number slots. I.e. slot numbers that --- do not fit in a 12bit integer which is used as immediate in the arithmetic --- operations. Thus, we're marking one additional register (x31) as permanently --- non-free and call it IP. --- --- IP can be used as temporary register in all operations. Just be aware that it --- may be clobbered as soon as you loose direct control over it (i.e. using IP --- by-passes the register allocation/spilling mechanisms.) It should be fine to --- use it as temporary register in a MachOp translation as long as you don't --- rely on its value beyond this limited scope. --- --- X31 is a caller-saved register. I.e. there are no guarantees about what the --- callee does with it. That's exactly what we want here. - -zeroReg, raReg, spMachReg, ipReg :: Reg -zeroReg = regSingle 0 -raReg = regSingle 1 --- | Not to be confused with the `CmmReg` `spReg` -spMachReg = regSingle 2 -ipReg = regSingle 31 - operandFromReg :: Reg -> Operand operandFromReg = OpReg W64 @@ -907,13 +832,6 @@ d29 = operandFromRegNo 61 d30 = operandFromRegNo 62 d31 = operandFromRegNo d31RegNo -opRegSExt :: Width -> Reg -> Operand -opRegSExt W64 r = OpRegExt W64 r ESXTX 0 -opRegSExt W32 r = OpRegExt W32 r ESXTW 0 -opRegSExt W16 r = OpRegExt W16 r ESXTH 0 -opRegSExt W8 r = OpRegExt W8 r ESXTB 0 -opRegSExt w _r = pprPanic "opRegSExt" (ppr w) - fitsIn12bitImm :: (Num a, Ord a) => a -> Bool fitsIn12bitImm off = off >= intMin12bit && off <= intMax12bit @@ -937,7 +855,7 @@ isEncodeableInWidth = isNbitEncodeable . widthInBits -- Conditional branch instructions can target labels in a range of +/- 4 KiB. -- The assembler can transform this into a J instruction targeting +/- 1MiB. -- There are rare cases where this is not enough (e.g. the Happy-generated --- @Parser.hs at .) We need to manually transfer these into register based jumps +-- @Parser.hs at .) We need to manually transform these into register based jumps -- using @ip@ (register reserved for calculations.) The trick is to invert the -- condition, do a far jump in the fall-through case or a short jump when the -- (inverted) condition is true. @@ -964,7 +882,7 @@ makeFarBranches info_env blocks | otherwise = annotate addr targetAddr orig where - Just targetAddr = lookupUFM blockAddressMap tgtBid + targetAddr = fromJust $ lookupUFM blockAddressMap tgtBid makeFar _bid addr orig@(B (TBlock tgtBid)) | abs (addr - targetAddr) >= nearLimit = annotate addr targetAddr $ @@ -972,16 +890,16 @@ makeFarBranches info_env blocks | otherwise = annotate addr targetAddr orig where - Just targetAddr = lookupUFM blockAddressMap tgtBid + targetAddr = fromJust $ lookupUFM blockAddressMap tgtBid makeFar bid addr (ANN desc other) = ANN desc $ makeFar bid addr other makeFar _bid _ other = other -- 262144 (2^20 / 4) instructions are allowed; let's keep some distance, as -- we have pseudo-insns that are pretty-printed as multiple instructions, -- and it's just not worth the effort to calculate things exactly as linker - -- relaxations are applied later (optimizing away our flaws.) The - -- conservative guess here is that every instruction does not emit more than - -- two in the mean. + -- relaxations are applied later (optimizing away our flaws.) The educated + -- guess here is that every instruction does not emit more than two in the + -- mean. nearLimit = 131072 - mapSize info_env * maxRetInfoTableSizeW blockAddressMap = listToUFM $ zip (map blockId blocks) blockAddressList ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -1,6 +1,3 @@ -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-# LANGUAGE CPP #-} - module GHC.CmmToAsm.RV64.Ppr (pprNatCmmDecl, pprInstr) where import GHC.Prelude hiding (EQ) @@ -304,116 +301,93 @@ negOp (OpImm (ImmInt i)) = OpImm (ImmInt (negate i)) negOp (OpImm (ImmInteger i)) = OpImm (ImmInteger (negate i)) negOp op = pprPanic "RV64.negOp" (text $ show op) --- TODO: Is this used in RISCV?! -pprExt :: IsLine doc => ExtMode -> doc -pprExt EUXTB = text "uxtb" -pprExt EUXTH = text "uxth" -pprExt EUXTW = text "uxtw" -pprExt EUXTX = text "uxtx" -pprExt ESXTB = text "sxtb" -pprExt ESXTH = text "sxth" -pprExt ESXTW = text "sxtw" -pprExt ESXTX = text "sxtx" - --- TODO: Is this used in RISCV?! -pprShift :: IsLine doc => ShiftMode -> doc -pprShift SLSL = text "lsl" -pprShift SLSR = text "lsr" -pprShift SASR = text "asr" -pprShift SROR = text "ror" - pprOp :: IsLine doc => Platform -> Operand -> doc pprOp plat op = case op of OpReg w r -> pprReg w r - OpRegExt w r x 0 -> pprReg w r <> comma <+> pprExt x - OpRegExt w r x i -> pprReg w r <> comma <+> pprExt x <> comma <+> char '#' <> int i - OpRegShift w r s i -> pprReg w r <> comma <+> pprShift s <+> char '#' <> int i OpImm im -> pprIm plat im - OpImmShift im s i -> pprIm plat im <> comma <+> pprShift s <+> char '#' <> int i OpAddr (AddrRegImm r1 im) -> pprImm plat im <> char '(' <> pprReg W64 r1 <> char ')' OpAddr (AddrReg r1) -> text "0(" <+> pprReg W64 r1 <+> char ')' pprReg :: forall doc. IsLine doc => Width -> Reg -> doc pprReg w r = case r of - RegReal (RealRegSingle i) -> ppr_reg_no w i + RegReal (RealRegSingle i) -> ppr_reg_no i -- virtual regs should not show up, but this is helpful for debugging. RegVirtual (VirtualRegI u) -> text "%vI_" <> pprUniqueAlways u RegVirtual (VirtualRegF u) -> text "%vF_" <> pprUniqueAlways u RegVirtual (VirtualRegD u) -> text "%vD_" <> pprUniqueAlways u - _ -> pprPanic "RiscV64.pprReg" (text $ show r) + _ -> pprPanic "RiscV64.pprReg" (text (show r) <+> ppr w) where - -- TODO: Width is only used in error messages, so we could just remove it. - ppr_reg_no :: Width -> Int -> doc + ppr_reg_no :: Int -> doc -- General Purpose Registers - ppr_reg_no _ 0 = text "zero" - ppr_reg_no _ 1 = text "ra" - ppr_reg_no _ 2 = text "sp" - ppr_reg_no _ 3 = text "gp" - ppr_reg_no _ 4 = text "tp" - ppr_reg_no _ 5 = text "t0" - ppr_reg_no _ 6 = text "t1" - ppr_reg_no _ 7 = text "t2" - ppr_reg_no _ 8 = text "s0" - ppr_reg_no _ 9 = text "s1" - ppr_reg_no _ 10 = text "a0" - ppr_reg_no _ 11 = text "a1" - ppr_reg_no _ 12 = text "a2" - ppr_reg_no _ 13 = text "a3" - ppr_reg_no _ 14 = text "a4" - ppr_reg_no _ 15 = text "a5" - ppr_reg_no _ 16 = text "a6" - ppr_reg_no _ 17 = text "a7" - ppr_reg_no _ 18 = text "s2" - ppr_reg_no _ 19 = text "s3" - ppr_reg_no _ 20 = text "s4" - ppr_reg_no _ 21 = text "s5" - ppr_reg_no _ 22 = text "s6" - ppr_reg_no _ 23 = text "s7" - ppr_reg_no _ 24 = text "s8" - ppr_reg_no _ 25 = text "s9" - ppr_reg_no _ 26 = text "s10" - ppr_reg_no _ 27 = text "s11" - ppr_reg_no _ 28 = text "t3" - ppr_reg_no _ 29 = text "t4" - ppr_reg_no _ 30 = text "t5" - ppr_reg_no _ 31 = text "t6" + ppr_reg_no 0 = text "zero" + ppr_reg_no 1 = text "ra" + ppr_reg_no 2 = text "sp" + ppr_reg_no 3 = text "gp" + ppr_reg_no 4 = text "tp" + ppr_reg_no 5 = text "t0" + ppr_reg_no 6 = text "t1" + ppr_reg_no 7 = text "t2" + ppr_reg_no 8 = text "s0" + ppr_reg_no 9 = text "s1" + ppr_reg_no 10 = text "a0" + ppr_reg_no 11 = text "a1" + ppr_reg_no 12 = text "a2" + ppr_reg_no 13 = text "a3" + ppr_reg_no 14 = text "a4" + ppr_reg_no 15 = text "a5" + ppr_reg_no 16 = text "a6" + ppr_reg_no 17 = text "a7" + ppr_reg_no 18 = text "s2" + ppr_reg_no 19 = text "s3" + ppr_reg_no 20 = text "s4" + ppr_reg_no 21 = text "s5" + ppr_reg_no 22 = text "s6" + ppr_reg_no 23 = text "s7" + ppr_reg_no 24 = text "s8" + ppr_reg_no 25 = text "s9" + ppr_reg_no 26 = text "s10" + ppr_reg_no 27 = text "s11" + ppr_reg_no 28 = text "t3" + ppr_reg_no 29 = text "t4" + ppr_reg_no 30 = text "t5" + ppr_reg_no 31 = text "t6" -- Floating Point Registers - ppr_reg_no _ 32 = text "ft0" - ppr_reg_no _ 33 = text "ft1" - ppr_reg_no _ 34 = text "ft2" - ppr_reg_no _ 35 = text "ft3" - ppr_reg_no _ 36 = text "ft4" - ppr_reg_no _ 37 = text "ft5" - ppr_reg_no _ 38 = text "ft6" - ppr_reg_no _ 39 = text "ft7" - ppr_reg_no _ 40 = text "fs0" - ppr_reg_no _ 41 = text "fs1" - ppr_reg_no _ 42 = text "fa0" - ppr_reg_no _ 43 = text "fa1" - ppr_reg_no _ 44 = text "fa2" - ppr_reg_no _ 45 = text "fa3" - ppr_reg_no _ 46 = text "fa4" - ppr_reg_no _ 47 = text "fa5" - ppr_reg_no _ 48 = text "fa6" - ppr_reg_no _ 49 = text "fa7" - ppr_reg_no _ 50 = text "fs2" - ppr_reg_no _ 51 = text "fs3" - ppr_reg_no _ 52 = text "fs4" - ppr_reg_no _ 53 = text "fs5" - ppr_reg_no _ 54 = text "fs6" - ppr_reg_no _ 55 = text "fs7" - ppr_reg_no _ 56 = text "fs8" - ppr_reg_no _ 57 = text "fs9" - ppr_reg_no _ 58 = text "fs10" - ppr_reg_no _ 59 = text "fs11" - ppr_reg_no _ 60 = text "ft8" - ppr_reg_no _ 61 = text "ft9" - ppr_reg_no _ 62 = text "ft10" - ppr_reg_no _ 63 = text "ft11" - - ppr_reg_no w i + ppr_reg_no 32 = text "ft0" + ppr_reg_no 33 = text "ft1" + ppr_reg_no 34 = text "ft2" + ppr_reg_no 35 = text "ft3" + ppr_reg_no 36 = text "ft4" + ppr_reg_no 37 = text "ft5" + ppr_reg_no 38 = text "ft6" + ppr_reg_no 39 = text "ft7" + ppr_reg_no 40 = text "fs0" + ppr_reg_no 41 = text "fs1" + ppr_reg_no 42 = text "fa0" + ppr_reg_no 43 = text "fa1" + ppr_reg_no 44 = text "fa2" + ppr_reg_no 45 = text "fa3" + ppr_reg_no 46 = text "fa4" + ppr_reg_no 47 = text "fa5" + ppr_reg_no 48 = text "fa6" + ppr_reg_no 49 = text "fa7" + ppr_reg_no 50 = text "fs2" + ppr_reg_no 51 = text "fs3" + ppr_reg_no 52 = text "fs4" + ppr_reg_no 53 = text "fs5" + ppr_reg_no 54 = text "fs6" + ppr_reg_no 55 = text "fs7" + ppr_reg_no 56 = text "fs8" + ppr_reg_no 57 = text "fs9" + ppr_reg_no 58 = text "fs10" + ppr_reg_no 59 = text "fs11" + ppr_reg_no 60 = text "ft8" + ppr_reg_no 61 = text "ft9" + ppr_reg_no 62 = text "ft10" + ppr_reg_no 63 = text "ft11" + + ppr_reg_no i | i < 0 = pprPanic "Unexpected register number (min is 0)" (ppr w <+> int i) | i > 63 = pprPanic "Unexpected register number (max is 63)" (ppr w <+> int i) -- no support for widths > W64. @@ -446,7 +420,6 @@ isImmZero (OpImm (ImmDouble 0)) = True isImmZero (OpImm (ImmInt 0)) = True isImmZero _ = False - isLabel :: Target -> Bool isLabel (TBlock _) = True isLabel (TLabel _) = True @@ -500,7 +473,6 @@ pprInstr platform instr = case instr of | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfmul." <> if isSingleOp o1 then text "s" else text "d") o1 o2 o3 | otherwise -> op3 (text "\tmul") o1 o2 o3 SMULH o1 o2 o3 -> op3 (text "\tmulh") o1 o2 o3 - SMULL o1 o2 o3 -> op3 (text "\tsmull") o1 o2 o3 NEG o1 o2 | isFloatOp o1 && isFloatOp o2 && isSingleOp o2 -> op2 (text "\tfneg.s") o1 o2 NEG o1 o2 | isFloatOp o1 && isFloatOp o2 && isDoubleOp o2 -> op2 (text "\tfneg.d") o1 o2 NEG o1 o2 -> op2 (text "\tneg") o1 o2 @@ -509,7 +481,7 @@ pprInstr platform instr = case instr of -> op3 (text "\tfdiv." <> if isSingleOp o1 then text "s" else text "d") o1 o2 o3 DIV o1 o2 o3 -> op3 (text "\tdiv") o1 o2 o3 REM o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 - -> panic $ "pprInstr - REM not implemented for floats (yet)" + -> panic "pprInstr - REM not implemented for floats (yet)" REM o1 o2 o3 -> op3 (text "\trem") o1 o2 o3 REMU o1 o2 o3 -> op3 (text "\tremu") o1 o2 o3 @@ -563,12 +535,8 @@ pprInstr platform instr = case instr of -- Surrender! Let the assembler figure out the right expressions with pseudo-op LI. -> lines_ [ text "\tli" <+> pprOp platform o1 <> comma <+> pprOp platform o2 ] | otherwise -> op3 (text "\taddi") o1 o2 (OpImm (ImmInt 0)) - MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORI o1 o2 o3 -> op3 (text "\tori") o1 o2 o3 XORI o1 o2 o3 -> op3 (text "\txori") 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) @@ -593,7 +561,7 @@ pprInstr platform instr = case instr of BCOND_FAR c l r b t | isLabel t -> lines_ [ text "\t" <> pprBcond (negateCond c) <+> pprOp platform l <> comma <+> pprOp platform r <> comma <+> getLabel platform b <> text "_end" , text "\tla" <+> pprOp platform ip <> comma <+> getLabel platform t - , text "\tjalr" <+> text "x0" <> comma <+> pprOp platform ip <> comma <+> text "0" + , text "\tjalr" <+> text "x0" <> comma <+> pprOp platform ip <> comma <+> text "0" ] BCOND_FAR _ _ _ _ (TReg _) -> panic "RV64.ppr: No conditional branching to registers!" @@ -623,10 +591,10 @@ pprInstr platform instr = case instr of UGE -> lines_ [ sltuFor l r <+> pprOp platform o <> comma <+> pprOp platform l <> comma <+> pprOp platform r , text "\txori" <+> pprOp platform o <> comma <+> pprOp platform o <> comma <+> text "1" ] UGT -> lines_ [ sltuFor l r <+> pprOp platform o <> comma <+> pprOp platform r <> comma <+> pprOp platform l ] - OLT | isFloatOp l && isFloatOp r -> line $ binOp ("\tflt." ++ floatOpPrecision platform l r) - OLE | isFloatOp l && isFloatOp r -> line $ binOp ("\tfle." ++ floatOpPrecision platform l r) - OGT | isFloatOp l && isFloatOp r -> line $ binOp ("\tfgt." ++ floatOpPrecision platform l r) - OGE | isFloatOp l && isFloatOp r -> line $ binOp ("\tfge." ++ floatOpPrecision platform l r) + FLT | isFloatOp l && isFloatOp r -> line $ binOp ("\tflt." ++ floatOpPrecision platform l r) + FLE | isFloatOp l && isFloatOp r -> line $ binOp ("\tfle." ++ floatOpPrecision platform l r) + FGT | isFloatOp l && isFloatOp r -> line $ binOp ("\tfgt." ++ floatOpPrecision platform l r) + FGE | isFloatOp l && isFloatOp r -> line $ binOp ("\tfge." ++ floatOpPrecision platform l r) x -> pprPanic "RV64.ppr: unhandled CSET conditional" (text (show x) <+> pprOp platform o <> comma <+> pprOp platform r <> comma <+> pprOp platform l) where subFor l r | (OpImm _) <- r = text "\taddi" <+> pprOp platform o <> comma <+> pprOp platform l <> comma <+> pprOp platform (negOp r) @@ -641,14 +609,6 @@ pprInstr platform instr = case instr of binOp :: (IsLine doc) => String -> doc binOp op = text op <+> pprOp platform o <> comma <+> pprOp platform l <> comma <+> pprOp platform r - CBZ o (TBlock bid) -> line $ text "\tbeq x0, " <+> pprOp platform o <> comma <+> pprAsmLabel platform (mkLocalBlockLabel (getUnique bid)) - CBZ o (TLabel lbl) -> line $ text "\tbeq x0, " <+> pprOp platform o <> comma <+> pprAsmLabel platform lbl - CBZ _ (TReg _) -> panic "AArch64.ppr: No conditional (cbz) branching to registers!" - - CBNZ o (TBlock bid) -> line $ text "\tbne x0, " <+> pprOp platform o <> comma <+> pprAsmLabel platform (mkLocalBlockLabel (getUnique bid)) - CBNZ o (TLabel lbl) -> line $ text "\tbne x0, " <+> pprOp platform o <> comma <+> pprAsmLabel platform lbl - CBNZ _ (TReg _) -> panic "AArch64.ppr: No conditional (cbnz) branching to registers!" - -- 7. Load and Store Instructions -------------------------------------------- -- NOTE: GHC may do whacky things where it only load the lower part of an -- address. Not observing the correct size when loading will lead @@ -662,7 +622,7 @@ pprInstr platform instr = case instr of LDR _f o1 (OpImm (ImmIndex lbl off)) -> lines_ [ text "\tla" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl - , text "\taddi" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> (int off) + , text "\taddi" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> int off ] LDR _f o1 (OpImm (ImmCLbl lbl)) -> @@ -739,19 +699,20 @@ floatOpPrecision _p l r | isFloatOp l && isFloatOp r && isSingleOp l && isSingle floatOpPrecision _p l r | isFloatOp l && isFloatOp r && isDoubleOp l && isDoubleOp r = "d" -- double precision floatOpPrecision p l r = pprPanic "Cannot determine floating point precission" (text "op1" <+> pprOp p l <+> text "op2" <+> pprOp p r) -pprBcond :: IsLine doc => Cond -> doc +pprBcond :: (IsLine doc) => Cond -> doc pprBcond c = text "b" <> pprCond c - -pprCond :: IsLine doc => Cond -> doc -pprCond c = case c of - EQ -> text "eq" - NE -> text "ne" - SLT -> text "lt" - SLE -> text "le" - SGE -> text "ge" - SGT -> text "gt" - ULT -> text "ltu" - ULE -> text "leu" - UGE -> text "geu" - UGT -> text "gtu" - _ -> panic $ "RV64.ppr: unhandled BCOND conditional: " ++ show c + where + pprCond :: (IsLine doc) => Cond -> doc + pprCond c = case c of + EQ -> text "eq" + NE -> text "ne" + SLT -> text "lt" + SLE -> text "le" + SGE -> text "ge" + SGT -> text "gt" + ULT -> text "ltu" + ULE -> text "leu" + UGE -> text "geu" + UGT -> text "gtu" + -- BCOND cannot handle floating point comparisons / registers + _ -> panic $ "RV64.ppr: unhandled BCOND conditional: " ++ show c ===================================== compiler/GHC/CmmToAsm/RV64/Regs.hs ===================================== @@ -16,6 +16,8 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Platform +-- * Registers + -- | First integer register number. @zero@ register. x0RegNo :: RegNo x0RegNo = 0 @@ -67,6 +69,31 @@ fa7RegNo, d17RegNo :: RegNo d17RegNo = 49 fa7RegNo = d17RegNo +-- Note [The made-up RISCV64 IP register] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- RISCV64 has no inter-procedural register in its ABI. However, we need one to +-- make register spills/loads to/from high number slots. I.e. slot numbers that +-- do not fit in a 12bit integer which is used as immediate in the arithmetic +-- operations. Thus, we're marking one additional register (x31) as permanently +-- non-free and call it IP. +-- +-- IP can be used as temporary register in all operations. Just be aware that it +-- may be clobbered as soon as you loose direct control over it (i.e. using IP +-- by-passes the register allocation/spilling mechanisms.) It should be fine to +-- use it as temporary register in a MachOp translation as long as you don't +-- rely on its value beyond this limited scope. +-- +-- X31 is a caller-saved register. I.e. there are no guarantees about what the +-- callee does with it. That's exactly what we want here. + +zeroReg, raReg, spMachReg, ipReg :: Reg +zeroReg = regSingle x0RegNo +raReg = regSingle 1 +-- | Not to be confused with the `CmmReg` `spReg` +spMachReg = regSingle 2 +ipReg = regSingle ipRegNo + -- | All machine register numbers. allMachRegNos :: [RegNo] allMachRegNos = intRegs ++ fpRegs @@ -92,14 +119,18 @@ allGpArgRegs = map regSingle [a0RegNo .. a7RegNo] allFpArgRegs :: [Reg] allFpArgRegs = map regSingle [fa0RegNo .. fa7RegNo] +-- * Addressing modes + -- | Addressing modes data AddrMode - = AddrRegImm Reg Imm - | AddrReg Reg + = -- | A register plus some integer, e.g. @8(sp)@ or @-16(sp)@. The offset + -- needs to fit into 12bits. + AddrRegImm Reg Imm + | -- | A register + AddrReg Reg deriving (Eq, Show) --- ----------------------------------------------------------------------------- --- Immediates +-- * Immediates data Imm = ImmInt Int View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da053cea8d36f62887083575202a01da261dd492...f6f310eeebbd8b51ec51bf058517953daa2593e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da053cea8d36f62887083575202a01da261dd492...f6f310eeebbd8b51ec51bf058517953daa2593e3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 20:55:51 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 15:55:51 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/data-kind Message-ID: <65e8d857ca4de_38980e119bdf001091c7@gitlab.mail> Ben Gamari pushed new branch wip/data-kind at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/data-kind You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 21:20:24 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Wed, 06 Mar 2024 16:20:24 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Try preserving the original laziness Message-ID: <65e8de184ee54_38980e126b881811806c@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: 4806677c by Mikolaj Konarski at 2024-03-06T22:20:07+01:00 Try preserving the original laziness - - - - - 1 changed file: - compiler/GHC/Core/TyCo/Tidy.hs Changes: ===================================== compiler/GHC/Core/TyCo/Tidy.hs ===================================== @@ -235,7 +235,7 @@ tidyCo env@(_, subst) co -- the case above duplicates a bit of work in tidying h and the kind -- of tv. But the alternative is to use coercionKind, which seems worse. go (FunCo r afl afr w co1 co2) = ((FunCo r afl afr $! go w) $! go co1) $! go co2 - go (CoVarCo cv) = CoVarCo $! go_cv cv + go (CoVarCo cv) = CoVarCo $ go_cv cv go (HoleCo h) = HoleCo h go (AxiomInstCo con ind cos) = AxiomInstCo con ind $! strictMap go cos go (UnivCo p r t1 t2) = (((UnivCo $! (go_prov p)) $! r) $! View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4806677c9b8bad999093e94b07ae10f8a3d8e5ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4806677c9b8bad999093e94b07ae10f8a3d8e5ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 21:50:25 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 16:50:25 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 6 commits: rts: expose HeapAlloc.h as public header Message-ID: <65e8e5212490a_38980e13558bd4118624@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - a6054b42 by Ben Gamari at 2024-03-06T16:49:43-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs - libraries/base/src/System/IO.hs - libraries/base/src/System/Mem/Weak.hs - libraries/base/src/System/Posix/Internals.hs - libraries/base/src/Text/ParserCombinators/ReadP.hs - libraries/base/src/Text/ParserCombinators/ReadPrec.hs - libraries/base/src/Text/Read.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - rts/Sparks.c - rts/include/rts/storage/Block.h - rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h - rts/posix/OSMem.c - rts/rts.cabal - rts/sm/CNF.c - rts/sm/GC.h - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f7ab7dfa05cd545e5f22334b061eb74408751bb...a6054b425e2bde8c246ca9a8d59b3c5bbfc39d23 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f7ab7dfa05cd545e5f22334b061eb74408751bb...a6054b425e2bde8c246ca9a8d59b3c5bbfc39d23 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 22:05:21 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 17:05:21 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24513 Message-ID: <65e8e8a1d5b91_38980e139caa141194ab@gitlab.mail> Ben Gamari pushed new branch wip/T24513 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24513 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 22:06:23 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 17:06:23 -0500 Subject: [Git][ghc/ghc][wip/T24513] rts: Fix SET_HDR initialization of retainer set Message-ID: <65e8e8df9590b_38980e13a809541228da@gitlab.mail> Ben Gamari pushed to branch wip/T24513 at Glasgow Haskell Compiler / GHC Commits: c4c57631 by Ben Gamari at 2024-03-06T17:06:17-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 1 changed file: - rts/include/rts/storage/ClosureMacros.h Changes: ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4c57631ccf94acd87367831ff2c9e2ede154b39 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4c57631ccf94acd87367831ff2c9e2ede154b39 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 6 23:36:14 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Wed, 06 Mar 2024 18:36:14 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] 32 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65e8fdee19fd7_38980e163d66b41319c5@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 70f2d3ee by Mikolaj Konarski at 2024-03-07T00:34:41+01:00 Add DCoVarSet to PluginProv Add the only remaining piece of feedback from git add src/Flavour.hs Help CI check some more of the patch Fix the 3 plugin tests that fail Explain better how shallowCoVarsOfCosDSet is entangled with a hundreds of lines bit-rotten refactoring Fix according to the first round of Simon's instruction Fix according to the second round of Simon's instruction Remove a question-comment that's probably absurd Fix according to the third round of Simon's instruction - - - - - 053fdb81 by Mikolaj Konarski at 2024-03-07T00:34:41+01:00 Make sure the foldl' accumulators are strict - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4806677c9b8bad999093e94b07ae10f8a3d8e5ff...053fdb81f509cc6158c5d645ef2402e24ca3c115 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4806677c9b8bad999093e94b07ae10f8a3d8e5ff...053fdb81f509cc6158c5d645ef2402e24ca3c115 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 04:33:11 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 23:33:11 -0500 Subject: [Git][ghc/ghc][wip/T24513] rts: Fix SET_HDR initialization of retainer set Message-ID: <65e94387b9548_3e2dad4d9e9d870bd@gitlab.mail> Ben Gamari pushed to branch wip/T24513 at Glasgow Haskell Compiler / GHC Commits: 4f51757f by Ben Gamari at 2024-03-06T23:33:06-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 1 changed file: - rts/include/rts/storage/ClosureMacros.h Changes: ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.hp.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f51757ff0c55d97ab8c6765b378b2e97f617d8b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f51757ff0c55d97ab8c6765b378b2e97f617d8b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 04:44:25 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 23:44:25 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24515 Message-ID: <65e94629d3384_3e2dad527de54749a@gitlab.mail> Ben Gamari pushed new branch wip/T24515 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24515 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 04:44:37 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 23:44:37 -0500 Subject: [Git][ghc/ghc][wip/T24515] 9 commits: base: Reflect new era profiling RTS flags in GHC.RTS.Flags Message-ID: <65e94635dfd77_3e2dad52d503c763e@gitlab.mail> Ben Gamari pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 82e0d401 by Ben Gamari at 2024-03-06T23:44:33-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - libraries/base/changelog.md - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs - libraries/base/src/System/IO.hs - libraries/base/src/System/Mem/Weak.hs - libraries/base/src/System/Posix/Internals.hs - libraries/base/src/Text/ParserCombinators/ReadP.hs - libraries/base/src/Text/ParserCombinators/ReadPrec.hs - libraries/base/src/Text/Read.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - rts/ProfHeap.c - rts/Profiling.c - rts/RtsFlags.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/Sparks.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8fc51acfc7fb78d756e9e92e683ce70305f1466...82e0d401abbd8e0e550daa10a506ff00adbaa001 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8fc51acfc7fb78d756e9e92e683ce70305f1466...82e0d401abbd8e0e550daa10a506ff00adbaa001 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 04:46:52 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 06 Mar 2024 23:46:52 -0500 Subject: [Git][ghc/ghc][wip/T24515] rts: Drop .wasm suffix from .prof file names Message-ID: <65e946bccde01_3e2dad533622478e6@gitlab.mail> Ben Gamari pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: 56c3cac0 by Ben Gamari at 2024-03-06T23:46:38-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 4 changed files: - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h Changes: ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasi32_HOST_OS) + dropExtension(prog, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasi32_HOST_OS) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/56c3cac08ae0d28e797527487699cbae858985d7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/56c3cac08ae0d28e797527487699cbae858985d7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 08:17:02 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Thu, 07 Mar 2024 03:17:02 -0500 Subject: [Git][ghc/ghc][wip/T24515] 2 commits: rts: Drop .wasm suffix from .prof file names Message-ID: <65e977fedfc05_3e2dadac5e1e421440@gitlab.mail> Cheng Shao pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: 9c9994a2 by Ben Gamari at 2024-03-07T08:16:05+00:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 3d9aed44 by Cheng Shao at 2024-03-07T08:16:30+00:00 Revert "testsuite: include target exe extension in heap profile filenames" This reverts commit 6f511c36f9845a6e3731e658de4992bfd9806a52. - - - - - 5 changed files: - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - testsuite/driver/testlib.py Changes: ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(stem, ".exe"); +#elif defined(wasm32_HOST_ARCH) + dropExtension(stem, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasm32_HOST_ARCH) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" ===================================== testsuite/driver/testlib.py ===================================== @@ -2332,11 +2332,11 @@ async def check_hp_ok(name: TestName) -> bool: actual_name = name + exe_extension() if not opts.ignore_extension else name # do not qualify for hp2ps because we should be in the right directory - hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {actual_name}'.format(**locals()) + hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {name}'.format(**locals()) hp2psResult = await runCmd(hp2psCmd, print_output=True) - actual_ps_path = in_testdir(actual_name, 'ps') + actual_ps_path = in_testdir(name, 'ps') if hp2psResult == 0: if actual_ps_path.exists(): @@ -2345,15 +2345,15 @@ async def check_hp_ok(name: TestName) -> bool: if (gsResult == 0): return True else: - print("hp2ps output for " + actual_name + " is not valid PostScript") + print("hp2ps output for " + name + " is not valid PostScript") return False else: return True # assume postscript is valid without ghostscript else: - print("hp2ps did not generate PostScript for " + actual_name) + print("hp2ps did not generate PostScript for " + name) return False else: - print("hp2ps error when processing heap profile for " + actual_name) + print("hp2ps error when processing heap profile for " + name) return False async def check_prof_ok(name: TestName, way: WayName) -> bool: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/56c3cac08ae0d28e797527487699cbae858985d7...3d9aed44cf82ce2ebebcdca4d901f7f68913ce34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/56c3cac08ae0d28e797527487699cbae858985d7...3d9aed44cf82ce2ebebcdca4d901f7f68913ce34 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 08:40:59 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Thu, 07 Mar 2024 03:40:59 -0500 Subject: [Git][ghc/ghc][wip/T24515] testsuite: drop exe extension from .hp & .prof filenames Message-ID: <65e97d9bcd3a9_3e2dadb6984e8218a9@gitlab.mail> Cheng Shao pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: 4184eaba by Cheng Shao at 2024-03-07T08:40:24+00:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -2329,14 +2329,13 @@ def write_file(f: Path, s: str) -> None: async def check_hp_ok(name: TestName) -> bool: opts = getTestOpts() - actual_name = name + exe_extension() if not opts.ignore_extension else name # do not qualify for hp2ps because we should be in the right directory - hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {actual_name}'.format(**locals()) + hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {name}'.format(**locals()) hp2psResult = await runCmd(hp2psCmd, print_output=True) - actual_ps_path = in_testdir(actual_name, 'ps') + actual_ps_path = in_testdir(name, 'ps') if hp2psResult == 0: if actual_ps_path.exists(): @@ -2345,15 +2344,15 @@ async def check_hp_ok(name: TestName) -> bool: if (gsResult == 0): return True else: - print("hp2ps output for " + actual_name + " is not valid PostScript") + print("hp2ps output for " + name + " is not valid PostScript") return False else: return True # assume postscript is valid without ghostscript else: - print("hp2ps did not generate PostScript for " + actual_name) + print("hp2ps did not generate PostScript for " + name) return False else: - print("hp2ps error when processing heap profile for " + actual_name) + print("hp2ps error when processing heap profile for " + name) return False async def check_prof_ok(name: TestName, way: WayName) -> bool: @@ -2365,7 +2364,7 @@ async def check_prof_ok(name: TestName, way: WayName) -> bool: if not expected_prof_path.exists(): return True - actual_prof_file = add_suffix(name + exe_extension(), 'prof') + actual_prof_file = add_suffix(name, 'prof') actual_prof_path = in_testdir(actual_prof_file) if not actual_prof_path.exists(): View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4184eabaded1965f4a4bde4c5053132e67978bc2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4184eabaded1965f4a4bde4c5053132e67978bc2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 10:00:00 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Thu, 07 Mar 2024 05:00:00 -0500 Subject: [Git][ghc/ghc][wip/int-index/visargs-errmsg] 80 commits: Add @since annotation to Data.Data.mkConstrTag Message-ID: <65e99020f1607_3e2dadd86f4e0320c7@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/visargs-errmsg at Glasgow Haskell Compiler / GHC Commits: 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 3fa9a654 by Vladislav Zavialov at 2024-03-07T12:59:25+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f96fd479be53aebc8e2abb1b6a06dace0be1def7...3fa9a654f11e4dfe6529dea66f3cdc0fdff4e07d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f96fd479be53aebc8e2abb1b6a06dace0be1def7...3fa9a654f11e4dfe6529dea66f3cdc0fdff4e07d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 10:02:07 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Thu, 07 Mar 2024 05:02:07 -0500 Subject: [Git][ghc/ghc][wip/int-index/visargs-errmsg] Rephrase error message to say "visible arguments" (#24318) Message-ID: <65e9909fc0c7e_3e2daddb106543245c@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/visargs-errmsg at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - 24 changed files: - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - testsuite/tests/ado/ado002.stderr - testsuite/tests/ghci/scripts/Defer02.stderr - testsuite/tests/indexed-types/should_compile/T10806.stderr - testsuite/tests/indexed-types/should_fail/T8518.stderr - testsuite/tests/rep-poly/T23903.stderr - testsuite/tests/th/T5358.stderr - testsuite/tests/typecheck/should_fail/DoExpansion2.stderr - testsuite/tests/typecheck/should_fail/DoExpansion3.stderr - testsuite/tests/typecheck/should_fail/FD1.stderr - testsuite/tests/typecheck/should_fail/T13902.stderr - testsuite/tests/typecheck/should_fail/T17139.stderr - + testsuite/tests/typecheck/should_fail/T24318.hs - + testsuite/tests/typecheck/should_fail/T24318.stderr - testsuite/tests/typecheck/should_fail/T8603.stderr - testsuite/tests/typecheck/should_fail/T9605.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail001.stderr - testsuite/tests/typecheck/should_fail/tcfail140.stderr - testsuite/tests/typecheck/should_fail/tcfail175.stderr - testsuite/tests/vdq-rta/should_fail/T22326_fail_n_args.stderr - testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr Changes: ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -75,7 +75,7 @@ import GHC.Driver.DynFlags ( getDynFlags ) import GHC.Types.Name import GHC.Types.Id import GHC.Types.SrcLoc -import GHC.Types.Basic( Arity, isDoExpansionGenerated ) +import GHC.Types.Basic( VisArity, isDoExpansionGenerated ) import Control.Monad import Control.Arrow ( second ) @@ -1207,7 +1207,7 @@ the variables they bind into scope, and typecheck the thing_inside. -- The MatchGroup for `f` has arity 2, not 3 checkArgCounts :: AnnoBody body => MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM Arity + -> TcM VisArity checkArgCounts (MG { mg_alts = L _ [] }) = return 1 -- See Note [Empty MatchGroups] in GHC.Rename.Bind -- case e of {} or \case {} @@ -1227,6 +1227,6 @@ checkArgCounts (MG { mg_alts = L _ (match1:matches) }) n_args1 = reqd_args_in_match match1 mb_bad_matches = NE.nonEmpty [m | m <- matches, reqd_args_in_match m /= n_args1] - reqd_args_in_match :: LocatedA (Match GhcRn body1) -> Arity + reqd_args_in_match :: LocatedA (Match GhcRn body1) -> VisArity -- Counts the number of /required/ args in the match reqd_args_in_match (L _ (Match { m_pats = pats })) = count (isVisArgPat . unLoc) pats ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -751,7 +751,7 @@ Example: matchExpectedFunTys :: forall a. ExpectedFunTyOrigin -- See Note [Herald for matchExpectedFunTys] -> UserTypeCtxt - -> Arity + -> VisArity -> ExpSigmaType -> ([ExpPatType] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) @@ -777,7 +777,7 @@ matchExpectedFunTys herald _ arity (Infer inf_res) thing_inside matchExpectedFunTys herald ctx arity (Check top_ty) thing_inside = check 0 [] top_ty where - check :: Arity -> [ExpPatType] -> TcSigmaType -> TcM (HsWrapper, a) + check :: VisArity -> [ExpPatType] -> TcSigmaType -> TcM (HsWrapper, a) -- `check` is called only in the Check{} case -- It collects rev_pat_tys in reversed order -- n_so_far is the number of /visible/ arguments seen so far: @@ -875,7 +875,7 @@ matchExpectedFunTys herald ctx arity (Check top_ty) thing_inside defer n_so_far rev_pat_tys res_ty ------------ - defer :: Arity -> [ExpPatType] -> TcRhoType -> TcM (HsWrapper, a) + defer :: VisArity -> [ExpPatType] -> TcRhoType -> TcM (HsWrapper, a) defer n_so_far rev_pat_tys fun_ty = do { more_arg_tys <- mapM (new_check_arg_ty herald) [n_so_far + 1 .. arity] ; let all_pats = reverse rev_pat_tys ++ map mkCheckExpFunPatTy more_arg_tys @@ -898,19 +898,15 @@ new_check_arg_ty herald arg_pos -- Position for error messages only ; return (mkScaled mult arg_ty) } mkFunTysMsg :: ExpectedFunTyOrigin - -> (Arity, TcType) + -> (VisArity, TcType) -> TidyEnv -> ZonkM (TidyEnv, SDoc) -- See Note [Reporting application arity errors] -mkFunTysMsg herald (n_val_args_in_call, fun_ty) env +mkFunTysMsg herald (n_vis_args_in_call, fun_ty) env = do { (env', fun_ty) <- zonkTidyTcType env fun_ty ; let (pi_ty_bndrs, _) = splitPiTys fun_ty - - -- `all_arg_tys` contains visible quantifiers only, so their number matches - -- the number of arguments that the user needs to pass to the function. n_fun_args = count isVisiblePiTyBinder pi_ty_bndrs - - msg | n_val_args_in_call <= n_fun_args -- Enough args, in the end + msg | n_vis_args_in_call <= n_fun_args -- Enough args, in the end = text "In the result of a function call" | otherwise = hang (full_herald <> comma) @@ -921,7 +917,8 @@ mkFunTysMsg herald (n_val_args_in_call, fun_ty) env ; return (env', msg) } where full_herald = pprExpectedFunTyHerald herald - <+> speakNOf n_val_args_in_call (text "value argument") + <+> speakNOf n_vis_args_in_call (text "visible argument") + -- What are "visible" arguments? See Note [Visibility and arity] in GHC.Types.Basic {- Note [Reporting application arity errors] @@ -931,8 +928,8 @@ and the call foo = f 3 4 5 We'd like to get an error like: • Couldn't match expected type ‘t0 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to three value arguments, - but its type ‘Int -> Int -> Int’ has only two + • The function ‘f’ is applied to three visible arguments, -- What are "visible" arguments? + but its type ‘Int -> Int -> Int’ has only two -- See Note [Visibility and arity] in GHC.Types.Basic That is what `mkFunTysMsg` tries to do. But what is the "type of the function". Most obviously, we can report its full, polymorphic type; that is simple and @@ -943,7 +940,7 @@ We get this error: • Couldn't match type ‘Int’ with ‘t0 -> t’ Expected: Int -> t0 -> t Actual: Int -> Int - • The function ‘f’ is applied to three value arguments, + • The function ‘f’ is applied to three visible arguments, but its type ‘Bool -> t Int Int’ has only one That's not /quite/ right beause we can instantiate `t` to an arrow and get ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -28,7 +28,7 @@ module GHC.Types.Basic ( ConTag, ConTagZ, fIRST_TAG, - Arity, RepArity, JoinArity, FullArgCount, + Arity, VisArity, RepArity, JoinArity, FullArgCount, JoinPointHood(..), isJoinPoint, Alignment, mkAlignment, alignmentOf, alignmentBytes, @@ -183,6 +183,10 @@ instance Binary LeftOrRight where -- See also Note [Definition of arity] in "GHC.Core.Opt.Arity" type Arity = Int +-- | Syntactic (visibility) arity, i.e. the number of visible arguments. +-- See Note [Visibility and arity] +type VisArity = Int + -- | Representation Arity -- -- The number of represented arguments that can be applied to a value before it does @@ -203,6 +207,71 @@ type JoinArity = Int -- both type and value arguments! type FullArgCount = Int +{- Note [Visibility and arity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Arity is the number of arguments that a function expects. In a curried language +like Haskell, there is more than one way to count those arguments. + +* `Arity` is the classic notion of arity, concerned with evalution, so it counts + the number of /value/ arguments that need to be supplied before evaluation can + take place, as described in notes + Note [Definition of arity] in GHC.Core.Opt.Arity + Note [Arity and function types] in GHC.Types.Id.Info + + Examples: + Int has arity == 0 + Int -> Int has arity <= 1 + Int -> Bool -> Int has arity <= 2 + We write (<=) rather than (==) as sometimes evaluation can occur before all + value arguments are supplied, depending on the actual function definition. + + This evaluation-focused notion of arity ignores type arguments, so: + forall a. a has arity == 0 + forall a. a -> a has arity <= 1 + forall a b. a -> b -> a has arity <= 2 + This is true regardless of ForAllTyFlag, so the arity is also unaffected by + (forall {a}. ty) or (forall a -> ty). + + Class dictionaries count towards the arity, as they are passed at runtime + forall a. (Num a) => a has arity <= 1 + forall a. (Num a) => a -> a has arity <= 2 + forall a b. (Num a, Ord b) => a -> b -> a has arity <= 4 + +* `VisArity` is the syntactic notion of arity. It is the number of /visible/ + arguments, i.e. arguments that occur visibly in the source code. + + In a function call `f x y z`, we can confidently say that f's vis-arity >= 3, + simply because we see three arguments [x,y,z]. We write (>=) rather than (==) + as this could be a partial application. + + At definition sites, we can acquire an underapproximation of vis-arity by + counting the patterns on the LHS, e.g. `f a b = rhs` has vis-arity >= 2. + The actual vis-arity can be higher if there is a lambda on the RHS, + e.g. `f a b = \c -> rhs`. + + If we look at the types, we can observe the following + * function arrows (a -> b) add to the vis-arity + * visible foralls (forall a -> b) add to the vis-arity + * constraint arrows (a => b) do not affect the vis-arity + * invisible foralls (forall a. b) do not affect the vis-arity + + This means that ForAllTyFlag matters for VisArity (in contrast to Arity), + while the type/value distinction is unimportant (again in contrast to Arity). + + Examples: + Int -- vis-arity == 0 (no args) + Int -> Int -- vis-arity == 1 (1 funarg) + forall a. a -> a -- vis-arity == 1 (1 funarg) + forall a. Num a => a -> a -- vis-arity == 1 (1 funarg) + forall a -> Num a => a -- vis-arity == 1 (1 req tyarg, 0 funargs) + forall a -> a -> a -- vis-arity == 2 (1 req tyarg, 1 funarg) + Int -> forall a -> Int -- vis-arity == 2 (1 funarg, 1 req tyarg) + + Wrinkle: with TypeApplications and TypeAbstractions, it is possible to visibly + bind and pass invisible arguments, e.g. `f @a x = ...` or `f @Int 42`. Those + @-prefixed arguments are ignored for the purposes of vis-arity. +-} + {- ************************************************************************ * * ===================================== testsuite/tests/ado/ado002.stderr ===================================== @@ -2,7 +2,7 @@ ado002.hs:8:8: error: [GHC-83865] • Couldn't match expected type: Char -> IO b0 with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: y <- getChar 'a' In the expression: @@ -45,7 +45,7 @@ ado002.hs:15:13: error: [GHC-83865] ado002.hs:23:9: error: [GHC-83865] • Couldn't match expected type: Char -> IO a0 with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: x5 <- getChar x4 In the expression: ===================================== testsuite/tests/ghci/scripts/Defer02.stderr ===================================== @@ -26,7 +26,7 @@ Defer01.hs:24:4: warning: [GHC-40564] [-Winaccessible-code (in -Wdefault)] Defer01.hs:30:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one value argument, + • The function ‘e’ is applied to one visible argument, but its type ‘Char’ has none In the expression: e 'q' In an equation for ‘f’: f = e 'q' @@ -95,7 +95,7 @@ Defer01.hs:49:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] (deferred type error) *** Exception: Defer01.hs:30:5: error: [GHC-83865] • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one value argument, + • The function ‘e’ is applied to one visible argument, but its type ‘Char’ has none In the expression: e 'q' In an equation for ‘f’: f = e 'q' ===================================== testsuite/tests/indexed-types/should_compile/T10806.stderr ===================================== @@ -2,7 +2,7 @@ T10806.hs:11:32: error: [GHC-83865] • Couldn't match expected type: Char -> Bool with actual type: IO () - • The function ‘print’ is applied to two value arguments, + • The function ‘print’ is applied to two visible arguments, but its type ‘Show a => a -> IO ()’ has only one In the expression: print 'x' 'y' In an equation for ‘triggersLoop’: ===================================== testsuite/tests/indexed-types/should_fail/T8518.stderr ===================================== @@ -2,7 +2,7 @@ T8518.hs:14:18: error: [GHC-83865] • Couldn't match expected type: Z c -> B c -> t0 with actual type: F c - • The function ‘rpt’ is applied to four value arguments, + • The function ‘rpt’ is applied to four visible arguments, but its type ‘t1 -> t2 -> F t2’ has only two In the expression: rpt (4 :: Int) c z b In an equation for ‘callCont’: ===================================== testsuite/tests/rep-poly/T23903.stderr ===================================== @@ -6,5 +6,5 @@ T23903.hs:21:1: error: [GHC-55287] t0 :: TYPE cx0 Cannot unify ‘Rep a’ with the type variable ‘cx0’ because the former is not a concrete ‘RuntimeRep’. - • The equation for ‘f’ has one value argument, + • The equation for ‘f’ has one visible argument, but its type ‘a #-> ()’ has none ===================================== testsuite/tests/th/T5358.stderr ===================================== @@ -1,17 +1,17 @@ T5358.hs:7:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t1 -> t1’ - • The equation for ‘t1’ has one value argument, + • The equation for ‘t1’ has one visible argument, but its type ‘Int’ has none T5358.hs:8:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t0 -> t0’ - • The equation for ‘t2’ has one value argument, + • The equation for ‘t2’ has one visible argument, but its type ‘Int’ has none T5358.hs:10:13: error: [GHC-83865] • Couldn't match expected type ‘t -> a0’ with actual type ‘Int’ - • The function ‘t1’ is applied to one value argument, + • The function ‘t1’ is applied to one visible argument, but its type ‘Int’ has none In the first argument of ‘(==)’, namely ‘t1 x’ In the expression: t1 x == t2 x @@ -21,7 +21,7 @@ T5358.hs:10:13: error: [GHC-83865] T5358.hs:10:21: error: [GHC-83865] • Couldn't match expected type ‘t -> a0’ with actual type ‘Int’ - • The function ‘t2’ is applied to one value argument, + • The function ‘t2’ is applied to one visible argument, but its type ‘Int’ has none In the second argument of ‘(==)’, namely ‘t2 x’ In the expression: t1 x == t2 x ===================================== testsuite/tests/typecheck/should_fail/DoExpansion2.stderr ===================================== @@ -55,7 +55,7 @@ DoExpansion2.hs:31:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type: t0 -> IO (Maybe Int) with actual type: IO String - • The function ‘getVal’ is applied to two value arguments, + • The function ‘getVal’ is applied to two visible arguments, but its type ‘Int -> IO String’ has only one In a stmt of a 'do' block: Just x <- getVal 3 4 In the expression: ===================================== testsuite/tests/typecheck/should_fail/DoExpansion3.stderr ===================================== @@ -10,7 +10,7 @@ DoExpansion3.hs:15:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul DoExpansion3.hs:18:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type: t0 -> t with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In the expression: getChar 2 In an equation for ‘y’: y = getChar 2 ===================================== testsuite/tests/typecheck/should_fail/FD1.stderr ===================================== @@ -5,6 +5,6 @@ FD1.hs:16:1: error: [GHC-25897] the type signature for: plus :: forall a. E a (Int -> Int) => Int -> a at FD1.hs:15:1-38 - • The equation for ‘plus’ has two value arguments, + • The equation for ‘plus’ has two visible arguments, but its type ‘Int -> a’ has only one • Relevant bindings include plus :: Int -> a (bound at FD1.hs:16:1) ===================================== testsuite/tests/typecheck/should_fail/T13902.stderr ===================================== @@ -1,7 +1,7 @@ T13902.hs:8:5: error: [GHC-83865] • Couldn't match expected type ‘t0 -> Int’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘a -> a’ has only one In the expression: f @Int 42 5 In an equation for ‘g’: g = f @Int 42 5 ===================================== testsuite/tests/typecheck/should_fail/T17139.stderr ===================================== @@ -7,7 +7,7 @@ T17139.hs:15:16: error: [GHC-88464] lift :: forall a b (f :: * -> *). (a -> b) -> TypeFam f (a -> b) at T17139.hs:14:1-38 • In the expression: _ (f <*> x) - The lambda expression ‘\ x -> ...’ has one value argument, + The lambda expression ‘\ x -> ...’ has one visible argument, but its type ‘TypeFam f (a -> b)’ has none In the expression: \ x -> _ (f <*> x) • Relevant bindings include ===================================== testsuite/tests/typecheck/should_fail/T24318.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE ExplicitNamespaces, RequiredTypeArguments #-} + +module T24318 where + +import Data.Kind + +f :: forall (a :: Type) -> Bool +f (type t) x = True ===================================== testsuite/tests/typecheck/should_fail/T24318.stderr ===================================== @@ -0,0 +1,5 @@ + +T24318.hs:8:1: error: [GHC-83865] + • Couldn't match expected type ‘Bool’ with actual type ‘t0 -> Bool’ + • The equation for ‘f’ has two visible arguments, + but its type ‘forall a -> Bool’ has only one ===================================== testsuite/tests/typecheck/should_fail/T8603.stderr ===================================== @@ -6,7 +6,7 @@ T8603.hs:33:17: error: [GHC-18872] [a2] :: * Expected: [a2] -> StateT s RV a0 Actual: t0 ((->) [a1]) (StateT s RV a0) - • The function ‘lift’ is applied to two value arguments, + • The function ‘lift’ is applied to two visible arguments, but its type ‘(Control.Monad.Trans.Class.MonadTrans t, Monad m) => m a -> t m a’ has only one ===================================== testsuite/tests/typecheck/should_fail/T9605.stderr ===================================== @@ -3,7 +3,7 @@ T9605.hs:7:6: error: [GHC-83865] • Couldn't match type ‘Bool’ with ‘m Bool’ Expected: t0 -> m Bool Actual: t0 -> Bool - • The function ‘f1’ is applied to one value argument, + • The function ‘f1’ is applied to one visible argument, but its type ‘Monad m => m Bool’ has none In the expression: f1 undefined In an equation for ‘f2’: f2 = f1 undefined ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -712,6 +712,7 @@ test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always test('T24064', normal, compile_fail, ['']) test('T24298', normal, compile_fail, ['']) test('T24279', normal, compile_fail, ['']) +test('T24318', normal, compile_fail, ['']) # all the various do expansion fail messages test('DoExpansion1', normal, compile, ['-fdefer-type-errors']) ===================================== testsuite/tests/typecheck/should_fail/tcfail001.stderr ===================================== @@ -2,7 +2,7 @@ tcfail001.hs:9:2: error: [GHC-83865] • Couldn't match expected type: [a] with actual type: [a0] -> [a1] - • The equation for ‘op’ has one value argument, + • The equation for ‘op’ has one visible argument, but its type ‘[a]’ has none In the instance declaration for ‘A [a]’ • Relevant bindings include op :: [a] (bound at tcfail001.hs:9:2) ===================================== testsuite/tests/typecheck/should_fail/tcfail140.stderr ===================================== @@ -1,7 +1,7 @@ tcfail140.hs:11:7: error: [GHC-83865] • Couldn't match expected type ‘t1 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘Int -> Int’ has only one In the expression: f 3 9 In an equation for ‘bar’: bar = f 3 9 @@ -9,7 +9,7 @@ tcfail140.hs:11:7: error: [GHC-83865] tcfail140.hs:13:10: error: [GHC-83865] • Couldn't match expected type ‘t2 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘Int -> Int’ has only one In the expression: 3 `f` 4 In an equation for ‘rot’: rot xs = 3 `f` 4 @@ -28,11 +28,11 @@ tcfail140.hs:15:15: error: [GHC-83865] tcfail140.hs:17:8: error: [GHC-27346] • The data constructor ‘Just’ should have 1 argument, but has been given none • In the pattern: Just - The lambda expression ‘\ Just x -> ...’ has two value arguments, + The lambda expression ‘\ Just x -> ...’ has two visible arguments, but its type ‘Maybe a -> a’ has only one In the expression: ((\ Just x -> x) :: Maybe a -> a) (Just 1) tcfail140.hs:20:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t0 -> Bool’ - • The equation for ‘g’ has two value arguments, + • The equation for ‘g’ has two visible arguments, but its type ‘Int -> Int’ has only one ===================================== testsuite/tests/typecheck/should_fail/tcfail175.stderr ===================================== @@ -6,7 +6,7 @@ tcfail175.hs:11:1: error: [GHC-25897] the type signature for: evalRHS :: forall a. Int -> a at tcfail175.hs:10:1-19 - • The equation for ‘evalRHS’ has three value arguments, + • The equation for ‘evalRHS’ has three visible arguments, but its type ‘Int -> a’ has only one • Relevant bindings include evalRHS :: Int -> a (bound at tcfail175.hs:11:1) ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_n_args.stderr ===================================== @@ -5,5 +5,5 @@ T22326_fail_n_args.hs:6:1: error: [GHC-25897] the type signature for: f :: a -> forall b -> b at T22326_fail_n_args.hs:6:1-26 - • The equation for ‘f’ has three value arguments, + • The equation for ‘f’ has three visible arguments, but its type ‘a -> forall b -> b’ has only two ===================================== testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr ===================================== @@ -37,7 +37,7 @@ CaretDiagnostics1.hs:13:7-11: error: [GHC-83865] CaretDiagnostics1.hs:(13,16)-(14,13): error: [GHC-83865] • Couldn't match expected type ‘Char -> t0’ with actual type ‘()’ - • The function ‘()’ is applied to one value argument, + • The function ‘()’ is applied to one visible argument, but its type ‘()’ has none In the expression: () '0' In a case alternative: "γηξ" -> () '0' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9cd9efb4de3757fd5eaec006739f75cef288e5eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9cd9efb4de3757fd5eaec006739f75cef288e5eb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 10:50:54 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Thu, 07 Mar 2024 05:50:54 -0500 Subject: [Git][ghc/ghc][wip/T24031] Deprecate PrimTyConI Message-ID: <65e99c0ee8f86_10117be7d9fc317be@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: 6c8c2363 by Teo Camarasu at 2024-03-07T10:50:41+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 8 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/th/T16293b.hs - + testsuite/tests/th/T24031.hs - + testsuite/tests/th/T24031.stdout - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -26,7 +26,7 @@ module GHC.Tc.Gen.Splice( runMetaE, runMetaP, runMetaT, runMetaD, runQuasi, tcTopSpliceExpr, lookupThName_maybe, defaultRunMeta, runMeta', runRemoteModFinalizers, - finishTH, runTopSplice + finishTH, runTopSplice, reifyName ) where import GHC.Prelude @@ -2120,15 +2120,6 @@ reifyTyCon tc | Just cls <- tyConClass_maybe tc = reifyClass cls -{- Seems to be just a short cut for the next equation -- omit - | tc `hasKey` fUNTyConKey -- I'm not quite sure what is happening here - = return (TH.PrimTyConI (reifyName tc) 2 False) --} - - | isPrimTyCon tc - = return (TH.PrimTyConI (reifyName tc) (length (tyConVisibleTyVars tc)) - (isUnliftedTypeKind (tyConResKind tc))) - | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc ===================================== libraries/template-haskell/Language/Haskell/TH/Ppr.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE Safe #-} {-# LANGUAGE LambdaCase #-} +{-# OPTIONS_GHC -Wno-deprecations #-} -- | contains a prettyprinter for the -- Template Haskell datatypes ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2068,6 +2068,7 @@ data Info Name Type -- What it is bound to deriving( Show, Eq, Ord, Data, Generic ) +{-# DEPRECATED PrimTyConI "TyConI is now produced instead." #-} -- | Obtained from 'reifyModule' in the 'Q' Monad. data ModuleInfo = ===================================== libraries/template-haskell/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`template-haskell` package](http://hackage.haskell.org/package/template-haskell) +## 2.23.0.0 + * `PrimTyConI` has been deprecated. `TyConI` will now be used to represent primitive types. + ## 2.22.0.0 * The kind of `Code` was changed from `forall r. (Type -> Type) -> TYPE r -> Type` ===================================== testsuite/tests/th/T16293b.hs ===================================== @@ -7,7 +7,8 @@ import GHC.Exts import Language.Haskell.TH f :: () -f = $(do PrimTyConI _ arity _ <- reify ''Proxy# +f = $(do TyConI (DataD _ _ targs _ _ _) <- reify ''Proxy# + let arity = length targs unless (arity == 1) $ fail $ "Unexpected arity for Proxy#: " ++ show arity [| () |]) ===================================== testsuite/tests/th/T24031.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE LinearTypes #-} +-- | This test shows that we can reify a bunch of primitive types. +-- Additionally it acts as a golden test to ensure that we don't +-- accidentally change our output for these types. + +import Control.Monad +import Data.Char +import GHC.Exts +import Language.Haskell.TH +import Language.Haskell.TH.Syntax +import GHC.Builtin.Types.Prim (primTyCons) +import GHC.Tc.Gen.Splice (reifyName) + +main :: IO () +main = $(do let types = map reifyName primTyCons + reified <- mapM reify types + let stripInt [] = [] + stripInt (x:xs) + | isDigit x = stripInt xs + | otherwise = x:xs + -- remove _[0-9]* sequences + let stripUniques ('_':xs) = stripUniques $ stripInt xs + stripUniques (x:xs)= x:stripUniques xs + stripUniques [] = [] + let output = lift $ map (stripUniques . show) reified + [| mapM_ putStrLn $output |]) ===================================== testsuite/tests/th/T24031.stdout ===================================== @@ -0,0 +1,74 @@ +TyConI (DataD [] GHC.Prim.~# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.~R# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.~P# [KindedTV a BndrReq (VarT k0),KindedTV b BndrReq (VarT k1)] Nothing [] []) +TyConI (DataD [] GHC.Prim.=> [KindedTV a BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.==> [KindedTV a BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.-=> [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.CONSTRAINT) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Addr# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Array# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.ByteArray# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallArray# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Char# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Double# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Float# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.BCO [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Weak# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableArray# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutableByteArray# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.SmallMutableArray# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.IOPort# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.TVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.MutVar# [KindedTV a BndrReq StarT,KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.RealWorld [] Nothing [] []) +TyConI (DataD [] GHC.Prim.StablePtr# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.StableName# [KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (AppT (PromotedT GHC.Types.BoxedRep) (VarT l)))] Nothing [] []) +TyConI (DataD [] GHC.Prim.Compact# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.State# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.Proxy# [KindedTV a BndrReq (VarT k)] Nothing [] []) +TyConI (DataD [] GHC.Prim.ThreadId# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.StackSnapshot# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.PromptTag# [KindedTV a BndrReq StarT] Nothing [] []) +TyConI (DataD [] GHC.Prim.FUN [KindedTV n BndrReq (ConT GHC.Types.Multiplicity),KindedTV a BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT q)),KindedTV b BndrReq (AppT (ConT GHC.Prim.TYPE) (VarT r))] Nothing [] []) +TyConI (DataD [] GHC.Prim.TYPE [KindedTV a BndrReq (ConT GHC.Types.RuntimeRep)] Nothing [] []) +TyConI (DataD [] GHC.Prim.CONSTRAINT [KindedTV a BndrReq (ConT GHC.Types.RuntimeRep)] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int8X64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int16X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int32X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Int64X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word8X64# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word16X32# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word32X16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.Word64X8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX2# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX8# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX4# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.FloatX16# [] Nothing [] []) +TyConI (DataD [] GHC.Prim.DoubleX8# [] Nothing [] []) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24031', normal, compile_and_run, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c8c236346a1234b7b13b72e1584cd96ecfbcf14 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c8c236346a1234b7b13b72e1584cd96ecfbcf14 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 12:05:22 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Thu, 07 Mar 2024 07:05:22 -0500 Subject: [Git][ghc/ghc][wip/T23942] 15 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e9ad82b336d_10117b2b69b2439798@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - b971bf8f by Matthew Craven at 2024-03-07T01:49:09-05:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Platform.hs - compiler/GHC/Tc/Errors/Hole/Plugin.hs-boot - compiler/GHC/Tc/Types/LclEnv.hs-boot - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Utils/Containers/Internal/StrictPair.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/base/changelog.md - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ed418039b26d7cc6ca442e41273caf589523c8a...b971bf8f54a6748aff30cee5cf106b92fd941cc5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ed418039b26d7cc6ca442e41273caf589523c8a...b971bf8f54a6748aff30cee5cf106b92fd941cc5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 12:20:48 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Thu, 07 Mar 2024 07:20:48 -0500 Subject: [Git][ghc/ghc][wip/T24031] 15 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e9b120dc59b_10117b310c720456f7@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 3ead2f38 by Teo Camarasu at 2024-03-07T12:20:46+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Tc/Gen/Splice.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/runtime_control.rst - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/base/changelog.md - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs - libraries/base/src/System/IO.hs - libraries/base/src/System/Mem/Weak.hs - libraries/base/src/System/Posix/Internals.hs - libraries/base/src/Text/ParserCombinators/ReadP.hs - libraries/base/src/Text/ParserCombinators/ReadPrec.hs - libraries/base/src/Text/Read.hs - libraries/filepath - libraries/ghc-experimental/src/Data/Sum/Experimental.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6c8c236346a1234b7b13b72e1584cd96ecfbcf14...3ead2f38a5f448ea1a669fcbbfa8469004b46f4d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6c8c236346a1234b7b13b72e1584cd96ecfbcf14...3ead2f38a5f448ea1a669fcbbfa8469004b46f4d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 13:21:46 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 07 Mar 2024 08:21:46 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/sand-witch/fix-tysyn Message-ID: <65e9bf6a627dd_10117b4d43da8602ee@gitlab.mail> Andrei Borzenkov pushed new branch wip/sand-witch/fix-tysyn at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sand-witch/fix-tysyn You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 13:24:48 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 07 Mar 2024 08:24:48 -0500 Subject: [Git][ghc/ghc][wip/sand-witch/fix-tysyn] Fix compiler crash caused by implicit RHS quantification in type synonyms (24470) Message-ID: <65e9c020712a9_10117b519b824604fd@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/fix-tysyn at Glasgow Haskell Compiler / GHC Commits: 26fa4a3a by Andrei Borzenkov at 2024-03-07T17:24:28+04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (24470) - - - - - 9 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1911,6 +1911,11 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkSimpleDecorated $ + text "Type variable" <+> quotes (ppr tv_name) <+> + text "in the right-hand side of type synonym" <+> quotes (ppr ts_name) <+> + text "is out of arity" + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2543,6 +2548,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3209,6 +3216,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4263,6 +4265,23 @@ data TcRnMessage where -} TcRnNamespacedFixitySigWithoutFlag :: FixitySig GhcPs -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when an implicitly quantified + type variable on the RHS of a type synonym doesn't match the arity specified + by a user on the LHS of the type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,52 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Type signatures have special rule about scoping of the outmost kind signatures: + + type P = Proxy :: k -> Type + +Here `k` isn't bind anywhere, however GHC performs implicit binding in this +specific case, so the example above becomes equivalent to that declaration: + + type P @k = Proxy :: k -> Type + +Doing so changes arity of type synonym declaration and could be observed e.g. when +we use type synonym in high order position: + + type T :: (forall k. k -> Type) -> Type + + type P = Proxy + + x :: T P -- Expected kind ‘forall k. k -> *’, but ‘P’ has kind ‘k0 -> *’ + +To give user more control under arity of type declaration, we do not perform +airty inference in check mode (i.e. when type synonym has standalone kind signature) +starting from e89aa0721ca commit: + + type T :: (forall k. k -> Type) -> Type + + type P :: forall k. k -> Type + type P = Proxy + + x :: T P -- OK + +However, renamer still adds type variables from outmost kind signature into +scope (see #24470) because it doesn't have infromation about standalone kind +signature in the context: + + type P :: forall j. j -> Type + type P = Proxy :: k -> Type -- `k` is not in scope during type checking, + -- but it passed the renamer + +To handle this case, we add validation into `checkForDisconnectedScopedTyVars` function. +Notice that an implicit binding isn't a problem itself, but becomes a problem when +it's out of specified arity of type synonym, i.e. this code is fine: + + type P :: forall j. j -> Type + type P @j = Proxy :: k -> Type -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -605,6 +605,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -911,3 +911,4 @@ test('T22788', normal, compile, ['']) test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,4 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • Type variable ‘j’ in the right-hand side of type synonym ‘SynBad’ is out of arity + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -721,3 +721,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26fa4a3a8be8f2ab10d606670ba2980dcfd119e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26fa4a3a8be8f2ab10d606670ba2980dcfd119e8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 13:26:23 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Thu, 07 Mar 2024 08:26:23 -0500 Subject: [Git][ghc/ghc][wip/T23942] small fixes and improvements Message-ID: <65e9c07f1fc7f_10117b5435c38622fb@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 438278dd by Matthew Craven at 2024-03-07T08:25:18-05:00 small fixes and improvements - - - - - 5 changed files: - compiler/GHC/CoreToStg/Prep.hs - libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs - libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -2484,7 +2484,29 @@ cpeBigNatLit env i = assert (i >= 0) $ do -- * A call to `newByteArray#` with the appropriate size -- * A call to `copyAddrToByteArray#` to initialize the `ByteArray#` -- * A call to `unsafeFreezeByteArray#` to make the types match - litAddrId <- newVar addrPrimTy + litAddrId <- mkSysLocalM (fsLit "bigNatGuts") ManyTy addrPrimTy + -- returned from newByteArray#: + deadNewByteArrayTupleId + <- fmap (`setIdOccInfo` IAmDead) . mkSysLocalM (fsLit "tup") ManyTy $ + mkTupleTy Unboxed [ realWorldStatePrimTy + , realWorldMutableByteArrayPrimTy + ] + stateTokenFromNewByteArrayId + <- mkSysLocalM (fsLit "token") ManyTy realWorldStatePrimTy + mutableByteArrayId + <- mkSysLocalM (fsLit "mba") ManyTy realWorldMutableByteArrayPrimTy + -- returned from copyAddrToByteArray#: + stateTokenFromCopyId + <- mkSysLocalM (fsLit "token") ManyTy realWorldStatePrimTy + -- returned from unsafeFreezeByteArray#: + deadFreezeTupleId + <- fmap (`setIdOccInfo` IAmDead) . mkSysLocalM (fsLit "tup") ManyTy $ + mkTupleTy Unboxed [realWorldStatePrimTy, byteArrayPrimTy] + stateTokenFromFreezeId + <- (`setIdOccInfo` IAmDead) <$> + mkSysLocalM (fsLit "token") ManyTy realWorldStatePrimTy + byteArrayId <- mkSysLocalM (fsLit "ba") ManyTy byteArrayPrimTy + let litAddrRhs = Lit (LitString words) -- not "mkLitString"; that does UTF-8 encoding, which we don't want here @@ -2498,13 +2520,6 @@ cpeBigNatLit env i = assert (i >= 0) $ do `App` contentsLength `App` Var realWorldPrimId - -- returned from newByteArray#: - deadNewByteArrayTupleId <- newVar $ - mkTupleTy Unboxed [realWorldStatePrimTy, realWorldMutableByteArrayPrimTy] - stateTokenFromNewByteArrayId <- newVar realWorldStatePrimTy - mutableByteArrayId <- newVar realWorldMutableByteArrayPrimTy - - let copyContentsCall = Var (primOpId CopyAddrToByteArrayOp) `App` Type realWorldTy @@ -2514,23 +2529,12 @@ cpeBigNatLit env i = assert (i >= 0) $ do `App` contentsLength `App` Var stateTokenFromNewByteArrayId - -- returned from copyAddrToByteArray#: - stateTokenFromCopyId <- newVar realWorldStatePrimTy - - let unsafeFreezeCall = Var (primOpId UnsafeFreezeByteArrayOp) `App` Type realWorldTy `App` Var mutableByteArrayId `App` Var stateTokenFromCopyId - -- returned from unsafeFreezeByteArray#: - deadFreezeTupleId <- newVar $ - mkTupleTy Unboxed [realWorldStatePrimTy, byteArrayPrimTy] - stateTokenFromFreezeId <- newVar realWorldStatePrimTy - byteArrayId <- newVar byteArrayPrimTy - - let unboxed2tuple_alt :: AltCon unboxed2tuple_alt = DataAlt (tupleDataCon Unboxed 2) ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs ===================================== @@ -24,7 +24,8 @@ import {-# SOURCE #-} GHC.Num.Natural import {-# SOURCE #-} GHC.Num.Integer -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base --- (we have a string literal) +-- (we use the empty tuple () and string literals) +import GHC.Tuple () import GHC.CString () default () ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs ===================================== @@ -31,7 +31,8 @@ import {-# SOURCE #-} GHC.Num.BigNat import {-# SOURCE #-} GHC.Num.Natural -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base --- (we have a string literal) +-- (we use the empty tuple () and string literals) +import GHC.Tuple () import GHC.CString () default () ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs ===================================== @@ -29,7 +29,8 @@ import GHC.Prim import GHC.Types -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base --- (we have a string literal) +-- (we use the empty tuple () and string literals) +import GHC.Tuple () import GHC.CString () default () ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -366,13 +366,13 @@ been built, otherwise compilation will fail with an error like this one: Use -v to see a list of the files searched for. To prevent such errors, we insist that if any boot library module X -implicitly depending on primitives in module Y, then the transitive +implicitly depends on primitives in module Y, then the transitive imports of X must include Y. Such implicit dependencies can be introduced in at least the following ways: W1: - Awkward dependencies on ghc-prim: + Awkward dependencies: * TypeRep metadata introduces references to GHC.Types in EVERY module. * A String literal introduces a reference to GHC.CString, for either unpackCString# or unpackCStringUtf8# depending on its contents. @@ -432,7 +432,7 @@ W4: as long as the module which defines Eq imports GHC.Magic this cannot cause trouble. - Embarrasingly, we do not follow this plan for the Lift class. + Embarrassingly, we do not follow this plan for the Lift class. Derived Lift instances refer to machinery in Language.Haskell.TH.Lib, which is not imported by the module Language.Haskell.TH.Syntax that defines the Lift class. This is still causing annoyance for boot @@ -471,8 +471,8 @@ This presents a problem. GHC.Internal.Base and GHC.Internal.Num. Enum is a superclass of Integral. We don't use any Enum methods here, but it is relevant (read on). -* Integral is defined in GHC.Real, which imports GHC.Base, GHC.Num, and - GHC.Enum. +* Integral is defined in GHC.Internal.Real, which imports + GHC.Internal.Base, GHC.Internal.Num, and GHC.Internal.Enum. We resolve this web of dependencies with hs-boot files. The rules https://ghc.gitlab.haskell.org/ghc/doc/users_guide/separate_compilation.html#how-to-compile-mutually-recursive-modules View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/438278dd05e17598384b5bd74c930ad1747317a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/438278dd05e17598384b5bd74c930ad1747317a9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 13:48:32 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 07 Mar 2024 08:48:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: rts: expose HeapAlloc.h as public header Message-ID: <65e9c5b043a4f_10117b5a90c68705b4@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - 4d2878c5 by Ben Gamari at 2024-03-07T08:48:27-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - bc6d3a0d by Cheng Shao at 2024-03-07T08:48:27-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Monad.hs - libraries/base/src/Control/Monad/ST.hs - libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/IO/Encoding/UTF16.hs - libraries/base/src/GHC/TypeNats.hs - libraries/base/src/System/Console/GetOpt.hs - libraries/base/src/System/IO.hs - libraries/base/src/System/Mem/Weak.hs - libraries/base/src/System/Posix/Internals.hs - libraries/base/src/Text/ParserCombinators/ReadP.hs - libraries/base/src/Text/ParserCombinators/ReadPrec.hs - libraries/base/src/Text/Read.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/Sparks.c - rts/include/rts/storage/Block.h - rts/sm/HeapAlloc.h → rts/include/rts/storage/HeapAlloc.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a1dd7cba418cf0866db91cd81fa45f2445c93ec...bc6d3a0de722e1080b0e7aa916fe9ba1ea332e64 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a1dd7cba418cf0866db91cd81fa45f2445c93ec...bc6d3a0de722e1080b0e7aa916fe9ba1ea332e64 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 13:55:59 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 08:55:59 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 2 commits: rts: Drop .wasm suffix from .prof file names Message-ID: <65e9c76fc072a_10117b5ea1c807904c@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 30ca8bdf by Ben Gamari at 2024-03-06T23:49:36-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 2efba97d by Ben Gamari at 2024-03-06T23:49:54-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 5 changed files: - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/include/rts/storage/ClosureMacros.h Changes: ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasi32_HOST_OS) + dropExtension(prog, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasi32_HOST_OS) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.hp.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6054b425e2bde8c246ca9a8d59b3c5bbfc39d23...2efba97d84ce32d50dd48a41955bcb2753b0e186 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6054b425e2bde8c246ca9a8d59b3c5bbfc39d23...2efba97d84ce32d50dd48a41955bcb2753b0e186 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 14:06:35 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 09:06:35 -0500 Subject: [Git][ghc/ghc][wip/data-kind] ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65e9c9ebe3eee_10117b69563d8818e7@gitlab.mail> Ben Gamari pushed to branch wip/data-kind at Glasgow Haskell Compiler / GHC Commits: 30f59e76 by Ben Gamari at 2024-03-07T09:06:24-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 6 changed files: - libraries/base/src/Data/Kind.hs - libraries/ghc-internal/ghc-internal.cabal - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/src/Data/Kind.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} -- | -- @@ -19,4 +19,6 @@ module Data.Kind FUN ) where -import GHC.Internal.Data.Kind \ No newline at end of file +import GHC.Num.BigNat () -- for build ordering (#23942) +import GHC.Prim (FUN) +import GHC.Types (Type, Constraint) ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -120,7 +120,6 @@ Library GHC.Internal.Data.Functor.Utils GHC.Internal.Data.IORef GHC.Internal.Data.Ix - GHC.Internal.Data.Kind GHC.Internal.Data.List GHC.Internal.Data.Maybe GHC.Internal.Data.Monoid ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1238,7 +1238,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1238,7 +1238,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1238,7 +1238,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1238,7 +1238,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30f59e76f6864b2ca02ea2ec5deb2fd93de06b0b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30f59e76f6864b2ca02ea2ec5deb2fd93de06b0b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 14:24:56 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 07 Mar 2024 09:24:56 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 13 commits: Read global package database from settings file Message-ID: <65e9ce389bede_10117b6f7482887566@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 5d441f0a by Matthew Pickering at 2024-03-05T10:57:55+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 8e3cb48c by Matthew Pickering at 2024-03-05T10:58:29+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 69a784c5 by Matthew Pickering at 2024-03-05T10:58:30+00:00 Add missing req_interp modifier to T18441fail3 and T18441fail19 These tests require the interpreter but they were failing in a different way with the javascript backend because the interpreter was disabled and stderr is ignored by the test. - - - - - 6f5a6e84 by Matthew Pickering at 2024-03-05T10:58:30+00:00 Use explicit syntax rather than pure - - - - - f41941e2 by Matthew Pickering at 2024-03-05T10:58:30+00:00 ci: Fail when bindist configure fails when installing bindist It is better to fail earlier if the configure step fails rather than carrying on for a more obscure error message. - - - - - 18d982b3 by Matthew Pickering at 2024-03-05T10:58:30+00:00 packaging: correctly propagate build/host/target to bindist configure script At the moment the host and target which we will produce a compiler for is fixed at the initial configure time. Therefore we need to persist the choice made at this time into the installation bindist as well so we look for the right tools, with the right prefixes at install time. In the future, we want to provide a bit more control about what kind of bindist we produce so the logic about what the host/target will have to be written by hadrian rather than persisted by the configure script. In particular with cross compilers we want to either build a normal stage 2 cross bindist or a stage 3 bindist, which creates a bindist which has a native compiler for the target platform. Fixes #21970 - - - - - 5d495163 by Matthew Pickering at 2024-03-05T10:58:31+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - a6b154ea by Matthew Pickering at 2024-03-05T10:58:31+00:00 hadrian: Disable docs when cross compiling Before there were a variety of ad-hoc places where doc building was disabled when cross compiling. * Some CI jobs sets --docs=none in gen_ci.hs * Some CI jobs set --docs=none in .gitlab/ci.sh * There was some logic in hadrian to not need the ["docs"] target when making a bindist. Now the situation is simple: * If you are cross compiling then defaultDocsTargets is empty by default. In theory, there is no reason why we can't build documentation for cross compiler bindists, but this is left to future work to generalise the documentation building rules to allow this (#24289) - - - - - af1c68f1 by Matthew Pickering at 2024-03-05T10:58:31+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 9061af22 by Matthew Pickering at 2024-03-05T10:58:31+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - e0c65d20 by Matthew Pickering at 2024-03-05T10:58:31+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 5788d3d8 by Matthew Pickering at 2024-03-05T10:58:31+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - effc3666 by Matthew Pickering at 2024-03-07T14:17:22+00:00 Split up system.config into host/target config files There were a number of settings which were not applied per-stage, for example if you specified `--ffi-include-dir` then that was applied to both host and target. Now this will just be passed when building the crosscompiler. The solution for now is to separate these two files into host/target and the host file contains very bare-bones . There isn't currently a way to specify with configure anything in the host file, so if you are building a cross-compiler and you need to do that, you have to modify the file yourself. - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/system.config.in - hadrian/hadrian.cabal - hadrian/src/Base.hs - + hadrian/src/BindistConfig.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Expression.hs - hadrian/src/Hadrian/Haskell/Hash.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Flavour.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/CabalReinstall.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69d8b51b500b8b879413feb552c1b7bd9125e120...effc3666a001efbf9f8e9c9c0416a7b4573f52ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69d8b51b500b8b879413feb552c1b7bd9125e120...effc3666a001efbf9f8e9c9c0416a7b4573f52ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 14:46:07 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 07 Mar 2024 09:46:07 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Split up system.config into host/target config files Message-ID: <65e9d32f92dec_10117b7b456ac902b1@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 9b09bf12 by Matthew Pickering at 2024-03-07T14:45:52+00:00 Split up system.config into host/target config files There were a number of settings which were not applied per-stage, for example if you specified `--ffi-include-dir` then that was applied to both host and target. Now this will just be passed when building the crosscompiler. The solution for now is to separate these two files into host/target and the host file contains very bare-bones . There isn't currently a way to specify with configure anything in the host file, so if you are building a cross-compiler and you need to do that, you have to modify the file yourself. - - - - - 22 changed files: - configure.ac - + hadrian/cfg/system.config.host.in - hadrian/cfg/system.config.in - + hadrian/cfg/system.config.target.in - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Expression.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Rts.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Common.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Builders/Hsc2Hs.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Packages.hs - hadrian/src/Settings/Warnings.hs Changes: ===================================== configure.ac ===================================== @@ -976,6 +976,8 @@ FIND_GHC_TOOLCHAIN([hadrian/cfg]) AC_CONFIG_FILES( [ mk/project.mk hadrian/cfg/system.config + hadrian/cfg/system.config.host + hadrian/cfg/system.config.target hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack ===================================== hadrian/cfg/system.config.host.in ===================================== @@ -0,0 +1,77 @@ +# This file is processed by the configure script. +# See hadrian/src/UserSettings.hs for user-defined settings. +#=========================================================== + +# Paths to builders: +#=================== + +# Information about builders: +#============================ + +cc-llvm-backend = NO + + +# Information about build, host and target systems: +#================================================== + +dynamic-extension = .so + +bootstrap-threaded-rts = YES + +# Settings: +#========== + +# We are in the process of moving the settings file from being entirely +# generated by configure, to generated being by the build system. Many of these +# might become redundant. +# See Note [tooldir: How GHC finds mingw on Windows] + +settings-otool-command = otool +settings-install_name_tool-command = install_name_tool +settings-llc-command = llc +settings-opt-command = opt +settings-llvm-as-command = clang +settings-use-distro-mingw = NO + +target-has-libm = YES + +# Include and library directories: +#================================= + +curses-lib-dir = +curses-include-dir = + +iconv-include-dir = +iconv-lib-dir = + +intree-gmp = NO +gmp-framework-preferred = NO +gmp-include-dir = +gmp-lib-dir = + +use-system-ffi = NO +ffi-include-dir = +ffi-lib-dir = + +libdw-include-dir = +libdw-lib-dir = + +libnuma-include-dir = +libnuma-lib-dir = + +libzstd-include-dir = +libzstd-lib-dir = + +# Optional Dependencies: +#======================= + +use-lib-dw = NO +use-lib-zstd = NO +static-lib-zstd = NO +use-lib-numa = NO +use-lib-m = YES +use-lib-rt = YES +use-lib-dl = YES +use-lib-bfd = NO +use-lib-pthread = NO +need-libatomic = NO ===================================== hadrian/cfg/system.config.in ===================================== @@ -32,8 +32,6 @@ python = @PythonCmd@ # Information about builders: #============================ -cc-llvm-backend = @CcLlvmBackend@ - llvm-min-version = @LlvmMinVersion@ llvm-max-version = @LlvmMaxVersion@ @@ -54,8 +52,6 @@ target-platform-full = @TargetPlatformFull@ cross-compiling = @CrossCompiling@ -dynamic-extension = @soext_target@ - ghc-version = @GhcVersion@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ @@ -72,60 +68,3 @@ project-patch-level1 = @ProjectPatchLevel1@ project-patch-level2 = @ProjectPatchLevel2@ project-git-commit-id = @ProjectGitCommitId@ -# Settings: -#========== - -# We are in the process of moving the settings file from being entirely -# generated by configure, to generated being by the build system. Many of these -# might become redundant. -# See Note [tooldir: How GHC finds mingw on Windows] - -settings-otool-command = @SettingsOtoolCommand@ -settings-install_name_tool-command = @SettingsInstallNameToolCommand@ -settings-llc-command = @SettingsLlcCommand@ -settings-opt-command = @SettingsOptCommand@ -settings-llvm-as-command = @SettingsLlvmAsCommand@ -settings-use-distro-mingw = @SettingsUseDistroMINGW@ - -target-has-libm = @TargetHasLibm@ - -# Include and library directories: -#================================= - -curses-lib-dir = @CURSES_LIB_DIRS@ -curses-include-dir = @CURSES_INCLUDE_DIRS@ - -iconv-include-dir = @ICONV_INCLUDE_DIRS@ -iconv-lib-dir = @ICONV_LIB_DIRS@ - -intree-gmp = @GMP_FORCE_INTREE@ -gmp-framework-preferred = @GMP_PREFER_FRAMEWORK@ -gmp-include-dir = @GMP_INCLUDE_DIRS@ -gmp-lib-dir = @GMP_LIB_DIRS@ - -use-system-ffi = @UseSystemLibFFI@ -ffi-include-dir = @FFIIncludeDir@ -ffi-lib-dir = @FFILibDir@ - -libdw-include-dir = @LibdwIncludeDir@ -libdw-lib-dir = @LibdwLibDir@ - -libnuma-include-dir = @LibNumaIncludeDir@ -libnuma-lib-dir = @LibNumaLibDir@ - -libzstd-include-dir = @LibZstdIncludeDir@ -libzstd-lib-dir = @LibZstdLibDir@ - -# Optional Dependencies: -#======================= - -use-lib-dw = @UseLibdw@ -use-lib-zstd = @UseLibZstd@ -static-lib-zstd = @UseStaticLibZstd@ -use-lib-numa = @UseLibNuma@ -use-lib-m = @UseLibm@ -use-lib-rt = @UseLibrt@ -use-lib-dl = @UseLibdl@ -use-lib-bfd = @UseLibbfd@ -use-lib-pthread = @UseLibpthread@ -need-libatomic = @NeedLibatomic@ ===================================== hadrian/cfg/system.config.target.in ===================================== @@ -0,0 +1,83 @@ +# This file is processed by the configure script. +# See hadrian/src/UserSettings.hs for user-defined settings. +#=========================================================== + +# Paths to builders: +#=================== + +# Information about builders: +#============================ + +cc-llvm-backend = @CcLlvmBackend@ + + +# Information about build, host and target systems: +#================================================== + +# Q: Is the *-platform information available in the target? +# A: Yes, it is. We pass @BuildPlatform@ and @HostPlatform@ and @TargetPlatform@ to ghc-toolchain using --target=that +# And we can reconstruct the platform info using targetPlatformTriple +# Q: What is TargetPlatformFull? +target-platform-full = @TargetPlatformFull@ + +dynamic-extension = @soext_target@ + +bootstrap-threaded-rts = @GhcThreadedRts@ + +# Settings: +#========== + +# We are in the process of moving the settings file from being entirely +# generated by configure, to generated being by the build system. Many of these +# might become redundant. +# See Note [tooldir: How GHC finds mingw on Windows] + +settings-otool-command = @SettingsOtoolCommand@ +settings-install_name_tool-command = @SettingsInstallNameToolCommand@ +settings-llc-command = @SettingsLlcCommand@ +settings-opt-command = @SettingsOptCommand@ +settings-llvm-as-command = @SettingsLlvmAsCommand@ +settings-use-distro-mingw = @SettingsUseDistroMINGW@ + +target-has-libm = @TargetHasLibm@ + +# Include and library directories: +#================================= + +curses-lib-dir = @CURSES_LIB_DIRS@ +curses-include-dir = @CURSES_INCLUDE_DIRS@ + +iconv-include-dir = @ICONV_INCLUDE_DIRS@ +iconv-lib-dir = @ICONV_LIB_DIRS@ + +intree-gmp = @GMP_FORCE_INTREE@ +gmp-framework-preferred = @GMP_PREFER_FRAMEWORK@ +gmp-include-dir = @GMP_INCLUDE_DIRS@ +gmp-lib-dir = @GMP_LIB_DIRS@ + +use-system-ffi = @UseSystemLibFFI@ +ffi-include-dir = @FFIIncludeDir@ +ffi-lib-dir = @FFILibDir@ + +libdw-include-dir = @LibdwIncludeDir@ +libdw-lib-dir = @LibdwLibDir@ + +libnuma-include-dir = @LibNumaIncludeDir@ +libnuma-lib-dir = @LibNumaLibDir@ + +libzstd-include-dir = @LibZstdIncludeDir@ +libzstd-lib-dir = @LibZstdLibDir@ + +# Optional Dependencies: +#======================= + +use-lib-dw = @UseLibdw@ +use-lib-zstd = @UseLibZstd@ +static-lib-zstd = @UseStaticLibZstd@ +use-lib-numa = @UseLibNuma@ +use-lib-m = @UseLibm@ +use-lib-rt = @UseLibrt@ +use-lib-dl = @UseLibdl@ +use-lib-bfd = @UseLibbfd@ +use-lib-pthread = @UseLibpthread@ +need-libatomic = @NeedLibatomic@ ===================================== hadrian/src/Base.hs ===================================== @@ -29,7 +29,8 @@ module Base ( module Way, -- * Paths - hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, + hadrianPath, configPath, configFile, buildConfigFileHost, buildConfigFileTarget, + sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, ghcLibDeps, haddockDeps, @@ -80,6 +81,13 @@ configPath = hadrianPath -/- "cfg" configFile :: FilePath configFile = configPath -/- "system.config" +buildConfigFileHost :: FilePath +buildConfigFileHost = configPath -/- "system.config.host" + +buildConfigFileTarget :: FilePath +buildConfigFileTarget = configPath -/- "system.config.target" + + -- | The target configuration file generated by ghc-toolchain for the -- compilation build platform buildTargetFile :: FilePath ===================================== hadrian/src/Builder.hs ===================================== @@ -28,14 +28,13 @@ import Hadrian.Builder.Tar import Hadrian.Oracles.Path import Hadrian.Oracles.TextFile import Hadrian.Utilities -import Oracles.Setting (bashPath, targetStage) import System.Exit import System.IO (stderr) import Base import Context import Oracles.Flag -import Oracles.Setting (setting, Setting(..)) +import Oracles.Setting import Packages import GHC.IO.Encoding (getFileSystemEncoding) ===================================== hadrian/src/Expression.hs ===================================== @@ -146,7 +146,7 @@ buildingCompilerStage' f = f . succStage <$> getStage -- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] -- in Settings.Packages for details. threadedBootstrapper :: Predicate -threadedBootstrapper = expr (flag BootstrapThreadedRts) +threadedBootstrapper = staged (buildFlag BootstrapThreadedRts) -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -13,7 +13,7 @@ -- to read configuration or package metadata files and cache the parsing. ----------------------------------------------------------------------------- module Hadrian.Oracles.TextFile ( - lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig, lookupValues, + lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig, lookupHostBuildConfig, lookupTargetBuildConfig, lookupValues, lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies, textFileOracle, getBuildTarget, getHostTarget, getTargetTarget, queryBuildTarget, queryHostTarget @@ -52,6 +52,23 @@ lookupSystemConfig = lookupValueOrError (Just configError) configFile where configError = "Perhaps you need to rerun ./configure" +lookupHostBuildConfig :: String -> Action String +lookupHostBuildConfig key = do + cross <- (== "YES") <$> lookupSystemConfig "cross-compiling" + -- If we are not cross compiling, the build the host compiler like the target. + let cfgFile = if cross then buildConfigFileHost else buildConfigFileTarget + lookupValueOrError (Just configError) cfgFile key + where + configError = "Perhaps you need to rerun ./configure" + +lookupTargetBuildConfig :: String -> Action String +lookupTargetBuildConfig key = + lookupValueOrError (Just configError) buildConfigFileTarget key + where + configError = "Perhaps you need to rerun ./configure" + + + -- | Lookup a list of values in a text file, tracking the result. Each line of -- the file is expected to have @key value1 value2 ...@ format. lookupValues :: FilePath -> String -> Action (Maybe [String]) @@ -104,6 +121,7 @@ getHostTarget = do -- MP: If we are not cross compiling then we should use the target file in order to -- build things for the host, in particular we want to use the configured values for the -- target for building the RTS (ie are we using Libffi for adjustors, and the wordsize) + -- TODO: Use "flag CrossCompiling" ht <- getTargetConfig hostTargetFile tt <- getTargetConfig targetTargetFile if (Toolchain.targetPlatformTriple ht) == (Toolchain.targetPlatformTriple tt) ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -2,6 +2,7 @@ module Oracles.Flag ( Flag (..), flag, getFlag, + BuildFlag(..), buildFlag, targetSupportsSharedLibs, targetSupportsGhciObjects, targetSupportsThreadedRts, @@ -22,7 +23,8 @@ import qualified GHC.Toolchain as Toolchain import GHC.Platform.ArchOS data Flag = CrossCompiling - | CcLlvmBackend + | UseGhcToolchain +data BuildFlag = CcLlvmBackend | GmpInTree | GmpFrameworkPref | UseSystemFfi @@ -38,7 +40,15 @@ data Flag = CrossCompiling | UseLibbfd | UseLibpthread | NeedLibatomic - | UseGhcToolchain + | TargetHasLibm + +parseFlagResult :: String -> String -> Bool +parseFlagResult key value = + if (value `notElem` ["YES", "NO", ""]) + then error $ "Configuration flag " + ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." + else value == "YES" + -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this. @@ -46,6 +56,12 @@ flag :: Flag -> Action Bool flag f = do let key = case f of CrossCompiling -> "cross-compiling" + UseGhcToolchain -> "use-ghc-toolchain" + parseFlagResult key <$> lookupSystemConfig key + +buildFlag :: BuildFlag -> Stage -> Action Bool +buildFlag f st = + let key = case f of CcLlvmBackend -> "cc-llvm-backend" GmpInTree -> "intree-gmp" GmpFrameworkPref -> "gmp-framework-preferred" @@ -62,11 +78,13 @@ flag f = do UseLibbfd -> "use-lib-bfd" UseLibpthread -> "use-lib-pthread" NeedLibatomic -> "need-libatomic" - UseGhcToolchain -> "use-ghc-toolchain" - value <- lookupSystemConfig key - when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " - ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." - return $ value == "YES" + TargetHasLibm -> "target-has-libm" + in parseFlagResult key <$> (tgtConfig st key) + where + tgtConfig Stage0 {} = lookupHostBuildConfig + tgtConfig Stage1 = lookupHostBuildConfig + tgtConfig Stage2 = lookupTargetBuildConfig + tgtConfig Stage3 = lookupTargetBuildConfig -- | Get a configuration setting. getFlag :: Flag -> Expr c b Bool ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -1,7 +1,8 @@ module Oracles.Setting ( configFile, -- * Settings - Setting (..), setting, getSetting, + ProjectSetting (..), setting, getSetting, + BuildSetting(..), buildSetting, ToolchainSetting (..), settingsFileSetting, -- * Helpers @@ -39,28 +40,14 @@ import GHC.Platform.ArchOS -- tracking the result in the Shake database. -- -- * ROMES:TODO: How to handle target-platform-full? -data Setting = CursesIncludeDir - | CursesLibDir - | DynamicExtension - | FfiIncludeDir - | FfiLibDir - | GhcMajorVersion +data ProjectSetting = + GhcMajorVersion | GhcMinorVersion | GhcPatchLevel | GhcVersion | GhcSourcePath | LlvmMinVersion | LlvmMaxVersion - | GmpIncludeDir - | GmpLibDir - | IconvIncludeDir - | IconvLibDir - | LibdwIncludeDir - | LibdwLibDir - | LibnumaIncludeDir - | LibnumaLibDir - | LibZstdIncludeDir - | LibZstdLibDir | ProjectGitCommitId | ProjectName | ProjectVersion @@ -73,6 +60,25 @@ data Setting = CursesIncludeDir | TargetPlatformFull | BourneShell + +-- Things which configure how a specific stage is built +data BuildSetting = + CursesIncludeDir + | CursesLibDir + | DynamicExtension + | FfiIncludeDir + | FfiLibDir + | GmpIncludeDir + | GmpLibDir + | IconvIncludeDir + | IconvLibDir + | LibdwIncludeDir + | LibdwLibDir + | LibnumaIncludeDir + | LibnumaLibDir + | LibZstdIncludeDir + | LibZstdLibDir + -- TODO compute solely in Hadrian, removing these variables' definitions -- from aclocal.m4 whenever they can be calculated from other variables -- already fed into Hadrian. @@ -93,13 +99,8 @@ data ToolchainSetting -- | Look up the value of a 'Setting' in @cfg/system.config@, tracking the -- result. -setting :: Setting -> Action String +setting :: ProjectSetting -> Action String setting key = lookupSystemConfig $ case key of - CursesIncludeDir -> "curses-include-dir" - CursesLibDir -> "curses-lib-dir" - DynamicExtension -> "dynamic-extension" - FfiIncludeDir -> "ffi-include-dir" - FfiLibDir -> "ffi-lib-dir" GhcMajorVersion -> "ghc-major-version" GhcMinorVersion -> "ghc-minor-version" GhcPatchLevel -> "ghc-patch-level" @@ -107,16 +108,6 @@ setting key = lookupSystemConfig $ case key of GhcSourcePath -> "ghc-source-path" LlvmMinVersion -> "llvm-min-version" LlvmMaxVersion -> "llvm-max-version" - GmpIncludeDir -> "gmp-include-dir" - GmpLibDir -> "gmp-lib-dir" - IconvIncludeDir -> "iconv-include-dir" - IconvLibDir -> "iconv-lib-dir" - LibdwIncludeDir -> "libdw-include-dir" - LibdwLibDir -> "libdw-lib-dir" - LibnumaIncludeDir -> "libnuma-include-dir" - LibnumaLibDir -> "libnuma-lib-dir" - LibZstdIncludeDir -> "libzstd-include-dir" - LibZstdLibDir -> "libzstd-lib-dir" ProjectGitCommitId -> "project-git-commit-id" ProjectName -> "project-name" ProjectVersion -> "project-version" @@ -129,22 +120,51 @@ setting key = lookupSystemConfig $ case key of TargetPlatformFull -> "target-platform-full" BourneShell -> "bourne-shell" +buildSetting :: BuildSetting -> Stage -> Action String +buildSetting key stage = tgtConfig stage $ case key of + CursesIncludeDir -> "curses-include-dir" + CursesLibDir -> "curses-lib-dir" + DynamicExtension -> "dynamic-extension" + FfiIncludeDir -> "ffi-include-dir" + FfiLibDir -> "ffi-lib-dir" + GmpIncludeDir -> "gmp-include-dir" + GmpLibDir -> "gmp-lib-dir" + IconvIncludeDir -> "iconv-include-dir" + IconvLibDir -> "iconv-lib-dir" + LibdwIncludeDir -> "libdw-include-dir" + LibdwLibDir -> "libdw-lib-dir" + LibnumaIncludeDir -> "libnuma-include-dir" + LibnumaLibDir -> "libnuma-lib-dir" + LibZstdIncludeDir -> "libzstd-include-dir" + LibZstdLibDir -> "libzstd-lib-dir" + where + tgtConfig Stage0 {} = lookupHostBuildConfig + tgtConfig Stage1 = lookupHostBuildConfig + tgtConfig Stage2 = lookupTargetBuildConfig + tgtConfig Stage3 = lookupTargetBuildConfig + + -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the -- result. -- See Note [tooldir: How GHC finds mingw on Windows] -- ROMES:TODO: This should be queryTargetTargetConfig -settingsFileSetting :: ToolchainSetting -> Action String -settingsFileSetting key = lookupSystemConfig $ case key of +settingsFileSetting :: ToolchainSetting -> Stage -> Action String +settingsFileSetting key stage = tgtConfig stage $ case key of ToolchainSetting_OtoolCommand -> "settings-otool-command" ToolchainSetting_InstallNameToolCommand -> "settings-install_name_tool-command" ToolchainSetting_LlcCommand -> "settings-llc-command" ToolchainSetting_OptCommand -> "settings-opt-command" ToolchainSetting_LlvmAsCommand -> "settings-llvm-as-command" ToolchainSetting_DistroMinGW -> "settings-use-distro-mingw" -- ROMES:TODO: This option doesn't seem to be in ghc-toolchain yet. It corresponds to EnableDistroToolchain + where + tgtConfig Stage0 {} = lookupHostBuildConfig + tgtConfig Stage1 = lookupHostBuildConfig + tgtConfig Stage2 = lookupTargetBuildConfig + tgtConfig Stage3 = lookupTargetBuildConfig -- | An expression that looks up the value of a 'Setting' in @cfg/system.config@, -- tracking the result. -getSetting :: Setting -> Expr c b String +getSetting :: ProjectSetting -> Expr c b String getSetting = expr . setting -- | The path to a Bourne shell interpreter. @@ -247,7 +267,7 @@ libsuf :: Stage -> Way -> Action String libsuf st way | not (wayUnit Dynamic way) = return (waySuffix way ++ ".a") -- e.g., _p.a | otherwise = do - extension <- setting DynamicExtension -- e.g., .dll or .so + extension <- buildSetting DynamicExtension st-- e.g., .dll or .so version <- ghcVersionStage st -- e.g. 8.4.4 or 8.9.xxxx let suffix = waySuffix (removeWayUnit Dynamic way) return (suffix ++ "-ghc" ++ version ++ extension) ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -10,7 +10,7 @@ module Oracles.TestSettings import Base import Hadrian.Oracles.TextFile -import Oracles.Setting (topDirectory, setting, Setting(..), crossStage) +import Oracles.Setting (topDirectory, setting, ProjectSetting(..), crossStage) import Packages import Settings.Program (programContext) import Hadrian.Oracles.Path ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -10,7 +10,6 @@ import qualified Data.Set as Set import Base import qualified Context import Expression -import Hadrian.Oracles.TextFile (lookupSystemConfig) import Oracles.Flag hiding (arSupportsAtFile, arSupportsDashL) import Oracles.ModuleFiles import Oracles.Setting @@ -49,10 +48,9 @@ ghcPrimDependencies = do rtsDependencies :: Expr [FilePath] rtsDependencies = do - stage <- getStage - rtsPath <- expr (rtsBuildPath stage) - jsTarget <- expr (isJsTarget stage) - useSystemFfi <- expr (flag UseSystemFfi) + rtsPath <- staged rtsBuildPath + jsTarget <- staged isJsTarget + useSystemFfi <- staged (buildFlag UseSystemFfi) let -- headers common to native and JS RTS common_headers = @@ -276,7 +274,7 @@ runInterpolations (Interpolations mk_substs) input = do return (subst input) -- | Interpolate the given variable with the value of the given 'Setting'. -interpolateSetting :: String -> Setting -> Interpolations +interpolateSetting :: String -> ProjectSetting -> Interpolations interpolateSetting name settng = interpolateVar name $ setting settng -- | Interpolate the @ProjectVersion@ and @ProjectVersionMunged@ variables. @@ -401,8 +399,8 @@ generateSettings settingsFile = do , ("ar supports at file", queryTarget stage arSupportsAtFile') , ("ar supports -L", queryTarget stage arSupportsDashL') , ("ranlib command", queryTarget stage ranlibPath) - , ("otool command", expr $ settingsFileSetting ToolchainSetting_OtoolCommand) - , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) + , ("otool command", staged $ settingsFileSetting ToolchainSetting_OtoolCommand) + , ("install_name_tool command", staged $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("windres command", queryTarget stage (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit, Context.stage = predStage stage }))) , ("cross compiling", expr $ yesNo <$> crossStage (predStage stage)) @@ -414,13 +412,13 @@ generateSettings settingsFile = do , ("target has GNU nonexec stack", queryTarget stage (yesNo . Toolchain.tgtSupportsGnuNonexecStack)) , ("target has .ident directive", queryTarget stage (yesNo . Toolchain.tgtSupportsIdentDirective)) , ("target has subsections via symbols", queryTarget stage (yesNo . Toolchain.tgtSupportsSubsectionsViaSymbols)) - , ("target has libm", expr $ lookupSystemConfig "target-has-libm") + , ("target has libm", yesNo <$> staged (buildFlag TargetHasLibm)) , ("Unregisterised", queryTarget stage (yesNo . tgtUnregisterised)) , ("LLVM target", queryTarget stage tgtLlvmTarget) - , ("LLVM llc command", expr $ settingsFileSetting ToolchainSetting_LlcCommand) - , ("LLVM opt command", expr $ settingsFileSetting ToolchainSetting_OptCommand) - , ("LLVM llvm-as command", expr $ settingsFileSetting ToolchainSetting_LlvmAsCommand) - , ("Use inplace MinGW toolchain", expr $ settingsFileSetting ToolchainSetting_DistroMinGW) + , ("LLVM llc command", staged $ settingsFileSetting ToolchainSetting_LlcCommand) + , ("LLVM opt command", staged $ settingsFileSetting ToolchainSetting_OptCommand) + , ("LLVM llvm-as command", staged $ settingsFileSetting ToolchainSetting_LlvmAsCommand) + , ("Use inplace MinGW toolchain", staged $ settingsFileSetting ToolchainSetting_DistroMinGW) , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter stage) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP stage) @@ -428,7 +426,7 @@ generateSettings settingsFile = do , ("Tables next to code", queryTarget stage (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget stage (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> targetUseLibffiForAdjustors stage) - , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("RTS expects libdw", yesNo <$> staged (buildFlag UseLibdw)) , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" ===================================== hadrian/src/Rules/Gmp.hs ===================================== @@ -17,7 +17,7 @@ import Settings.Builders.Common (cArgs, getStagedCCFlags) -- their paths. gmpObjects :: Stage -> Action [FilePath] gmpObjects s = do - isInTree <- flag GmpInTree + isInTree <- buildFlag GmpInTree s if not isInTree then return [] else do @@ -65,8 +65,9 @@ gmpRules = do packageP = takeDirectory buildP librariesP = takeDirectory packageP stageP = takeDirectory librariesP + stage <- parsePath parseStage "" (takeFileName stageP) - isInTree <- flag GmpInTree + isInTree <- buildFlag GmpInTree stage if isInTree then do ===================================== hadrian/src/Rules/Libffi.hs ===================================== @@ -87,7 +87,7 @@ libffiContext stage = do -- | The name of the library libffiName :: Expr String libffiName = do - useSystemFfi <- expr (flag UseSystemFfi) + useSystemFfi <- staged (buildFlag UseSystemFfi) if useSystemFfi then pure "ffi" else libffiLocalName Nothing @@ -118,8 +118,8 @@ libffiHeaderDir stage = do path <- libffiBuildPath stage return $ path -/- "inst/include" -libffiSystemHeaderDir :: Action FilePath -libffiSystemHeaderDir = setting FfiIncludeDir +libffiSystemHeaderDir :: Stage -> Action FilePath +libffiSystemHeaderDir = buildSetting FfiIncludeDir fixLibffiMakefile :: FilePath -> String -> String fixLibffiMakefile top = ===================================== hadrian/src/Rules/Rts.hs ===================================== @@ -53,9 +53,9 @@ withLibffi stage action = needLibffi stage -- See Note [Packaging libffi headers] in GHC.Driver.CodeOutput. copyLibffiHeader :: Stage -> FilePath -> Action () copyLibffiHeader stage header = do - useSystemFfi <- flag UseSystemFfi + useSystemFfi <- buildFlag UseSystemFfi stage (fromStr, headerDir) <- if useSystemFfi - then ("system",) <$> libffiSystemHeaderDir + then ("system",) <$> libffiSystemHeaderDir stage else needLibffi stage >> ("custom",) <$> libffiHeaderDir stage copyFile @@ -122,7 +122,7 @@ rtsLibffiLibrary stage way = do needRtsLibffiTargets :: Stage -> Action [FilePath] needRtsLibffiTargets stage = do rtsPath <- rtsBuildPath stage - useSystemFfi <- flag UseSystemFfi + useSystemFfi <- buildFlag UseSystemFfi stage jsTarget <- isJsTarget stage -- Header files (in the rts build dir). ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -199,11 +199,11 @@ configureArgs cFlags' ldFlags' = do mconcat [ conf "CFLAGS" cFlags , conf "LDFLAGS" ldFlags - , conf "--with-iconv-includes" $ arg =<< getSetting IconvIncludeDir - , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir - , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir - , conf "--with-gmp-libraries" $ arg =<< getSetting GmpLibDir - , conf "--with-curses-libraries" $ arg =<< getSetting CursesLibDir + , conf "--with-iconv-includes" $ arg =<< staged (buildSetting IconvIncludeDir) + , conf "--with-iconv-libraries" $ arg =<< staged (buildSetting IconvLibDir) + , conf "--with-gmp-includes" $ arg =<< staged (buildSetting GmpIncludeDir) + , conf "--with-gmp-libraries" $ arg =<< staged (buildSetting GmpLibDir) + , conf "--with-curses-libraries" $ arg =<< staged (buildSetting CursesLibDir) , conf "--host" $ arg =<< flip queryTarget targetPlatformTriple . predStage' =<< getStage , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage , ghcVersionH ===================================== hadrian/src/Settings/Builders/Common.hs ===================================== @@ -51,9 +51,9 @@ cppArgs = mempty cWarnings :: Args cWarnings = mconcat [ arg "-Wall" - , flag CcLlvmBackend ? arg "-Wno-unknown-pragmas" - , notM (flag CcLlvmBackend) ? not windowsHost ? arg "-Werror=unused-but-set-variable" - , notM (flag CcLlvmBackend) ? arg "-Wno-error=inline" ] + , staged (buildFlag CcLlvmBackend) ? arg "-Wno-unknown-pragmas" + , notM (staged (buildFlag CcLlvmBackend)) ? not windowsHost ? arg "-Werror=unused-but-set-variable" + , notM (staged (buildFlag CcLlvmBackend)) ? arg "-Wno-error=inline" ] packageDatabaseArgs :: Args packageDatabaseArgs = do ===================================== hadrian/src/Settings/Builders/Ghc.hs ===================================== @@ -103,7 +103,7 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do st <- getStage distDir <- expr (Context.distDir st) - useSystemFfi <- expr (flag UseSystemFfi) + useSystemFfi <- staged (buildFlag UseSystemFfi) buildPath <- getBuildPath libffiName' <- libffiName debugged <- buildingCompilerStage' . ghcDebugged =<< expr flavour ===================================== hadrian/src/Settings/Builders/Hsc2Hs.hs ===================================== @@ -12,7 +12,7 @@ hsc2hsBuilderArgs :: Args hsc2hsBuilderArgs = builder Hsc2Hs ? do stage <- getStage ccPath <- getBuilderPath $ Cc CompileC stage - gmpDir <- getSetting GmpIncludeDir + gmpDir <- staged (buildSetting GmpIncludeDir) top <- expr topDirectory hArch <- queryHost queryArch hOs <- queryHost queryOS ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -114,7 +114,7 @@ inTreeCompilerArgs stg = do platform <- queryTargetTarget ghcStage targetPlatformTriple wordsize <- show @Int . (*8) <$> queryTargetTarget ghcStage (wordSize2Bytes . tgtWordSize) - llc_cmd <- settingsFileSetting ToolchainSetting_LlcCommand + llc_cmd <- settingsFileSetting ToolchainSetting_LlcCommand ghcStage have_llvm <- liftIO (isJust <$> findExecutable llc_cmd) top <- topDirectory ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -30,10 +30,10 @@ packageArgs = do compilerStageOption f = buildingCompilerStage' . f =<< expr flavour - cursesIncludeDir <- getSetting CursesIncludeDir - cursesLibraryDir <- getSetting CursesLibDir - ffiIncludeDir <- getSetting FfiIncludeDir - ffiLibraryDir <- getSetting FfiLibDir + cursesIncludeDir <- staged (buildSetting CursesIncludeDir) + cursesLibraryDir <- staged (buildSetting CursesLibDir) + ffiIncludeDir <- staged (buildSetting FfiIncludeDir) + ffiLibraryDir <- staged (buildSetting FfiLibDir) stageVersion <- readVersion <$> (expr $ ghcVersionStage stage) mconcat @@ -80,13 +80,13 @@ packageArgs = do [ andM [expr (ghcWithInterpreter stage), notStage0] `cabalFlag` "internal-interpreter" , notM cross `cabalFlag` "terminfo" , arg "-build-tool-depends" - , flag UseLibzstd `cabalFlag` "with-libzstd" + , staged (buildFlag UseLibzstd) `cabalFlag` "with-libzstd" -- ROMES: While the boot compiler is not updated wrt -this-unit-id -- not being fixed to `ghc`, when building stage0, we must set -- -this-unit-id to `ghc` because the boot compiler expects that. -- We do it through a cabal flag in ghc.cabal , stageVersion < makeVersion [9,8,1] ? arg "+hadrian-stage0" - , flag StaticLibzstd `cabalFlag` "static-libzstd" + , staged (buildFlag StaticLibzstd) `cabalFlag` "static-libzstd" ] , builder (Haddock BuildPackage) ? arg ("--optghc=-I" ++ path) ] @@ -116,9 +116,9 @@ packageArgs = do -------------------------------- ghcPrim ------------------------------- , package ghcPrim ? mconcat - [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic" + [ builder (Cabal Flags) ? staged (buildFlag NeedLibatomic) `cabalFlag` "need-atomic" - , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ? + , builder (Cc CompileC) ? (not <$> staged (buildFlag CcLlvmBackend)) ? input "**/cbits/atomic.c" ? arg "-Wno-sync-nand" ] --------------------------------- ghci --------------------------------- @@ -229,8 +229,8 @@ packageArgs = do ghcBignumArgs :: Args ghcBignumArgs = package ghcBignum ? do -- These are only used for non-in-tree builds. - librariesGmp <- getSetting GmpLibDir - includesGmp <- getSetting GmpIncludeDir + librariesGmp <- staged (buildSetting GmpLibDir) + includesGmp <- staged (buildSetting GmpIncludeDir) backend <- getBignumBackend check <- getBignumCheck @@ -253,15 +253,15 @@ ghcBignumArgs = package ghcBignum ? do -- enable in-tree support: don't depend on external "gmp" -- library - , flag GmpInTree ? arg "--configure-option=--with-intree-gmp" + , staged (buildFlag GmpInTree) ? arg "--configure-option=--with-intree-gmp" -- prefer framework over library (on Darwin) - , flag GmpFrameworkPref ? + , staged (buildFlag GmpFrameworkPref) ? arg "--configure-option=--with-gmp-framework-preferred" -- Ensure that the ghc-bignum package registration includes -- knowledge of the system gmp's library and include directories. - , notM (flag GmpInTree) ? cabalExtraDirs includesGmp librariesGmp + , notM (staged (buildFlag GmpInTree)) ? cabalExtraDirs includesGmp librariesGmp ] ] _ -> mempty @@ -290,15 +290,15 @@ rtsPackageArgs = package rts ? do way <- getWay path <- getBuildPath top <- expr topDirectory - useSystemFfi <- getFlag UseSystemFfi - ffiIncludeDir <- getSetting FfiIncludeDir - ffiLibraryDir <- getSetting FfiLibDir - libdwIncludeDir <- getSetting LibdwIncludeDir - libdwLibraryDir <- getSetting LibdwLibDir - libnumaIncludeDir <- getSetting LibnumaIncludeDir - libnumaLibraryDir <- getSetting LibnumaLibDir - libzstdIncludeDir <- getSetting LibZstdIncludeDir - libzstdLibraryDir <- getSetting LibZstdLibDir + useSystemFfi <- staged (buildFlag UseSystemFfi) + ffiIncludeDir <- staged (buildSetting FfiIncludeDir) + ffiLibraryDir <- staged (buildSetting FfiLibDir) + libdwIncludeDir <- staged (buildSetting LibdwIncludeDir) + libdwLibraryDir <- staged (buildSetting LibdwLibDir) + libnumaIncludeDir <- staged (buildSetting LibnumaIncludeDir) + libnumaLibraryDir <- staged (buildSetting LibnumaLibDir) + libzstdIncludeDir <- staged (buildSetting LibZstdIncludeDir) + libzstdLibraryDir <- staged (buildSetting LibZstdLibDir) -- Arguments passed to GHC when compiling C and .cmm sources. @@ -392,10 +392,10 @@ rtsPackageArgs = package rts ? do -- any warnings in the module. See: -- https://gitlab.haskell.org/ghc/ghc/wikis/working-conventions#Warnings - , (not <$> flag CcLlvmBackend) ? + , (not <$> staged (buildFlag CcLlvmBackend)) ? inputs ["**/Compact.c"] ? arg "-finline-limit=2500" - , input "**/RetainerProfile.c" ? flag CcLlvmBackend ? + , input "**/RetainerProfile.c" ? staged (buildFlag CcLlvmBackend) ? arg "-Wno-incompatible-pointer-types" ] @@ -405,18 +405,18 @@ rtsPackageArgs = package rts ? do , any (wayUnit Debug) rtsWays `cabalFlag` "debug" , any (wayUnit Dynamic) rtsWays `cabalFlag` "dynamic" , any (wayUnit Threaded) rtsWays `cabalFlag` "threaded" - , flag UseLibm `cabalFlag` "libm" - , flag UseLibrt `cabalFlag` "librt" - , flag UseLibdl `cabalFlag` "libdl" + , staged (buildFlag UseLibm) `cabalFlag` "libm" + , staged (buildFlag UseLibrt) `cabalFlag` "librt" + , staged (buildFlag UseLibdl) `cabalFlag` "libdl" , useSystemFfi `cabalFlag` "use-system-libffi" , targetUseLibffiForAdjustors stage `cabalFlag` "libffi-adjustors" - , flag UseLibpthread `cabalFlag` "need-pthread" - , flag UseLibbfd `cabalFlag` "libbfd" - , flag NeedLibatomic `cabalFlag` "need-atomic" - , flag UseLibdw `cabalFlag` "libdw" - , flag UseLibnuma `cabalFlag` "libnuma" - , flag UseLibzstd `cabalFlag` "libzstd" - , flag StaticLibzstd `cabalFlag` "static-libzstd" + , staged (buildFlag UseLibpthread) `cabalFlag` "need-pthread" + , staged (buildFlag UseLibbfd ) `cabalFlag` "libbfd" + , staged (buildFlag NeedLibatomic) `cabalFlag` "need-atomic" + , staged (buildFlag UseLibdw ) `cabalFlag` "libdw" + , staged (buildFlag UseLibnuma ) `cabalFlag` "libnuma" + , staged (buildFlag UseLibzstd ) `cabalFlag` "libzstd" + , staged (buildFlag StaticLibzstd) `cabalFlag` "static-libzstd" , queryTargetTarget stage tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore" , ghcUnreg `cabalFlag` "unregisterised" , ghcEnableTNC `cabalFlag` "tables-next-to-code" @@ -437,7 +437,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] + , builder HsCpp ? staged (buildFlag UseLibdw) ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== hadrian/src/Settings/Warnings.hs ===================================== @@ -10,16 +10,15 @@ import Packages -- | Default Haskell warning-related arguments. defaultGhcWarningsArgs :: Args defaultGhcWarningsArgs = do - stage <- getStage mconcat [ notStage0 ? arg "-Wnoncanonical-monad-instances" - , notM (flag CcLlvmBackend) ? arg "-optc-Wno-error=inline" - , flag CcLlvmBackend ? arg "-optc-Wno-unknown-pragmas" + , notM (staged (buildFlag CcLlvmBackend)) ? arg "-optc-Wno-error=inline" + , staged (buildFlag CcLlvmBackend) ? arg "-optc-Wno-unknown-pragmas" -- Cabal can seemingly produce filepaths with incorrect case on filesystems -- with case-insensitive names. Ignore such issues for now as they seem benign. -- See #17798. - , isOsxTarget stage ? arg "-optP-Wno-nonportable-include-path" - , isWinTarget stage ? arg "-optP-Wno-nonportable-include-path" + , staged isOsxTarget ? arg "-optP-Wno-nonportable-include-path" + , staged isWinTarget ? arg "-optP-Wno-nonportable-include-path" ] -- | Package-specific warnings-related arguments, mostly suppressing various warnings. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b09bf12924ebb65b3374bf0e5a8b6f1aebd8d6a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b09bf12924ebb65b3374bf0e5a8b6f1aebd8d6a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 14:46:40 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 09:46:40 -0500 Subject: [Git][ghc/ghc][wip/exception-context] 24 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65e9d350224d1_10117b7c6d584913aa@gitlab.mail> Ben Gamari pushed to branch wip/exception-context at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - ad3948f5 by Ben Gamari at 2024-03-07T09:45:44-05:00 Bump array submodule - - - - - 4a0ef7fc by Ben Gamari at 2024-03-07T09:46:03-05:00 Bump stm submodule - - - - - bdf83693 by Ben Gamari at 2024-03-07T09:46:03-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 6840ee63 by Ben Gamari at 2024-03-07T09:46:03-05:00 testsuite/interface-stability: Update documentation - - - - - 38a1f398 by Ben Gamari at 2024-03-07T09:46:03-05:00 ghc-internal: comment formatting - - - - - 0510ac05 by Ben Gamari at 2024-03-07T09:46:03-05:00 compiler: Default and warn ExceptionContext constraints - - - - - ef8e4310 by Ben Gamari at 2024-03-07T09:46:03-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - ad96a777 by Ben Gamari at 2024-03-07T09:46:03-05:00 users guide: Release notes for exception backtrace work - - - - - dc54eaaf by Ben Gamari at 2024-03-07T09:46:03-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - 2ec0f3df by Sylvain Henry at 2024-03-07T09:46:03-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/runtime_control.rst - docs/users_guide/using-warnings.rst - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Concurrent.hs - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d4786ddd608f72127f4fe8f7bf69746d1f38fd1...2ec0f3df90650e0305a1c9d4c629a333bd792b73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d4786ddd608f72127f4fe8f7bf69746d1f38fd1...2ec0f3df90650e0305a1c9d4c629a333bd792b73 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 17:02:45 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 12:02:45 -0500 Subject: [Git][ghc/ghc][wip/T24515] rts: Drop .wasm suffix from .prof file names Message-ID: <65e9f33544663_10117bb92c4c01256db@gitlab.mail> Ben Gamari pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: 3c3e02f8 by Ben Gamari at 2024-03-07T12:02:25-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 4 changed files: - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h Changes: ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(stem, ".exe"); +#elif defined(wasi32_HOST_OS) + dropExtension(stem, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasi32_HOST_OS) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c3e02f83edf7fc92e7514f2f05eb0f5c4e9d582 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c3e02f83edf7fc92e7514f2f05eb0f5c4e9d582 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 18:07:29 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 07 Mar 2024 13:07:29 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/m_warning Message-ID: <65ea02614bc2e_10117bd8f3d1c1399ce@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/m_warning at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/m_warning You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 21:29:11 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 07 Mar 2024 16:29:11 -0500 Subject: [Git][ghc/ghc][master] Rephrase error message to say "visible arguments" (#24318) Message-ID: <65ea31a7b876d_17a6f218f3f441006e9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - 24 changed files: - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - testsuite/tests/ado/ado002.stderr - testsuite/tests/ghci/scripts/Defer02.stderr - testsuite/tests/indexed-types/should_compile/T10806.stderr - testsuite/tests/indexed-types/should_fail/T8518.stderr - testsuite/tests/rep-poly/T23903.stderr - testsuite/tests/th/T5358.stderr - testsuite/tests/typecheck/should_fail/DoExpansion2.stderr - testsuite/tests/typecheck/should_fail/DoExpansion3.stderr - testsuite/tests/typecheck/should_fail/FD1.stderr - testsuite/tests/typecheck/should_fail/T13902.stderr - testsuite/tests/typecheck/should_fail/T17139.stderr - + testsuite/tests/typecheck/should_fail/T24318.hs - + testsuite/tests/typecheck/should_fail/T24318.stderr - testsuite/tests/typecheck/should_fail/T8603.stderr - testsuite/tests/typecheck/should_fail/T9605.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail001.stderr - testsuite/tests/typecheck/should_fail/tcfail140.stderr - testsuite/tests/typecheck/should_fail/tcfail175.stderr - testsuite/tests/vdq-rta/should_fail/T22326_fail_n_args.stderr - testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr Changes: ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -75,7 +75,7 @@ import GHC.Driver.DynFlags ( getDynFlags ) import GHC.Types.Name import GHC.Types.Id import GHC.Types.SrcLoc -import GHC.Types.Basic( Arity, isDoExpansionGenerated ) +import GHC.Types.Basic( VisArity, isDoExpansionGenerated ) import Control.Monad import Control.Arrow ( second ) @@ -1207,7 +1207,7 @@ the variables they bind into scope, and typecheck the thing_inside. -- The MatchGroup for `f` has arity 2, not 3 checkArgCounts :: AnnoBody body => MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM Arity + -> TcM VisArity checkArgCounts (MG { mg_alts = L _ [] }) = return 1 -- See Note [Empty MatchGroups] in GHC.Rename.Bind -- case e of {} or \case {} @@ -1227,6 +1227,6 @@ checkArgCounts (MG { mg_alts = L _ (match1:matches) }) n_args1 = reqd_args_in_match match1 mb_bad_matches = NE.nonEmpty [m | m <- matches, reqd_args_in_match m /= n_args1] - reqd_args_in_match :: LocatedA (Match GhcRn body1) -> Arity + reqd_args_in_match :: LocatedA (Match GhcRn body1) -> VisArity -- Counts the number of /required/ args in the match reqd_args_in_match (L _ (Match { m_pats = pats })) = count (isVisArgPat . unLoc) pats ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -751,7 +751,7 @@ Example: matchExpectedFunTys :: forall a. ExpectedFunTyOrigin -- See Note [Herald for matchExpectedFunTys] -> UserTypeCtxt - -> Arity + -> VisArity -> ExpSigmaType -> ([ExpPatType] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) @@ -777,7 +777,7 @@ matchExpectedFunTys herald _ arity (Infer inf_res) thing_inside matchExpectedFunTys herald ctx arity (Check top_ty) thing_inside = check 0 [] top_ty where - check :: Arity -> [ExpPatType] -> TcSigmaType -> TcM (HsWrapper, a) + check :: VisArity -> [ExpPatType] -> TcSigmaType -> TcM (HsWrapper, a) -- `check` is called only in the Check{} case -- It collects rev_pat_tys in reversed order -- n_so_far is the number of /visible/ arguments seen so far: @@ -875,7 +875,7 @@ matchExpectedFunTys herald ctx arity (Check top_ty) thing_inside defer n_so_far rev_pat_tys res_ty ------------ - defer :: Arity -> [ExpPatType] -> TcRhoType -> TcM (HsWrapper, a) + defer :: VisArity -> [ExpPatType] -> TcRhoType -> TcM (HsWrapper, a) defer n_so_far rev_pat_tys fun_ty = do { more_arg_tys <- mapM (new_check_arg_ty herald) [n_so_far + 1 .. arity] ; let all_pats = reverse rev_pat_tys ++ map mkCheckExpFunPatTy more_arg_tys @@ -898,19 +898,15 @@ new_check_arg_ty herald arg_pos -- Position for error messages only ; return (mkScaled mult arg_ty) } mkFunTysMsg :: ExpectedFunTyOrigin - -> (Arity, TcType) + -> (VisArity, TcType) -> TidyEnv -> ZonkM (TidyEnv, SDoc) -- See Note [Reporting application arity errors] -mkFunTysMsg herald (n_val_args_in_call, fun_ty) env +mkFunTysMsg herald (n_vis_args_in_call, fun_ty) env = do { (env', fun_ty) <- zonkTidyTcType env fun_ty ; let (pi_ty_bndrs, _) = splitPiTys fun_ty - - -- `all_arg_tys` contains visible quantifiers only, so their number matches - -- the number of arguments that the user needs to pass to the function. n_fun_args = count isVisiblePiTyBinder pi_ty_bndrs - - msg | n_val_args_in_call <= n_fun_args -- Enough args, in the end + msg | n_vis_args_in_call <= n_fun_args -- Enough args, in the end = text "In the result of a function call" | otherwise = hang (full_herald <> comma) @@ -921,7 +917,8 @@ mkFunTysMsg herald (n_val_args_in_call, fun_ty) env ; return (env', msg) } where full_herald = pprExpectedFunTyHerald herald - <+> speakNOf n_val_args_in_call (text "value argument") + <+> speakNOf n_vis_args_in_call (text "visible argument") + -- What are "visible" arguments? See Note [Visibility and arity] in GHC.Types.Basic {- Note [Reporting application arity errors] @@ -931,8 +928,8 @@ and the call foo = f 3 4 5 We'd like to get an error like: • Couldn't match expected type ‘t0 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to three value arguments, - but its type ‘Int -> Int -> Int’ has only two + • The function ‘f’ is applied to three visible arguments, -- What are "visible" arguments? + but its type ‘Int -> Int -> Int’ has only two -- See Note [Visibility and arity] in GHC.Types.Basic That is what `mkFunTysMsg` tries to do. But what is the "type of the function". Most obviously, we can report its full, polymorphic type; that is simple and @@ -943,7 +940,7 @@ We get this error: • Couldn't match type ‘Int’ with ‘t0 -> t’ Expected: Int -> t0 -> t Actual: Int -> Int - • The function ‘f’ is applied to three value arguments, + • The function ‘f’ is applied to three visible arguments, but its type ‘Bool -> t Int Int’ has only one That's not /quite/ right beause we can instantiate `t` to an arrow and get ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -28,7 +28,7 @@ module GHC.Types.Basic ( ConTag, ConTagZ, fIRST_TAG, - Arity, RepArity, JoinArity, FullArgCount, + Arity, VisArity, RepArity, JoinArity, FullArgCount, JoinPointHood(..), isJoinPoint, Alignment, mkAlignment, alignmentOf, alignmentBytes, @@ -183,6 +183,10 @@ instance Binary LeftOrRight where -- See also Note [Definition of arity] in "GHC.Core.Opt.Arity" type Arity = Int +-- | Syntactic (visibility) arity, i.e. the number of visible arguments. +-- See Note [Visibility and arity] +type VisArity = Int + -- | Representation Arity -- -- The number of represented arguments that can be applied to a value before it does @@ -203,6 +207,71 @@ type JoinArity = Int -- both type and value arguments! type FullArgCount = Int +{- Note [Visibility and arity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Arity is the number of arguments that a function expects. In a curried language +like Haskell, there is more than one way to count those arguments. + +* `Arity` is the classic notion of arity, concerned with evalution, so it counts + the number of /value/ arguments that need to be supplied before evaluation can + take place, as described in notes + Note [Definition of arity] in GHC.Core.Opt.Arity + Note [Arity and function types] in GHC.Types.Id.Info + + Examples: + Int has arity == 0 + Int -> Int has arity <= 1 + Int -> Bool -> Int has arity <= 2 + We write (<=) rather than (==) as sometimes evaluation can occur before all + value arguments are supplied, depending on the actual function definition. + + This evaluation-focused notion of arity ignores type arguments, so: + forall a. a has arity == 0 + forall a. a -> a has arity <= 1 + forall a b. a -> b -> a has arity <= 2 + This is true regardless of ForAllTyFlag, so the arity is also unaffected by + (forall {a}. ty) or (forall a -> ty). + + Class dictionaries count towards the arity, as they are passed at runtime + forall a. (Num a) => a has arity <= 1 + forall a. (Num a) => a -> a has arity <= 2 + forall a b. (Num a, Ord b) => a -> b -> a has arity <= 4 + +* `VisArity` is the syntactic notion of arity. It is the number of /visible/ + arguments, i.e. arguments that occur visibly in the source code. + + In a function call `f x y z`, we can confidently say that f's vis-arity >= 3, + simply because we see three arguments [x,y,z]. We write (>=) rather than (==) + as this could be a partial application. + + At definition sites, we can acquire an underapproximation of vis-arity by + counting the patterns on the LHS, e.g. `f a b = rhs` has vis-arity >= 2. + The actual vis-arity can be higher if there is a lambda on the RHS, + e.g. `f a b = \c -> rhs`. + + If we look at the types, we can observe the following + * function arrows (a -> b) add to the vis-arity + * visible foralls (forall a -> b) add to the vis-arity + * constraint arrows (a => b) do not affect the vis-arity + * invisible foralls (forall a. b) do not affect the vis-arity + + This means that ForAllTyFlag matters for VisArity (in contrast to Arity), + while the type/value distinction is unimportant (again in contrast to Arity). + + Examples: + Int -- vis-arity == 0 (no args) + Int -> Int -- vis-arity == 1 (1 funarg) + forall a. a -> a -- vis-arity == 1 (1 funarg) + forall a. Num a => a -> a -- vis-arity == 1 (1 funarg) + forall a -> Num a => a -- vis-arity == 1 (1 req tyarg, 0 funargs) + forall a -> a -> a -- vis-arity == 2 (1 req tyarg, 1 funarg) + Int -> forall a -> Int -- vis-arity == 2 (1 funarg, 1 req tyarg) + + Wrinkle: with TypeApplications and TypeAbstractions, it is possible to visibly + bind and pass invisible arguments, e.g. `f @a x = ...` or `f @Int 42`. Those + @-prefixed arguments are ignored for the purposes of vis-arity. +-} + {- ************************************************************************ * * ===================================== testsuite/tests/ado/ado002.stderr ===================================== @@ -2,7 +2,7 @@ ado002.hs:8:8: error: [GHC-83865] • Couldn't match expected type: Char -> IO b0 with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: y <- getChar 'a' In the expression: @@ -45,7 +45,7 @@ ado002.hs:15:13: error: [GHC-83865] ado002.hs:23:9: error: [GHC-83865] • Couldn't match expected type: Char -> IO a0 with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: x5 <- getChar x4 In the expression: ===================================== testsuite/tests/ghci/scripts/Defer02.stderr ===================================== @@ -26,7 +26,7 @@ Defer01.hs:24:4: warning: [GHC-40564] [-Winaccessible-code (in -Wdefault)] Defer01.hs:30:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one value argument, + • The function ‘e’ is applied to one visible argument, but its type ‘Char’ has none In the expression: e 'q' In an equation for ‘f’: f = e 'q' @@ -95,7 +95,7 @@ Defer01.hs:49:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] (deferred type error) *** Exception: Defer01.hs:30:5: error: [GHC-83865] • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one value argument, + • The function ‘e’ is applied to one visible argument, but its type ‘Char’ has none In the expression: e 'q' In an equation for ‘f’: f = e 'q' ===================================== testsuite/tests/indexed-types/should_compile/T10806.stderr ===================================== @@ -2,7 +2,7 @@ T10806.hs:11:32: error: [GHC-83865] • Couldn't match expected type: Char -> Bool with actual type: IO () - • The function ‘print’ is applied to two value arguments, + • The function ‘print’ is applied to two visible arguments, but its type ‘Show a => a -> IO ()’ has only one In the expression: print 'x' 'y' In an equation for ‘triggersLoop’: ===================================== testsuite/tests/indexed-types/should_fail/T8518.stderr ===================================== @@ -2,7 +2,7 @@ T8518.hs:14:18: error: [GHC-83865] • Couldn't match expected type: Z c -> B c -> t0 with actual type: F c - • The function ‘rpt’ is applied to four value arguments, + • The function ‘rpt’ is applied to four visible arguments, but its type ‘t1 -> t2 -> F t2’ has only two In the expression: rpt (4 :: Int) c z b In an equation for ‘callCont’: ===================================== testsuite/tests/rep-poly/T23903.stderr ===================================== @@ -6,5 +6,5 @@ T23903.hs:21:1: error: [GHC-55287] t0 :: TYPE cx0 Cannot unify ‘Rep a’ with the type variable ‘cx0’ because the former is not a concrete ‘RuntimeRep’. - • The equation for ‘f’ has one value argument, + • The equation for ‘f’ has one visible argument, but its type ‘a #-> ()’ has none ===================================== testsuite/tests/th/T5358.stderr ===================================== @@ -1,17 +1,17 @@ T5358.hs:7:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t1 -> t1’ - • The equation for ‘t1’ has one value argument, + • The equation for ‘t1’ has one visible argument, but its type ‘Int’ has none T5358.hs:8:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t0 -> t0’ - • The equation for ‘t2’ has one value argument, + • The equation for ‘t2’ has one visible argument, but its type ‘Int’ has none T5358.hs:10:13: error: [GHC-83865] • Couldn't match expected type ‘t -> a0’ with actual type ‘Int’ - • The function ‘t1’ is applied to one value argument, + • The function ‘t1’ is applied to one visible argument, but its type ‘Int’ has none In the first argument of ‘(==)’, namely ‘t1 x’ In the expression: t1 x == t2 x @@ -21,7 +21,7 @@ T5358.hs:10:13: error: [GHC-83865] T5358.hs:10:21: error: [GHC-83865] • Couldn't match expected type ‘t -> a0’ with actual type ‘Int’ - • The function ‘t2’ is applied to one value argument, + • The function ‘t2’ is applied to one visible argument, but its type ‘Int’ has none In the second argument of ‘(==)’, namely ‘t2 x’ In the expression: t1 x == t2 x ===================================== testsuite/tests/typecheck/should_fail/DoExpansion2.stderr ===================================== @@ -55,7 +55,7 @@ DoExpansion2.hs:31:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type: t0 -> IO (Maybe Int) with actual type: IO String - • The function ‘getVal’ is applied to two value arguments, + • The function ‘getVal’ is applied to two visible arguments, but its type ‘Int -> IO String’ has only one In a stmt of a 'do' block: Just x <- getVal 3 4 In the expression: ===================================== testsuite/tests/typecheck/should_fail/DoExpansion3.stderr ===================================== @@ -10,7 +10,7 @@ DoExpansion3.hs:15:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul DoExpansion3.hs:18:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type: t0 -> t with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In the expression: getChar 2 In an equation for ‘y’: y = getChar 2 ===================================== testsuite/tests/typecheck/should_fail/FD1.stderr ===================================== @@ -5,6 +5,6 @@ FD1.hs:16:1: error: [GHC-25897] the type signature for: plus :: forall a. E a (Int -> Int) => Int -> a at FD1.hs:15:1-38 - • The equation for ‘plus’ has two value arguments, + • The equation for ‘plus’ has two visible arguments, but its type ‘Int -> a’ has only one • Relevant bindings include plus :: Int -> a (bound at FD1.hs:16:1) ===================================== testsuite/tests/typecheck/should_fail/T13902.stderr ===================================== @@ -1,7 +1,7 @@ T13902.hs:8:5: error: [GHC-83865] • Couldn't match expected type ‘t0 -> Int’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘a -> a’ has only one In the expression: f @Int 42 5 In an equation for ‘g’: g = f @Int 42 5 ===================================== testsuite/tests/typecheck/should_fail/T17139.stderr ===================================== @@ -7,7 +7,7 @@ T17139.hs:15:16: error: [GHC-88464] lift :: forall a b (f :: * -> *). (a -> b) -> TypeFam f (a -> b) at T17139.hs:14:1-38 • In the expression: _ (f <*> x) - The lambda expression ‘\ x -> ...’ has one value argument, + The lambda expression ‘\ x -> ...’ has one visible argument, but its type ‘TypeFam f (a -> b)’ has none In the expression: \ x -> _ (f <*> x) • Relevant bindings include ===================================== testsuite/tests/typecheck/should_fail/T24318.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE ExplicitNamespaces, RequiredTypeArguments #-} + +module T24318 where + +import Data.Kind + +f :: forall (a :: Type) -> Bool +f (type t) x = True ===================================== testsuite/tests/typecheck/should_fail/T24318.stderr ===================================== @@ -0,0 +1,5 @@ + +T24318.hs:8:1: error: [GHC-83865] + • Couldn't match expected type ‘Bool’ with actual type ‘t0 -> Bool’ + • The equation for ‘f’ has two visible arguments, + but its type ‘forall a -> Bool’ has only one ===================================== testsuite/tests/typecheck/should_fail/T8603.stderr ===================================== @@ -6,7 +6,7 @@ T8603.hs:33:17: error: [GHC-18872] [a2] :: * Expected: [a2] -> StateT s RV a0 Actual: t0 ((->) [a1]) (StateT s RV a0) - • The function ‘lift’ is applied to two value arguments, + • The function ‘lift’ is applied to two visible arguments, but its type ‘(Control.Monad.Trans.Class.MonadTrans t, Monad m) => m a -> t m a’ has only one ===================================== testsuite/tests/typecheck/should_fail/T9605.stderr ===================================== @@ -3,7 +3,7 @@ T9605.hs:7:6: error: [GHC-83865] • Couldn't match type ‘Bool’ with ‘m Bool’ Expected: t0 -> m Bool Actual: t0 -> Bool - • The function ‘f1’ is applied to one value argument, + • The function ‘f1’ is applied to one visible argument, but its type ‘Monad m => m Bool’ has none In the expression: f1 undefined In an equation for ‘f2’: f2 = f1 undefined ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -712,6 +712,7 @@ test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always test('T24064', normal, compile_fail, ['']) test('T24298', normal, compile_fail, ['']) test('T24279', normal, compile_fail, ['']) +test('T24318', normal, compile_fail, ['']) # all the various do expansion fail messages test('DoExpansion1', normal, compile, ['-fdefer-type-errors']) ===================================== testsuite/tests/typecheck/should_fail/tcfail001.stderr ===================================== @@ -2,7 +2,7 @@ tcfail001.hs:9:2: error: [GHC-83865] • Couldn't match expected type: [a] with actual type: [a0] -> [a1] - • The equation for ‘op’ has one value argument, + • The equation for ‘op’ has one visible argument, but its type ‘[a]’ has none In the instance declaration for ‘A [a]’ • Relevant bindings include op :: [a] (bound at tcfail001.hs:9:2) ===================================== testsuite/tests/typecheck/should_fail/tcfail140.stderr ===================================== @@ -1,7 +1,7 @@ tcfail140.hs:11:7: error: [GHC-83865] • Couldn't match expected type ‘t1 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘Int -> Int’ has only one In the expression: f 3 9 In an equation for ‘bar’: bar = f 3 9 @@ -9,7 +9,7 @@ tcfail140.hs:11:7: error: [GHC-83865] tcfail140.hs:13:10: error: [GHC-83865] • Couldn't match expected type ‘t2 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘Int -> Int’ has only one In the expression: 3 `f` 4 In an equation for ‘rot’: rot xs = 3 `f` 4 @@ -28,11 +28,11 @@ tcfail140.hs:15:15: error: [GHC-83865] tcfail140.hs:17:8: error: [GHC-27346] • The data constructor ‘Just’ should have 1 argument, but has been given none • In the pattern: Just - The lambda expression ‘\ Just x -> ...’ has two value arguments, + The lambda expression ‘\ Just x -> ...’ has two visible arguments, but its type ‘Maybe a -> a’ has only one In the expression: ((\ Just x -> x) :: Maybe a -> a) (Just 1) tcfail140.hs:20:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t0 -> Bool’ - • The equation for ‘g’ has two value arguments, + • The equation for ‘g’ has two visible arguments, but its type ‘Int -> Int’ has only one ===================================== testsuite/tests/typecheck/should_fail/tcfail175.stderr ===================================== @@ -6,7 +6,7 @@ tcfail175.hs:11:1: error: [GHC-25897] the type signature for: evalRHS :: forall a. Int -> a at tcfail175.hs:10:1-19 - • The equation for ‘evalRHS’ has three value arguments, + • The equation for ‘evalRHS’ has three visible arguments, but its type ‘Int -> a’ has only one • Relevant bindings include evalRHS :: Int -> a (bound at tcfail175.hs:11:1) ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_n_args.stderr ===================================== @@ -5,5 +5,5 @@ T22326_fail_n_args.hs:6:1: error: [GHC-25897] the type signature for: f :: a -> forall b -> b at T22326_fail_n_args.hs:6:1-26 - • The equation for ‘f’ has three value arguments, + • The equation for ‘f’ has three visible arguments, but its type ‘a -> forall b -> b’ has only two ===================================== testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr ===================================== @@ -37,7 +37,7 @@ CaretDiagnostics1.hs:13:7-11: error: [GHC-83865] CaretDiagnostics1.hs:(13,16)-(14,13): error: [GHC-83865] • Couldn't match expected type ‘Char -> t0’ with actual type ‘()’ - • The function ‘()’ is applied to one value argument, + • The function ‘()’ is applied to one visible argument, but its type ‘()’ has none In the expression: () '0' In a case alternative: "γηξ" -> () '0' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9cd9efb4de3757fd5eaec006739f75cef288e5eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9cd9efb4de3757fd5eaec006739f75cef288e5eb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 21:30:46 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 07 Mar 2024 16:30:46 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: Bump array submodule Message-ID: <65ea32066e597_17a6f21c0c8c01049b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 39ae4f9e by Ben Gamari at 2024-03-07T16:30:38-05:00 Bump array submodule - - - - - b8e012ed by Ben Gamari at 2024-03-07T16:30:38-05:00 Bump stm submodule - - - - - 08ba9f3b by Ben Gamari at 2024-03-07T16:30:39-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - f3d8702a by Ben Gamari at 2024-03-07T16:30:39-05:00 testsuite/interface-stability: Update documentation - - - - - 440b9397 by Ben Gamari at 2024-03-07T16:30:39-05:00 ghc-internal: comment formatting - - - - - 70f745bc by Ben Gamari at 2024-03-07T16:30:39-05:00 compiler: Default and warn ExceptionContext constraints - - - - - f9a53b3b by Ben Gamari at 2024-03-07T16:30:39-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 540386f3 by Ben Gamari at 2024-03-07T16:30:39-05:00 users guide: Release notes for exception backtrace work - - - - - 901c69f7 by Ben Gamari at 2024-03-07T16:30:39-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - 28adbec7 by Sylvain Henry at 2024-03-07T16:30:39-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - 6e5db80f by Alan Zimmerman at 2024-03-07T16:30:40-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr - libraries/base/tests/IO/openFile002.stderr - libraries/base/tests/IO/openFile002.stderr-mingw32 - libraries/base/tests/IO/withBinaryFile001.stderr - libraries/base/tests/IO/withBinaryFile002.stderr - libraries/base/tests/IO/withFile001.stderr - libraries/base/tests/IO/withFile002.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc6d3a0de722e1080b0e7aa916fe9ba1ea332e64...6e5db80f6bacd51fbabdaedbb22b0b91aebc4a33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc6d3a0de722e1080b0e7aa916fe9ba1ea332e64...6e5db80f6bacd51fbabdaedbb22b0b91aebc4a33 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 21:50:16 2024 From: gitlab at gitlab.haskell.org (Torsten Schmits (@torsten.schmits)) Date: Thu, 07 Mar 2024 16:50:16 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/torsten.schmits/rts-linker-direct-symbol-lookup Message-ID: <65ea3698dc162_17a6f22a605981161a3@gitlab.mail> Torsten Schmits pushed new branch wip/torsten.schmits/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/torsten.schmits/rts-linker-direct-symbol-lookup You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 21:55:59 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 07 Mar 2024 16:55:59 -0500 Subject: [Git][ghc/ghc][wip/andreask/m_warning] RTS: Emit warning when -M < -H Message-ID: <65ea37ef94efb_17a6f22dc87e4116390@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/m_warning at Glasgow Haskell Compiler / GHC Commits: 0c35d34f by Andreas Klebinger at 2024-03-07T22:42:57+01:00 RTS: Emit warning when -M < -H - - - - - 1 changed file: - rts/RtsFlags.c Changes: ===================================== rts/RtsFlags.c ===================================== @@ -1951,6 +1951,9 @@ static void normaliseRtsOpts (void) if (RtsFlags.GcFlags.maxHeapSize != 0 && RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) { + errorBelch("Maximum heap size (-M) is smaller than suggested heap size (-H)\n" + "Setting maximum heap size to suggested heap size ( %" FMT_Word " )", + (StgWord64) RtsFlags.GcFlags.maxHeapSize * (StgWord64) BLOCK_SIZE); RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c35d34f5909066e6725891f5fe12df2812b516c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c35d34f5909066e6725891f5fe12df2812b516c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 22:46:59 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Thu, 07 Mar 2024 17:46:59 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Deleted 2 commits: Add DCoVarSet to PluginProv Message-ID: <65ea43e37ecae_17a6f240e9d8c122576@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below. Deleted commits: 70f2d3ee by Mikolaj Konarski at 2024-03-07T00:34:41+01:00 Add DCoVarSet to PluginProv Add the only remaining piece of feedback from git add src/Flavour.hs Help CI check some more of the patch Fix the 3 plugin tests that fail Explain better how shallowCoVarsOfCosDSet is entangled with a hundreds of lines bit-rotten refactoring Fix according to the first round of Simon's instruction Fix according to the second round of Simon's instruction Remove a question-comment that's probably absurd Fix according to the third round of Simon's instruction - - - - - 053fdb81 by Mikolaj Konarski at 2024-03-07T00:34:41+01:00 Make sure the foldl' accumulators are strict - - - - - 23 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Types/Unique/DSet.hs - compiler/GHC/Types/Var/Set.hs - compiler/GHC/Utils/FV.hs - docs/users_guide/extending_ghc.rst - testsuite/tests/tcplugins/CtIdPlugin.hs - testsuite/tests/tcplugins/RewritePlugin.hs - testsuite/tests/tcplugins/TyFamPlugin.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -97,7 +97,7 @@ module GHC.Core.Coercion ( emptyLiftingContext, extendLiftingContext, extendLiftingContextAndInScope, liftCoSubstVarBndrUsing, isMappedByLC, extendLiftingContextCvSubst, - mkSubstLiftingContext, zapLiftingContext, + mkSubstLiftingContext, liftingContextSubst, zapLiftingContext, substForAllCoBndrUsingLC, lcLookupCoVar, lcInScopeSet, LiftCoEnv, LiftingContext(..), liftEnvSubstLeft, liftEnvSubstRight, @@ -1397,7 +1397,7 @@ setNominalRole_maybe r co setNominalRole_maybe_helper (UnivCo prov _ co1 co2) | case prov of PhantomProv _ -> False -- should always be phantom ProofIrrelProv _ -> True -- it's always safe - PluginProv _ -> False -- who knows? This choice is conservative. + PluginProv _ _ -> False -- who knows? This choice is conservative. = Just $ UnivCo prov Nominal co1 co2 setNominalRole_maybe_helper _ = Nothing @@ -1522,7 +1522,7 @@ promoteCoercion co = case co of UnivCo (PhantomProv kco) _ _ _ -> kco UnivCo (ProofIrrelProv kco) _ _ _ -> kco - UnivCo (PluginProv _) _ _ _ -> mkKindCo co + UnivCo (PluginProv _ _) _ _ _ -> mkKindCo co SymCo g -> mkSymCo (promoteCoercion g) @@ -1979,6 +1979,9 @@ mkLiftingContext pairs mkSubstLiftingContext :: Subst -> LiftingContext mkSubstLiftingContext subst = LC subst emptyVarEnv +liftingContextSubst :: LiftingContext -> Subst +liftingContextSubst (LC subst _) = subst + -- | Extend a lifting context with a new mapping. extendLiftingContext :: LiftingContext -- ^ original LC -> TyCoVar -- ^ new variable to map... @@ -2354,7 +2357,7 @@ seqCo (AxiomRuleCo _ cs) = seqCos cs seqProv :: UnivCoProvenance -> () seqProv (PhantomProv co) = seqCo co seqProv (ProofIrrelProv co) = seqCo co -seqProv (PluginProv _) = () +seqProv (PluginProv _ cvs) = seqDVarSet cvs seqCos :: [Coercion] -> () seqCos [] = () ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -641,7 +641,7 @@ opt_univ env sym prov role oty1 oty2 where prov' = case prov of ProofIrrelProv kco -> ProofIrrelProv $ opt_co4_wrap env sym False Nominal kco - PluginProv _ -> prov + PluginProv s cvs -> PluginProv s $ substDCoVarSet (liftingContextSubst env) cvs ------------- opt_transList :: HasDebugCallStack => InScopeSet -> [NormalCo] -> [NormalCo] -> [NormalCo] @@ -722,7 +722,8 @@ opt_trans_rule is in_co1@(UnivCo p1 r1 tyl1 _tyr1) = Just $ PhantomProv $ opt_trans is kco1 kco2 opt_trans_prov (ProofIrrelProv kco1) (ProofIrrelProv kco2) = Just $ ProofIrrelProv $ opt_trans is kco1 kco2 - opt_trans_prov (PluginProv str1) (PluginProv str2) | str1 == str2 = Just p1 + opt_trans_prov (PluginProv str1 cvs1) (PluginProv str2 cvs2) + | str1 == str2 = Just (PluginProv str1 (cvs1 `unionDVarSet` cvs2)) opt_trans_prov _ _ = Nothing -- Push transitivity down through matching top-level constructors. ===================================== compiler/GHC/Core/FVs.hs ===================================== @@ -410,7 +410,7 @@ orphNamesOfCo (HoleCo _) = emptyNameSet orphNamesOfProv :: UnivCoProvenance -> NameSet orphNamesOfProv (PhantomProv co) = orphNamesOfCo co orphNamesOfProv (ProofIrrelProv co) = orphNamesOfCo co -orphNamesOfProv (PluginProv _) = emptyNameSet +orphNamesOfProv (PluginProv _ _) = emptyNameSet orphNamesOfCos :: [Coercion] -> NameSet orphNamesOfCos = orphNamesOfThings orphNamesOfCo ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1931,6 +1931,13 @@ checkTyCon :: TyCon -> LintM () checkTyCon tc = checkL (not (isTcTyCon tc)) (text "Found TcTyCon:" <+> ppr tc) +------------------- +checkTyCoVarInScope :: Subst -> TyCoVar -> LintM () +checkTyCoVarInScope subst tcv + = checkL (tcv `isInScope` subst) $ + hang (text "The type or coercion variable" <+> pprBndr LetBind tcv) + 2 (text "is out of scope") + ------------------- lintType :: Type -> LintM LintedType @@ -1948,12 +1955,8 @@ lintType (TyVarTy tv) -- In GHCi we may lint an expression with a free -- type variable. Then it won't be in the -- substitution, but it should be in scope - Nothing | tv `isInScope` subst - -> return (TyVarTy tv) - | otherwise - -> failWithL $ - hang (text "The type variable" <+> pprBndr LetBind tv) - 2 (text "is out of scope") + Nothing -> do { checkTyCoVarInScope subst tv + ; return (TyVarTy tv) } } lintType ty@(AppTy t1 t2) @@ -2325,15 +2328,8 @@ lintCoercion (CoVarCo cv) = do { subst <- getSubst ; case lookupCoVar subst cv of Just linted_co -> return linted_co ; - Nothing - | cv `isInScope` subst - -> return (CoVarCo cv) - | otherwise - -> - -- lintCoBndr always extends the substitution - failWithL $ - hang (text "The coercion variable" <+> pprBndr LetBind cv) - 2 (text "is out of scope") + Nothing -> do { checkTyCoVarInScope subst cv + ; return (CoVarCo cv) } } @@ -2532,7 +2528,12 @@ lintCoercion co@(UnivCo prov r ty1 ty2) ; check_kinds kco k1 k2 ; return (ProofIrrelProv kco') } - lint_prov _ _ prov@(PluginProv _) = return prov + lint_prov _ _ (PluginProv s cvs) + = do { subst <- getSubst + ; mapM_ (checkTyCoVarInScope subst) (dVarSetElems cvs) + -- Don't bother to return substituted fvs; + -- they don't matter to Lint + ; return (PluginProv s cvs) } check_kinds kco k1 k2 = do { let Pair k1' k2' = coercionKind kco ===================================== compiler/GHC/Core/TyCo/FVs.hs ===================================== @@ -19,6 +19,7 @@ module GHC.Core.TyCo.FVs tyCoVarsOfCoDSet, tyCoFVsOfCo, tyCoFVsOfCos, tyCoVarsOfCoList, + coVarsOfCosDSet, almostDevoidCoVarOfCo, @@ -446,6 +447,13 @@ deepCoVarFolder = TyCoFolder { tcf_view = noView -- See Note [CoercionHoles and coercion free variables] -- in GHC.Core.TyCo.Rep +------- Same again, but for DCoVarSet ---------- +-- But this time the free vars are shallow + +coVarsOfCosDSet :: [Coercion] -> DCoVarSet +coVarsOfCosDSet cos = fvDVarSetSome isCoVar (tyCoFVsOfCos cos) + + {- ********************************************************************* * * Closing over kinds @@ -660,7 +668,7 @@ tyCoFVsOfCoVar v fv_cand in_scope acc tyCoFVsOfProv :: UnivCoProvenance -> FV tyCoFVsOfProv (PhantomProv co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc tyCoFVsOfProv (ProofIrrelProv co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc -tyCoFVsOfProv (PluginProv _) fv_cand in_scope acc = emptyFV fv_cand in_scope acc +tyCoFVsOfProv (PluginProv _ cvs) fv_cand in_scope acc = mkFVs (dVarSetElems cvs) fv_cand in_scope acc tyCoFVsOfCos :: [Coercion] -> FV tyCoFVsOfCos [] fv_cand in_scope acc = emptyFV fv_cand in_scope acc @@ -730,7 +738,7 @@ almost_devoid_co_var_of_prov (PhantomProv co) cv = almost_devoid_co_var_of_co co cv almost_devoid_co_var_of_prov (ProofIrrelProv co) cv = almost_devoid_co_var_of_co co cv -almost_devoid_co_var_of_prov (PluginProv _) _ = True +almost_devoid_co_var_of_prov (PluginProv _ cvs) cv = not (cv `elemDVarSet` cvs) almost_devoid_co_var_of_type :: Type -> CoVar -> Bool almost_devoid_co_var_of_type (TyVarTy _) _ = True @@ -1129,7 +1137,7 @@ tyConsOfType ty go_prov (PhantomProv co) = go_co co go_prov (ProofIrrelProv co) = go_co co - go_prov (PluginProv _) = emptyUniqSet + go_prov (PluginProv _ _) = emptyUniqSet go_cos cos = foldr (unionUniqSets . go_co) emptyUniqSet cos @@ -1340,4 +1348,4 @@ occCheckExpand vs_to_avoid ty ------------------ go_prov cxt (PhantomProv co) = PhantomProv <$> go_co cxt co go_prov cxt (ProofIrrelProv co) = ProofIrrelProv <$> go_co cxt co - go_prov _ p@(PluginProv _) = return p + go_prov _ p@(PluginProv _ _) = return p ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1,4 +1,3 @@ - {-# LANGUAGE DeriveDataTypeable #-} {-# OPTIONS_HADDOCK not-home #-} @@ -78,7 +77,7 @@ import {-# SOURCE #-} GHC.Core.Type( chooseFunTyFlag, typeKind, typeTypeOrConstr -- friends: import GHC.Types.Var -import GHC.Types.Var.Set( elemVarSet ) +import GHC.Types.Var.Set( DCoVarSet, dVarSetElems, elemVarSet ) import GHC.Core.TyCon import GHC.Core.Coercion.Axiom @@ -886,7 +885,7 @@ data Coercion | FunCo -- FunCo :: "e" -> N/P -> e -> e -> e -- See Note [FunCo] for fco_afl, fco_afr - { fco_role :: Role + { fco_role :: Role , fco_afl :: FunTyFlag -- Arrow for coercionLKind , fco_afr :: FunTyFlag -- Arrow for coercionRKind , fco_mult :: CoercionN @@ -1527,15 +1526,19 @@ data UnivCoProvenance -- considered equivalent. See Note [ProofIrrelProv]. -- Can be used in Nominal or Representational coercions - | PluginProv String -- ^ From a plugin, which asserts that this coercion - -- is sound. The string is for the use of the plugin. + | PluginProv String !DCoVarSet + -- ^ From a plugin, which asserts that this coercion is sound. + -- The string and the variable set are for the use by the plugin. + -- E.g., the set may contain the in-scope coercion variables + -- that the the proof represented by the coercion makes use of. + -- See Note [The importance of tracking free coercion variables]. deriving Data.Data instance Outputable UnivCoProvenance where - ppr (PhantomProv _) = text "(phantom)" - ppr (ProofIrrelProv _) = text "(proof irrel.)" - ppr (PluginProv str) = parens (text "plugin" <+> brackets (text str)) + ppr (PhantomProv _) = text "(phantom)" + ppr (ProofIrrelProv _) = text "(proof irrel.)" + ppr (PluginProv str cvs) = parens (text "plugin" <+> brackets (text str) <+> ppr cvs) -- | A coercion to be filled in by the type-checker. See Note [Coercion holes] data CoercionHole @@ -1690,6 +1693,50 @@ Here, where co5 :: (a1 ~ Bool) ~ (a2 ~ Bool) co5 = TyConAppCo Nominal (~#) [<*>, <*>, co4, ] + + +Note [The importance of tracking free coercion variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It is vital that `UnivCo` (a coercion that lacks a proper proof) +tracks its free coercion variables. To see why, consider this program: + + type S :: Nat -> Nat + + data T (a::Nat) where + T1 :: T 0 + T2 :: ... + + f :: T a -> S (a+1) -> S 1 + f = /\a (x:T a) (y:a). + case x of + T1 (gco : a ~# 0) -> y |> wco + +For this to typecheck we need `wco :: S (a+1) ~# S 1`, given that `gco : a ~# 0`. +To prove that we need to know that `a+1 = 1` if `a=0`, which a plugin might know. +So it solves `wco` by providing a `UnivCo (PluginProv "my-plugin" gcvs) (a+1) 1`. + + But the `gcvs` in `PluginProv` must mention `gco`. + +Why? Otherwise we might float the entire expression (y |> wco) out of the +the case alternative for `T1` which brings `gco` into scope. If this +happens then we aren't far from a segmentation fault or much worse. +See #23923 for a real-world example of this happening. + +So it is /crucial/ for the `PluginProv` to mention, in `gcvs`, the coercion +variables used by the plugin to justify the `UnivCo` that it builds. + +Note that we don't need to track +* the coercion's free *type* variables +* coercion variables free in kinds (we only need the "shallow" free covars) + +This means that we may float past type variables which the original +proof had as free variables. While surprising, this doesn't jeopardise +the validity of the coercion, which only depends upon the scoping +relative to the free coercion variables. + +(The free coercion variables are kept as a DCoVarSet in UnivCo, +since these sets are included in interface files.) + -} @@ -1856,7 +1903,9 @@ foldTyCo (TyCoFolder { tcf_view = view go_prov env (PhantomProv co) = go_co env co go_prov env (ProofIrrelProv co) = go_co env co - go_prov _ (PluginProv _) = mempty + go_prov _ (PluginProv _ cvs) = go_cvs env cvs + + go_cvs env cvs = foldl' (\ !acc cv -> acc `mappend` covar env cv) mempty (dVarSetElems cvs) -- | A view function that looks through nothing. noView :: Type -> Maybe Type @@ -1922,7 +1971,7 @@ coercionSize (AxiomRuleCo _ cs) = 1 + sum (map coercionSize cs) provSize :: UnivCoProvenance -> Int provSize (PhantomProv co) = 1 + coercionSize co provSize (ProofIrrelProv co) = 1 + coercionSize co -provSize (PluginProv _) = 1 +provSize (PluginProv _ _) = 1 {- ************************************************************************ ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -41,7 +41,7 @@ module GHC.Core.TyCo.Subst cloneTyVarBndr, cloneTyVarBndrs, substVarBndr, substVarBndrs, substTyVarBndr, substTyVarBndrs, - substCoVarBndr, + substCoVarBndr, substDCoVarSet, substTyVar, substTyVars, substTyVarToTyVar, substTyCoVars, substTyCoBndr, substForAllCoBndr, @@ -910,12 +910,18 @@ subst_co subst co go_prov (PhantomProv kco) = PhantomProv (go kco) go_prov (ProofIrrelProv kco) = ProofIrrelProv (go kco) - go_prov p@(PluginProv _) = p + go_prov (PluginProv s cvs) = PluginProv s $ substDCoVarSet subst cvs -- See Note [Substituting in a coercion hole] go_hole h@(CoercionHole { ch_co_var = cv }) = h { ch_co_var = updateVarType go_ty cv } +-- | Perform a substitution within a 'DVarSet' of free variables, +-- returning the shallow free coercion variables. +substDCoVarSet :: Subst -> DCoVarSet -> DCoVarSet +substDCoVarSet subst cvs = coVarsOfCosDSet $ map (substCoVar subst) $ + dVarSetElems cvs + substForAllCoBndr :: Subst -> TyCoVar -> KindCoercion -> (Subst, TyCoVar, Coercion) substForAllCoBndr subst ===================================== compiler/GHC/Core/TyCo/Tidy.hs ===================================== @@ -20,9 +20,11 @@ import GHC.Data.FastString import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs (tyCoVarsOfTypesWellScoped, tyCoVarsOfTypeList) +import GHC.Data.Maybe (orElse) import GHC.Types.Name hiding (varName) import GHC.Types.Var import GHC.Types.Var.Env +import GHC.Types.Var.Set import GHC.Utils.Misc (strictMap) import Data.List (mapAccumL) @@ -233,9 +235,7 @@ tidyCo env@(_, subst) co -- the case above duplicates a bit of work in tidying h and the kind -- of tv. But the alternative is to use coercionKind, which seems worse. go (FunCo r afl afr w co1 co2) = ((FunCo r afl afr $! go w) $! go co1) $! go co2 - go (CoVarCo cv) = case lookupVarEnv subst cv of - Nothing -> CoVarCo cv - Just cv' -> CoVarCo cv' + go (CoVarCo cv) = CoVarCo $! go_cv cv go (HoleCo h) = HoleCo h go (AxiomInstCo con ind cos) = AxiomInstCo con ind $! strictMap go cos go (UnivCo p r t1 t2) = (((UnivCo $! (go_prov p)) $! r) $! @@ -249,9 +249,11 @@ tidyCo env@(_, subst) co go (SubCo co) = SubCo $! go co go (AxiomRuleCo ax cos) = AxiomRuleCo ax $ strictMap go cos + go_cv cv = lookupVarEnv subst cv `orElse` cv + go_prov (PhantomProv co) = PhantomProv $! go co go_prov (ProofIrrelProv co) = ProofIrrelProv $! go co - go_prov p@(PluginProv _) = p + go_prov (PluginProv s cvs) = PluginProv s $ mapDVarSet go_cv cvs tidyCos :: TidyEnv -> [Coercion] -> [Coercion] tidyCos env = strictMap (tidyCo env) ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -580,7 +580,7 @@ expandTypeSynonyms ty go_prov subst (PhantomProv co) = PhantomProv (go_co subst co) go_prov subst (ProofIrrelProv co) = ProofIrrelProv (go_co subst co) - go_prov _ p@(PluginProv _) = p + go_prov _ p@(PluginProv _ _) = p -- the "False" and "const" are to accommodate the type of -- substForAllCoBndrUsing, which is general enough to @@ -912,7 +912,8 @@ mapTyCo mapper -> (go_ty (), go_tys (), go_co (), go_cos ()) {-# INLINE mapTyCoX #-} -- See Note [Specialising mappers] -mapTyCoX :: Monad m => TyCoMapper env m +mapTyCoX :: forall m env. Monad m + => TyCoMapper env m -> ( env -> Type -> m Type , env -> [Type] -> m [Type] , env -> Coercion -> m Coercion @@ -960,6 +961,7 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar go_mco !_ MRefl = return MRefl go_mco !env (MCo co) = MCo <$> (go_co env co) + go_co :: env -> Coercion -> m Coercion go_co !env (Refl ty) = Refl <$> go_ty env ty go_co !env (GRefl r ty mco) = mkGReflCo r <$> go_ty env ty <*> go_mco env mco go_co !env (AppCo c1 c2) = mkAppCo <$> go_co env c1 <*> go_co env c2 @@ -999,7 +1001,14 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar go_prov !env (PhantomProv co) = PhantomProv <$> go_co env co go_prov !env (ProofIrrelProv co) = ProofIrrelProv <$> go_co env co - go_prov !_ p@(PluginProv _) = return p + go_prov !env (PluginProv s cvs) = PluginProv s <$> strictFoldDVarSet (do_cv env) + (return emptyDVarSet) cvs + + do_cv :: env -> CoVar -> m DTyCoVarSet -> m DTyCoVarSet + do_cv env v mfvs = do { fvs <- mfvs + ; co <- covar env v + ; return (tyCoVarsOfCoDSet co `unionDVarSet` fvs) } + {- ********************************************************************* ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -88,6 +88,7 @@ import GHC.Utils.Panic import GHC.Utils.Misc import Data.Maybe ( isNothing, catMaybes ) +import Data.List ( partition ) {- Note [Avoiding space leaks in toIface*] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -318,9 +319,11 @@ toIfaceCoercionX fr co fr' = fr `delVarSet` tv go_prov :: UnivCoProvenance -> IfaceUnivCoProv - go_prov (PhantomProv co) = IfacePhantomProv (go co) - go_prov (ProofIrrelProv co) = IfaceProofIrrelProv (go co) - go_prov (PluginProv str) = IfacePluginProv str + go_prov (PhantomProv co) = IfacePhantomProv (go co) + go_prov (ProofIrrelProv co) = IfaceProofIrrelProv (go co) + go_prov (PluginProv str cvs) = IfacePluginProv str (map toIfaceCoVar bound_cvs) free_cvs + where + (free_cvs, bound_cvs) = partition (`elemVarSet` fr) (dVarSetElems cvs) toIfaceTcArgs :: TyCon -> [Type] -> IfaceAppArgs toIfaceTcArgs = toIfaceTcArgsX emptyVarSet ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -678,6 +678,8 @@ rnIfaceCo (IfaceAxiomInstCo n i cs) = IfaceAxiomInstCo <$> rnIfaceGlobal n <*> pure i <*> mapM rnIfaceCo cs rnIfaceCo (IfaceUnivCo s r t1 t2) = IfaceUnivCo s r <$> rnIfaceType t1 <*> rnIfaceType t2 + -- Renaming affects only type constructors, not coercion variables, + -- so no need to recurs into the provenance. rnIfaceCo (IfaceSymCo c) = IfaceSymCo <$> rnIfaceCo c rnIfaceCo (IfaceTransCo c1 c2) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1795,7 +1795,7 @@ freeNamesIfCoercion (IfaceAxiomRuleCo _ax cos) freeNamesIfProv :: IfaceUnivCoProv -> NameSet freeNamesIfProv (IfacePhantomProv co) = freeNamesIfCoercion co freeNamesIfProv (IfaceProofIrrelProv co) = freeNamesIfCoercion co -freeNamesIfProv (IfacePluginProv _) = emptyNameSet +freeNamesIfProv (IfacePluginProv _ _ _) = emptyNameSet freeNamesIfVarBndr :: VarBndr IfaceBndr vis -> NameSet freeNamesIfVarBndr (Bndr bndr _) = freeNamesIfBndr bndr ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -399,7 +399,10 @@ data IfaceCoercion data IfaceUnivCoProv = IfacePhantomProv IfaceCoercion | IfaceProofIrrelProv IfaceCoercion - | IfacePluginProv String + | IfacePluginProv String [IfLclName] [Var] + -- Local covars and open (free) covars resp + -- See Note [Free tyvars in IfaceType] + {- Note [Holes in IfaceCoercion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -620,7 +623,7 @@ substIfaceType env ty go_prov (IfacePhantomProv co) = IfacePhantomProv (go_co co) go_prov (IfaceProofIrrelProv co) = IfaceProofIrrelProv (go_co co) - go_prov co@(IfacePluginProv _) = co + go_prov co@(IfacePluginProv _ _ _) = co substIfaceAppArgs :: IfaceTySubst -> IfaceAppArgs -> IfaceAppArgs substIfaceAppArgs env args @@ -1954,8 +1957,8 @@ pprIfaceUnivCoProv (IfacePhantomProv co) = text "phantom" <+> pprParendIfaceCoercion co pprIfaceUnivCoProv (IfaceProofIrrelProv co) = text "irrel" <+> pprParendIfaceCoercion co -pprIfaceUnivCoProv (IfacePluginProv s) - = text "plugin" <+> doubleQuotes (text s) +pprIfaceUnivCoProv (IfacePluginProv s cvs fcvs) + = hang (text "plugin") 2 (sep [doubleQuotes (text s), ppr cvs, ppr fcvs]) ------------------- instance Outputable IfaceTyCon where @@ -2324,9 +2327,11 @@ instance Binary IfaceUnivCoProv where put_ bh (IfaceProofIrrelProv a) = do putByte bh 2 put_ bh a - put_ bh (IfacePluginProv a) = do + put_ bh (IfacePluginProv a cvs fcvs) = do putByte bh 3 put_ bh a + assertPpr (null fcvs) (ppr cvs $$ ppr fcvs) $ + put_ bh cvs get bh = do tag <- getByte bh @@ -2336,7 +2341,8 @@ instance Binary IfaceUnivCoProv where 2 -> do a <- get bh return $ IfaceProofIrrelProv a 3 -> do a <- get bh - return $ IfacePluginProv a + cvs <- get bh + return $ IfacePluginProv a cvs [] _ -> panic ("get IfaceUnivCoProv " ++ show tag) ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1491,7 +1491,10 @@ tcIfaceCo = go tcIfaceUnivCoProv :: IfaceUnivCoProv -> IfL UnivCoProvenance tcIfaceUnivCoProv (IfacePhantomProv kco) = PhantomProv <$> tcIfaceCo kco tcIfaceUnivCoProv (IfaceProofIrrelProv kco) = ProofIrrelProv <$> tcIfaceCo kco -tcIfaceUnivCoProv (IfacePluginProv str) = return $ PluginProv str +tcIfaceUnivCoProv (IfacePluginProv str cvs fcvs) = + assertPpr (null fcvs) (ppr fcvs) $ do + cvs' <- mapM tcIfaceLclId cvs + return $ PluginProv str $ mkDVarSet cvs' {- ************************************************************************ ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -156,7 +156,7 @@ synonymTyConsOfType ty go_prov (PhantomProv co) = go_co co go_prov (ProofIrrelProv co) = go_co co - go_prov (PluginProv _) = emptyNameEnv + go_prov (PluginProv _ _) = emptyNameEnv go_tc tc | isTypeSynonymTyCon tc = unitNameEnv (tyConName tc) tc | otherwise = emptyNameEnv ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -1592,7 +1592,10 @@ collect_cand_qtvs_co orig_ty cur_lvl bound = go_co go_prov dv (PhantomProv co) = go_co dv co go_prov dv (ProofIrrelProv co) = go_co dv co - go_prov dv (PluginProv _) = return dv + go_prov dv (PluginProv _ cvs) = strictFoldDVarSet zt_cv (return dv) cvs + + zt_cv :: CoVar -> TcM CandidatesQTvs -> TcM CandidatesQTvs + zt_cv cv mdvs = do { dvs <- mdvs; go_cv dvs cv } go_cv :: CandidatesQTvs -> CoVar -> TcM CandidatesQTvs go_cv dv@(DV { dv_cvs = cvs }) cv ===================================== compiler/GHC/Types/Unique/DSet.hs ===================================== @@ -33,7 +33,7 @@ module GHC.Types.Unique.DSet ( lookupUniqDSet, uniqDSetToList, partitionUniqDSet, - mapUniqDSet + mapUniqDSet, strictFoldUniqDSet ) where import GHC.Prelude @@ -125,7 +125,15 @@ partitionUniqDSet p = coerce . partitionUDFM p . getUniqDSet -- See Note [UniqSet invariant] in GHC.Types.Unique.Set mapUniqDSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b -mapUniqDSet f = mkUniqDSet . map f . uniqDSetToList +mapUniqDSet f (UniqDSet m) = UniqDSet $ unsafeCastUDFMKey $ mapUDFM f m +-- Simply apply `f` to each element, retaining all the structure unchanged. +-- The identification of keys and elements prevents a derived Functor +-- instance, but `unsafeCastUDFMKey` makes it possible to apply the strict +-- mapping from DFM. + +strictFoldUniqDSet :: (a -> r -> r) -> r -> UniqDSet a -> r +strictFoldUniqDSet k r s = foldl' (\ !r e -> k e r) r $ + uniqDSetToList s -- Two 'UniqDSet's are considered equal if they contain the same -- uniques. ===================================== compiler/GHC/Types/Var/Set.hs ===================================== @@ -26,7 +26,7 @@ module GHC.Types.Var.Set ( nonDetStrictFoldVarSet, -- * Deterministic Var set types - DVarSet, DIdSet, DTyVarSet, DTyCoVarSet, + DVarSet, DIdSet, DTyVarSet, DCoVarSet, DTyCoVarSet, -- ** Manipulating these sets emptyDVarSet, unitDVarSet, mkDVarSet, @@ -38,7 +38,7 @@ module GHC.Types.Var.Set ( isEmptyDVarSet, delDVarSet, delDVarSetList, minusDVarSet, nonDetStrictFoldDVarSet, - filterDVarSet, mapDVarSet, + filterDVarSet, mapDVarSet, strictFoldDVarSet, dVarSetMinusVarSet, anyDVarSet, allDVarSet, transCloDVarSet, sizeDVarSet, seqDVarSet, @@ -232,6 +232,9 @@ type DIdSet = UniqDSet Id -- | Deterministic Type Variable Set type DTyVarSet = UniqDSet TyVar +-- | Deterministic Coercion Variable Set +type DCoVarSet = UniqDSet CoVar + -- | Deterministic Type or Coercion Variable Set type DTyCoVarSet = UniqDSet TyCoVar @@ -308,6 +311,9 @@ allDVarSet p = allUDFM p . getUniqDSet mapDVarSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b mapDVarSet = mapUniqDSet +strictFoldDVarSet :: (a -> r -> r) -> r -> UniqDSet a -> r +strictFoldDVarSet = strictFoldUniqDSet + filterDVarSet :: (Var -> Bool) -> DVarSet -> DVarSet filterDVarSet = filterUniqDSet ===================================== compiler/GHC/Utils/FV.hs ===================================== @@ -21,6 +21,7 @@ module GHC.Utils.FV ( delFVs, filterFV, mapUnionFV, + fvDVarSetSome, ) where import GHC.Prelude @@ -195,3 +196,7 @@ mkFVs :: [Var] -> FV mkFVs vars fv_cand in_scope acc = mapUnionFV unitFV vars fv_cand in_scope acc {-# INLINE mkFVs #-} + +fvDVarSetSome :: InterestingVarFun -> FV -> DVarSet +fvDVarSetSome interesting_var fv = + mkDVarSet $ fst $ fv interesting_var emptyVarSet ([], emptyVarSet) ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -760,10 +760,33 @@ This evidence is ignored for Given constraints, which GHC "solves" simply by discarding them; typically this is used when they are uninformative (e.g. reflexive equations). For Wanted constraints, the evidence will form part of the Core term that is generated after -typechecking, and can be checked by ``-dcore-lint``. It is possible for -the plugin to create equality axioms for use in evidence terms, but GHC -does not check their consistency, and inconsistent axiom sets may lead -to segfaults or other runtime misbehaviour. +typechecking, and can be checked by ``-dcore-lint``. + +When solving a Wanted equality constraint (of type ``t1 ~N# t2`` +or ``t1 ~R# t2`` for nominal and representation equalities respectively), +the evidence (of type ``EvTerm``) will take the form ``EvExpr (Coercion co)``, +where the coercion ``co`` has type ``co :: t1 ~N# t2`` or ``co :: t1 ~R# t2`` +respectively. + +It is up to the plugin to construct a suitable coercion ``co``. +However, one possibility is to construct one of form :: + + UnivCo (PluginProv "my-plugin" gcvs) role t1 t2 + +A ``UnivCo`` of this form says "trust me: my-plugin has solved this Wanted +using (only) ``gcvs``". + +Here + +* The ``role`` should be the role of the original equality constraint + (nominal or representational). +* The ``gcvs`` is a set of "given coercion variables"; these are the coercion + variable bound by enclosing Given constraints, which the plugin has used + to justify solving the Wanted. + +For soundness, it is very important to include the ``gcvs``; otherwise +GHC may transform the program into a form that seg-faults. +See #23923 for a long dicussion. Evidence is required also when creating new Given constraints, which are usually implied by old ones. It is not uncommon that the evidence of a new ===================================== testsuite/tests/tcplugins/CtIdPlugin.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Tc.Plugin import GHC.Tc.Types import GHC.Tc.Types.Constraint import GHC.Tc.Types.Evidence +import GHC.Types.Unique.DSet -- common import Common @@ -41,7 +42,7 @@ solver :: [String] -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult solver _args defs ev givens wanteds = do - let pluginCo = mkUnivCo (PluginProv "CtIdPlugin") Representational + let pluginCo = mkUnivCo (PluginProv "CtIdPlugin" emptyUniqDSet) Representational -- Empty is fine. This plugin does not use "givens". let substEvidence ct ct' = evCast (ctEvExpr $ ctEvidence ct') $ pluginCo (ctPred ct') (ctPred ct) ===================================== testsuite/tests/tcplugins/RewritePlugin.hs ===================================== @@ -45,6 +45,8 @@ import GHC.Tc.Types.Constraint ) import GHC.Tc.Types.Evidence ( EvTerm(EvExpr), Role(Nominal) ) +import GHC.Types.Unique.DSet + ( emptyUniqDSet ) import GHC.Types.Unique.FM ( UniqFM, listToUFM ) @@ -85,5 +87,5 @@ mkTyFamReduction :: TyCon -> [ Type ] -> Type -> Reduction mkTyFamReduction tyCon args res = Reduction co res where co :: Coercion - co = mkUnivCo ( PluginProv "RewritePlugin" ) Nominal + co = mkUnivCo ( PluginProv "RewritePlugin" emptyUniqDSet) Nominal -- Empty is fine. This plugin does not use "givens". ( mkTyConApp tyCon args ) res ===================================== testsuite/tests/tcplugins/TyFamPlugin.hs ===================================== @@ -39,6 +39,8 @@ import GHC.Tc.Types.Constraint ) import GHC.Tc.Types.Evidence ( EvBindsVar, EvTerm(EvExpr), Role(Nominal) ) +import GHC.Types.Unique.DSet + ( emptyUniqDSet ) -- common import Common @@ -78,6 +80,6 @@ solveCt ( PluginDefs {..} ) ct@( classifyPredType . ctPred -> EqPred NomEq lhs r , let evTerm :: EvTerm evTerm = EvExpr . Coercion - $ mkUnivCo ( PluginProv "TyFamPlugin" ) Nominal lhs rhs + $ mkUnivCo ( PluginProv "TyFamPlugin" emptyUniqDSet) Nominal lhs rhs -- Empty is fine. This plugin does not use "givens". = pure $ Just ( evTerm, ct ) solveCt _ ct = pure Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4b131133e4cee35d2140eedfcf3b4e573a43a8a...053fdb81f509cc6158c5d645ef2402e24ca3c115 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4b131133e4cee35d2140eedfcf3b4e573a43a8a...053fdb81f509cc6158c5d645ef2402e24ca3c115 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 22:50:19 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Thu, 07 Mar 2024 17:50:19 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] dummy Message-ID: <65ea44abd59a7_17a6f245a16041227cd@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: d74bc723 by Mikolaj Konarski at 2024-03-07T23:50:08+01:00 dummy - - - - - 1 changed file: - compiler/GHC/Core/TyCo/Rep.hs Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1,4 +1,3 @@ - {-# LANGUAGE DeriveDataTypeable #-} {-# OPTIONS_HADDOCK not-home #-} @@ -1817,6 +1816,8 @@ foldTyCo (TyCoFolder { tcf_view = view = let !env' = tycobinder env tv vis -- Avoid building a thunk here in go_ty env (varType tv) `mappend` go_ty env' inner + + -- Explicit recursion because using foldr builds a local -- loop (with env free) and I'm not confident it'll be -- lambda lifted in the end View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d74bc7237300750eec8dc917bd86d1d4e1f2cde9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d74bc7237300750eec8dc917bd86d1d4e1f2cde9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 7 23:36:05 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 18:36:05 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] 113 commits: feat: Add sortOn to Data.List.NonEmpty Message-ID: <65ea4f659a592_17a6f259d1f84126539@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 2fe878a9 by Ben Gamari at 2024-03-07T17:44:24-05:00 rts/CloneStack: Bounds check array write - - - - - d432ba8a by Ben Gamari at 2024-03-07T17:44:24-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - c907af77 by Ben Gamari at 2024-03-07T18:33:18-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 44e11eb2 by Ben Gamari at 2024-03-07T18:33:18-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - cb280181 by Ben Gamari at 2024-03-07T18:33:18-05:00 rts/IPE: Don't expose helper in header - - - - - 94a14063 by Ben Gamari at 2024-03-07T18:33:18-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - 64b11438 by Ben Gamari at 2024-03-07T18:33:18-05:00 IPE: Include unit id - - - - - 422a541e by Ben Gamari at 2024-03-07T18:33:18-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 3c2c7b4e by Ben Gamari at 2024-03-07T18:33:18-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 21 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.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/ab1a832d7632b49b6290f95ae106aa257daacd93...3c2c7b4eff9c53e1fd3581d466efd034632cb176 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab1a832d7632b49b6290f95ae106aa257daacd93...3c2c7b4eff9c53e1fd3581d466efd034632cb176 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 00:20:33 2024 From: gitlab at gitlab.haskell.org (Mikolaj Konarski (@Mikolaj)) Date: Thu, 07 Mar 2024 19:20:33 -0500 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] 2 commits: Add DCoVarSet to PluginProv Message-ID: <65ea59d12d68_17a6f26c7c7d81284a0@gitlab.mail> Mikolaj Konarski pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: 70f2d3ee by Mikolaj Konarski at 2024-03-07T00:34:41+01:00 Add DCoVarSet to PluginProv Add the only remaining piece of feedback from git add src/Flavour.hs Help CI check some more of the patch Fix the 3 plugin tests that fail Explain better how shallowCoVarsOfCosDSet is entangled with a hundreds of lines bit-rotten refactoring Fix according to the first round of Simon's instruction Fix according to the second round of Simon's instruction Remove a question-comment that's probably absurd Fix according to the third round of Simon's instruction - - - - - 053fdb81 by Mikolaj Konarski at 2024-03-07T00:34:41+01:00 Make sure the foldl' accumulators are strict - - - - - 23 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Types/Unique/DSet.hs - compiler/GHC/Types/Var/Set.hs - compiler/GHC/Utils/FV.hs - docs/users_guide/extending_ghc.rst - testsuite/tests/tcplugins/CtIdPlugin.hs - testsuite/tests/tcplugins/RewritePlugin.hs - testsuite/tests/tcplugins/TyFamPlugin.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -97,7 +97,7 @@ module GHC.Core.Coercion ( emptyLiftingContext, extendLiftingContext, extendLiftingContextAndInScope, liftCoSubstVarBndrUsing, isMappedByLC, extendLiftingContextCvSubst, - mkSubstLiftingContext, zapLiftingContext, + mkSubstLiftingContext, liftingContextSubst, zapLiftingContext, substForAllCoBndrUsingLC, lcLookupCoVar, lcInScopeSet, LiftCoEnv, LiftingContext(..), liftEnvSubstLeft, liftEnvSubstRight, @@ -1397,7 +1397,7 @@ setNominalRole_maybe r co setNominalRole_maybe_helper (UnivCo prov _ co1 co2) | case prov of PhantomProv _ -> False -- should always be phantom ProofIrrelProv _ -> True -- it's always safe - PluginProv _ -> False -- who knows? This choice is conservative. + PluginProv _ _ -> False -- who knows? This choice is conservative. = Just $ UnivCo prov Nominal co1 co2 setNominalRole_maybe_helper _ = Nothing @@ -1522,7 +1522,7 @@ promoteCoercion co = case co of UnivCo (PhantomProv kco) _ _ _ -> kco UnivCo (ProofIrrelProv kco) _ _ _ -> kco - UnivCo (PluginProv _) _ _ _ -> mkKindCo co + UnivCo (PluginProv _ _) _ _ _ -> mkKindCo co SymCo g -> mkSymCo (promoteCoercion g) @@ -1979,6 +1979,9 @@ mkLiftingContext pairs mkSubstLiftingContext :: Subst -> LiftingContext mkSubstLiftingContext subst = LC subst emptyVarEnv +liftingContextSubst :: LiftingContext -> Subst +liftingContextSubst (LC subst _) = subst + -- | Extend a lifting context with a new mapping. extendLiftingContext :: LiftingContext -- ^ original LC -> TyCoVar -- ^ new variable to map... @@ -2354,7 +2357,7 @@ seqCo (AxiomRuleCo _ cs) = seqCos cs seqProv :: UnivCoProvenance -> () seqProv (PhantomProv co) = seqCo co seqProv (ProofIrrelProv co) = seqCo co -seqProv (PluginProv _) = () +seqProv (PluginProv _ cvs) = seqDVarSet cvs seqCos :: [Coercion] -> () seqCos [] = () ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -641,7 +641,7 @@ opt_univ env sym prov role oty1 oty2 where prov' = case prov of ProofIrrelProv kco -> ProofIrrelProv $ opt_co4_wrap env sym False Nominal kco - PluginProv _ -> prov + PluginProv s cvs -> PluginProv s $ substDCoVarSet (liftingContextSubst env) cvs ------------- opt_transList :: HasDebugCallStack => InScopeSet -> [NormalCo] -> [NormalCo] -> [NormalCo] @@ -722,7 +722,8 @@ opt_trans_rule is in_co1@(UnivCo p1 r1 tyl1 _tyr1) = Just $ PhantomProv $ opt_trans is kco1 kco2 opt_trans_prov (ProofIrrelProv kco1) (ProofIrrelProv kco2) = Just $ ProofIrrelProv $ opt_trans is kco1 kco2 - opt_trans_prov (PluginProv str1) (PluginProv str2) | str1 == str2 = Just p1 + opt_trans_prov (PluginProv str1 cvs1) (PluginProv str2 cvs2) + | str1 == str2 = Just (PluginProv str1 (cvs1 `unionDVarSet` cvs2)) opt_trans_prov _ _ = Nothing -- Push transitivity down through matching top-level constructors. ===================================== compiler/GHC/Core/FVs.hs ===================================== @@ -410,7 +410,7 @@ orphNamesOfCo (HoleCo _) = emptyNameSet orphNamesOfProv :: UnivCoProvenance -> NameSet orphNamesOfProv (PhantomProv co) = orphNamesOfCo co orphNamesOfProv (ProofIrrelProv co) = orphNamesOfCo co -orphNamesOfProv (PluginProv _) = emptyNameSet +orphNamesOfProv (PluginProv _ _) = emptyNameSet orphNamesOfCos :: [Coercion] -> NameSet orphNamesOfCos = orphNamesOfThings orphNamesOfCo ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1931,6 +1931,13 @@ checkTyCon :: TyCon -> LintM () checkTyCon tc = checkL (not (isTcTyCon tc)) (text "Found TcTyCon:" <+> ppr tc) +------------------- +checkTyCoVarInScope :: Subst -> TyCoVar -> LintM () +checkTyCoVarInScope subst tcv + = checkL (tcv `isInScope` subst) $ + hang (text "The type or coercion variable" <+> pprBndr LetBind tcv) + 2 (text "is out of scope") + ------------------- lintType :: Type -> LintM LintedType @@ -1948,12 +1955,8 @@ lintType (TyVarTy tv) -- In GHCi we may lint an expression with a free -- type variable. Then it won't be in the -- substitution, but it should be in scope - Nothing | tv `isInScope` subst - -> return (TyVarTy tv) - | otherwise - -> failWithL $ - hang (text "The type variable" <+> pprBndr LetBind tv) - 2 (text "is out of scope") + Nothing -> do { checkTyCoVarInScope subst tv + ; return (TyVarTy tv) } } lintType ty@(AppTy t1 t2) @@ -2325,15 +2328,8 @@ lintCoercion (CoVarCo cv) = do { subst <- getSubst ; case lookupCoVar subst cv of Just linted_co -> return linted_co ; - Nothing - | cv `isInScope` subst - -> return (CoVarCo cv) - | otherwise - -> - -- lintCoBndr always extends the substitution - failWithL $ - hang (text "The coercion variable" <+> pprBndr LetBind cv) - 2 (text "is out of scope") + Nothing -> do { checkTyCoVarInScope subst cv + ; return (CoVarCo cv) } } @@ -2532,7 +2528,12 @@ lintCoercion co@(UnivCo prov r ty1 ty2) ; check_kinds kco k1 k2 ; return (ProofIrrelProv kco') } - lint_prov _ _ prov@(PluginProv _) = return prov + lint_prov _ _ (PluginProv s cvs) + = do { subst <- getSubst + ; mapM_ (checkTyCoVarInScope subst) (dVarSetElems cvs) + -- Don't bother to return substituted fvs; + -- they don't matter to Lint + ; return (PluginProv s cvs) } check_kinds kco k1 k2 = do { let Pair k1' k2' = coercionKind kco ===================================== compiler/GHC/Core/TyCo/FVs.hs ===================================== @@ -19,6 +19,7 @@ module GHC.Core.TyCo.FVs tyCoVarsOfCoDSet, tyCoFVsOfCo, tyCoFVsOfCos, tyCoVarsOfCoList, + coVarsOfCosDSet, almostDevoidCoVarOfCo, @@ -446,6 +447,13 @@ deepCoVarFolder = TyCoFolder { tcf_view = noView -- See Note [CoercionHoles and coercion free variables] -- in GHC.Core.TyCo.Rep +------- Same again, but for DCoVarSet ---------- +-- But this time the free vars are shallow + +coVarsOfCosDSet :: [Coercion] -> DCoVarSet +coVarsOfCosDSet cos = fvDVarSetSome isCoVar (tyCoFVsOfCos cos) + + {- ********************************************************************* * * Closing over kinds @@ -660,7 +668,7 @@ tyCoFVsOfCoVar v fv_cand in_scope acc tyCoFVsOfProv :: UnivCoProvenance -> FV tyCoFVsOfProv (PhantomProv co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc tyCoFVsOfProv (ProofIrrelProv co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc -tyCoFVsOfProv (PluginProv _) fv_cand in_scope acc = emptyFV fv_cand in_scope acc +tyCoFVsOfProv (PluginProv _ cvs) fv_cand in_scope acc = mkFVs (dVarSetElems cvs) fv_cand in_scope acc tyCoFVsOfCos :: [Coercion] -> FV tyCoFVsOfCos [] fv_cand in_scope acc = emptyFV fv_cand in_scope acc @@ -730,7 +738,7 @@ almost_devoid_co_var_of_prov (PhantomProv co) cv = almost_devoid_co_var_of_co co cv almost_devoid_co_var_of_prov (ProofIrrelProv co) cv = almost_devoid_co_var_of_co co cv -almost_devoid_co_var_of_prov (PluginProv _) _ = True +almost_devoid_co_var_of_prov (PluginProv _ cvs) cv = not (cv `elemDVarSet` cvs) almost_devoid_co_var_of_type :: Type -> CoVar -> Bool almost_devoid_co_var_of_type (TyVarTy _) _ = True @@ -1129,7 +1137,7 @@ tyConsOfType ty go_prov (PhantomProv co) = go_co co go_prov (ProofIrrelProv co) = go_co co - go_prov (PluginProv _) = emptyUniqSet + go_prov (PluginProv _ _) = emptyUniqSet go_cos cos = foldr (unionUniqSets . go_co) emptyUniqSet cos @@ -1340,4 +1348,4 @@ occCheckExpand vs_to_avoid ty ------------------ go_prov cxt (PhantomProv co) = PhantomProv <$> go_co cxt co go_prov cxt (ProofIrrelProv co) = ProofIrrelProv <$> go_co cxt co - go_prov _ p@(PluginProv _) = return p + go_prov _ p@(PluginProv _ _) = return p ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1,4 +1,3 @@ - {-# LANGUAGE DeriveDataTypeable #-} {-# OPTIONS_HADDOCK not-home #-} @@ -78,7 +77,7 @@ import {-# SOURCE #-} GHC.Core.Type( chooseFunTyFlag, typeKind, typeTypeOrConstr -- friends: import GHC.Types.Var -import GHC.Types.Var.Set( elemVarSet ) +import GHC.Types.Var.Set( DCoVarSet, dVarSetElems, elemVarSet ) import GHC.Core.TyCon import GHC.Core.Coercion.Axiom @@ -886,7 +885,7 @@ data Coercion | FunCo -- FunCo :: "e" -> N/P -> e -> e -> e -- See Note [FunCo] for fco_afl, fco_afr - { fco_role :: Role + { fco_role :: Role , fco_afl :: FunTyFlag -- Arrow for coercionLKind , fco_afr :: FunTyFlag -- Arrow for coercionRKind , fco_mult :: CoercionN @@ -1527,15 +1526,19 @@ data UnivCoProvenance -- considered equivalent. See Note [ProofIrrelProv]. -- Can be used in Nominal or Representational coercions - | PluginProv String -- ^ From a plugin, which asserts that this coercion - -- is sound. The string is for the use of the plugin. + | PluginProv String !DCoVarSet + -- ^ From a plugin, which asserts that this coercion is sound. + -- The string and the variable set are for the use by the plugin. + -- E.g., the set may contain the in-scope coercion variables + -- that the the proof represented by the coercion makes use of. + -- See Note [The importance of tracking free coercion variables]. deriving Data.Data instance Outputable UnivCoProvenance where - ppr (PhantomProv _) = text "(phantom)" - ppr (ProofIrrelProv _) = text "(proof irrel.)" - ppr (PluginProv str) = parens (text "plugin" <+> brackets (text str)) + ppr (PhantomProv _) = text "(phantom)" + ppr (ProofIrrelProv _) = text "(proof irrel.)" + ppr (PluginProv str cvs) = parens (text "plugin" <+> brackets (text str) <+> ppr cvs) -- | A coercion to be filled in by the type-checker. See Note [Coercion holes] data CoercionHole @@ -1690,6 +1693,50 @@ Here, where co5 :: (a1 ~ Bool) ~ (a2 ~ Bool) co5 = TyConAppCo Nominal (~#) [<*>, <*>, co4, ] + + +Note [The importance of tracking free coercion variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It is vital that `UnivCo` (a coercion that lacks a proper proof) +tracks its free coercion variables. To see why, consider this program: + + type S :: Nat -> Nat + + data T (a::Nat) where + T1 :: T 0 + T2 :: ... + + f :: T a -> S (a+1) -> S 1 + f = /\a (x:T a) (y:a). + case x of + T1 (gco : a ~# 0) -> y |> wco + +For this to typecheck we need `wco :: S (a+1) ~# S 1`, given that `gco : a ~# 0`. +To prove that we need to know that `a+1 = 1` if `a=0`, which a plugin might know. +So it solves `wco` by providing a `UnivCo (PluginProv "my-plugin" gcvs) (a+1) 1`. + + But the `gcvs` in `PluginProv` must mention `gco`. + +Why? Otherwise we might float the entire expression (y |> wco) out of the +the case alternative for `T1` which brings `gco` into scope. If this +happens then we aren't far from a segmentation fault or much worse. +See #23923 for a real-world example of this happening. + +So it is /crucial/ for the `PluginProv` to mention, in `gcvs`, the coercion +variables used by the plugin to justify the `UnivCo` that it builds. + +Note that we don't need to track +* the coercion's free *type* variables +* coercion variables free in kinds (we only need the "shallow" free covars) + +This means that we may float past type variables which the original +proof had as free variables. While surprising, this doesn't jeopardise +the validity of the coercion, which only depends upon the scoping +relative to the free coercion variables. + +(The free coercion variables are kept as a DCoVarSet in UnivCo, +since these sets are included in interface files.) + -} @@ -1856,7 +1903,9 @@ foldTyCo (TyCoFolder { tcf_view = view go_prov env (PhantomProv co) = go_co env co go_prov env (ProofIrrelProv co) = go_co env co - go_prov _ (PluginProv _) = mempty + go_prov _ (PluginProv _ cvs) = go_cvs env cvs + + go_cvs env cvs = foldl' (\ !acc cv -> acc `mappend` covar env cv) mempty (dVarSetElems cvs) -- | A view function that looks through nothing. noView :: Type -> Maybe Type @@ -1922,7 +1971,7 @@ coercionSize (AxiomRuleCo _ cs) = 1 + sum (map coercionSize cs) provSize :: UnivCoProvenance -> Int provSize (PhantomProv co) = 1 + coercionSize co provSize (ProofIrrelProv co) = 1 + coercionSize co -provSize (PluginProv _) = 1 +provSize (PluginProv _ _) = 1 {- ************************************************************************ ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -41,7 +41,7 @@ module GHC.Core.TyCo.Subst cloneTyVarBndr, cloneTyVarBndrs, substVarBndr, substVarBndrs, substTyVarBndr, substTyVarBndrs, - substCoVarBndr, + substCoVarBndr, substDCoVarSet, substTyVar, substTyVars, substTyVarToTyVar, substTyCoVars, substTyCoBndr, substForAllCoBndr, @@ -910,12 +910,18 @@ subst_co subst co go_prov (PhantomProv kco) = PhantomProv (go kco) go_prov (ProofIrrelProv kco) = ProofIrrelProv (go kco) - go_prov p@(PluginProv _) = p + go_prov (PluginProv s cvs) = PluginProv s $ substDCoVarSet subst cvs -- See Note [Substituting in a coercion hole] go_hole h@(CoercionHole { ch_co_var = cv }) = h { ch_co_var = updateVarType go_ty cv } +-- | Perform a substitution within a 'DVarSet' of free variables, +-- returning the shallow free coercion variables. +substDCoVarSet :: Subst -> DCoVarSet -> DCoVarSet +substDCoVarSet subst cvs = coVarsOfCosDSet $ map (substCoVar subst) $ + dVarSetElems cvs + substForAllCoBndr :: Subst -> TyCoVar -> KindCoercion -> (Subst, TyCoVar, Coercion) substForAllCoBndr subst ===================================== compiler/GHC/Core/TyCo/Tidy.hs ===================================== @@ -20,9 +20,11 @@ import GHC.Data.FastString import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs (tyCoVarsOfTypesWellScoped, tyCoVarsOfTypeList) +import GHC.Data.Maybe (orElse) import GHC.Types.Name hiding (varName) import GHC.Types.Var import GHC.Types.Var.Env +import GHC.Types.Var.Set import GHC.Utils.Misc (strictMap) import Data.List (mapAccumL) @@ -233,9 +235,7 @@ tidyCo env@(_, subst) co -- the case above duplicates a bit of work in tidying h and the kind -- of tv. But the alternative is to use coercionKind, which seems worse. go (FunCo r afl afr w co1 co2) = ((FunCo r afl afr $! go w) $! go co1) $! go co2 - go (CoVarCo cv) = case lookupVarEnv subst cv of - Nothing -> CoVarCo cv - Just cv' -> CoVarCo cv' + go (CoVarCo cv) = CoVarCo $! go_cv cv go (HoleCo h) = HoleCo h go (AxiomInstCo con ind cos) = AxiomInstCo con ind $! strictMap go cos go (UnivCo p r t1 t2) = (((UnivCo $! (go_prov p)) $! r) $! @@ -249,9 +249,11 @@ tidyCo env@(_, subst) co go (SubCo co) = SubCo $! go co go (AxiomRuleCo ax cos) = AxiomRuleCo ax $ strictMap go cos + go_cv cv = lookupVarEnv subst cv `orElse` cv + go_prov (PhantomProv co) = PhantomProv $! go co go_prov (ProofIrrelProv co) = ProofIrrelProv $! go co - go_prov p@(PluginProv _) = p + go_prov (PluginProv s cvs) = PluginProv s $ mapDVarSet go_cv cvs tidyCos :: TidyEnv -> [Coercion] -> [Coercion] tidyCos env = strictMap (tidyCo env) ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -580,7 +580,7 @@ expandTypeSynonyms ty go_prov subst (PhantomProv co) = PhantomProv (go_co subst co) go_prov subst (ProofIrrelProv co) = ProofIrrelProv (go_co subst co) - go_prov _ p@(PluginProv _) = p + go_prov _ p@(PluginProv _ _) = p -- the "False" and "const" are to accommodate the type of -- substForAllCoBndrUsing, which is general enough to @@ -912,7 +912,8 @@ mapTyCo mapper -> (go_ty (), go_tys (), go_co (), go_cos ()) {-# INLINE mapTyCoX #-} -- See Note [Specialising mappers] -mapTyCoX :: Monad m => TyCoMapper env m +mapTyCoX :: forall m env. Monad m + => TyCoMapper env m -> ( env -> Type -> m Type , env -> [Type] -> m [Type] , env -> Coercion -> m Coercion @@ -960,6 +961,7 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar go_mco !_ MRefl = return MRefl go_mco !env (MCo co) = MCo <$> (go_co env co) + go_co :: env -> Coercion -> m Coercion go_co !env (Refl ty) = Refl <$> go_ty env ty go_co !env (GRefl r ty mco) = mkGReflCo r <$> go_ty env ty <*> go_mco env mco go_co !env (AppCo c1 c2) = mkAppCo <$> go_co env c1 <*> go_co env c2 @@ -999,7 +1001,14 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar go_prov !env (PhantomProv co) = PhantomProv <$> go_co env co go_prov !env (ProofIrrelProv co) = ProofIrrelProv <$> go_co env co - go_prov !_ p@(PluginProv _) = return p + go_prov !env (PluginProv s cvs) = PluginProv s <$> strictFoldDVarSet (do_cv env) + (return emptyDVarSet) cvs + + do_cv :: env -> CoVar -> m DTyCoVarSet -> m DTyCoVarSet + do_cv env v mfvs = do { fvs <- mfvs + ; co <- covar env v + ; return (tyCoVarsOfCoDSet co `unionDVarSet` fvs) } + {- ********************************************************************* ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -88,6 +88,7 @@ import GHC.Utils.Panic import GHC.Utils.Misc import Data.Maybe ( isNothing, catMaybes ) +import Data.List ( partition ) {- Note [Avoiding space leaks in toIface*] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -318,9 +319,11 @@ toIfaceCoercionX fr co fr' = fr `delVarSet` tv go_prov :: UnivCoProvenance -> IfaceUnivCoProv - go_prov (PhantomProv co) = IfacePhantomProv (go co) - go_prov (ProofIrrelProv co) = IfaceProofIrrelProv (go co) - go_prov (PluginProv str) = IfacePluginProv str + go_prov (PhantomProv co) = IfacePhantomProv (go co) + go_prov (ProofIrrelProv co) = IfaceProofIrrelProv (go co) + go_prov (PluginProv str cvs) = IfacePluginProv str (map toIfaceCoVar bound_cvs) free_cvs + where + (free_cvs, bound_cvs) = partition (`elemVarSet` fr) (dVarSetElems cvs) toIfaceTcArgs :: TyCon -> [Type] -> IfaceAppArgs toIfaceTcArgs = toIfaceTcArgsX emptyVarSet ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -678,6 +678,8 @@ rnIfaceCo (IfaceAxiomInstCo n i cs) = IfaceAxiomInstCo <$> rnIfaceGlobal n <*> pure i <*> mapM rnIfaceCo cs rnIfaceCo (IfaceUnivCo s r t1 t2) = IfaceUnivCo s r <$> rnIfaceType t1 <*> rnIfaceType t2 + -- Renaming affects only type constructors, not coercion variables, + -- so no need to recurs into the provenance. rnIfaceCo (IfaceSymCo c) = IfaceSymCo <$> rnIfaceCo c rnIfaceCo (IfaceTransCo c1 c2) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1795,7 +1795,7 @@ freeNamesIfCoercion (IfaceAxiomRuleCo _ax cos) freeNamesIfProv :: IfaceUnivCoProv -> NameSet freeNamesIfProv (IfacePhantomProv co) = freeNamesIfCoercion co freeNamesIfProv (IfaceProofIrrelProv co) = freeNamesIfCoercion co -freeNamesIfProv (IfacePluginProv _) = emptyNameSet +freeNamesIfProv (IfacePluginProv _ _ _) = emptyNameSet freeNamesIfVarBndr :: VarBndr IfaceBndr vis -> NameSet freeNamesIfVarBndr (Bndr bndr _) = freeNamesIfBndr bndr ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -399,7 +399,10 @@ data IfaceCoercion data IfaceUnivCoProv = IfacePhantomProv IfaceCoercion | IfaceProofIrrelProv IfaceCoercion - | IfacePluginProv String + | IfacePluginProv String [IfLclName] [Var] + -- Local covars and open (free) covars resp + -- See Note [Free tyvars in IfaceType] + {- Note [Holes in IfaceCoercion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -620,7 +623,7 @@ substIfaceType env ty go_prov (IfacePhantomProv co) = IfacePhantomProv (go_co co) go_prov (IfaceProofIrrelProv co) = IfaceProofIrrelProv (go_co co) - go_prov co@(IfacePluginProv _) = co + go_prov co@(IfacePluginProv _ _ _) = co substIfaceAppArgs :: IfaceTySubst -> IfaceAppArgs -> IfaceAppArgs substIfaceAppArgs env args @@ -1954,8 +1957,8 @@ pprIfaceUnivCoProv (IfacePhantomProv co) = text "phantom" <+> pprParendIfaceCoercion co pprIfaceUnivCoProv (IfaceProofIrrelProv co) = text "irrel" <+> pprParendIfaceCoercion co -pprIfaceUnivCoProv (IfacePluginProv s) - = text "plugin" <+> doubleQuotes (text s) +pprIfaceUnivCoProv (IfacePluginProv s cvs fcvs) + = hang (text "plugin") 2 (sep [doubleQuotes (text s), ppr cvs, ppr fcvs]) ------------------- instance Outputable IfaceTyCon where @@ -2324,9 +2327,11 @@ instance Binary IfaceUnivCoProv where put_ bh (IfaceProofIrrelProv a) = do putByte bh 2 put_ bh a - put_ bh (IfacePluginProv a) = do + put_ bh (IfacePluginProv a cvs fcvs) = do putByte bh 3 put_ bh a + assertPpr (null fcvs) (ppr cvs $$ ppr fcvs) $ + put_ bh cvs get bh = do tag <- getByte bh @@ -2336,7 +2341,8 @@ instance Binary IfaceUnivCoProv where 2 -> do a <- get bh return $ IfaceProofIrrelProv a 3 -> do a <- get bh - return $ IfacePluginProv a + cvs <- get bh + return $ IfacePluginProv a cvs [] _ -> panic ("get IfaceUnivCoProv " ++ show tag) ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1491,7 +1491,10 @@ tcIfaceCo = go tcIfaceUnivCoProv :: IfaceUnivCoProv -> IfL UnivCoProvenance tcIfaceUnivCoProv (IfacePhantomProv kco) = PhantomProv <$> tcIfaceCo kco tcIfaceUnivCoProv (IfaceProofIrrelProv kco) = ProofIrrelProv <$> tcIfaceCo kco -tcIfaceUnivCoProv (IfacePluginProv str) = return $ PluginProv str +tcIfaceUnivCoProv (IfacePluginProv str cvs fcvs) = + assertPpr (null fcvs) (ppr fcvs) $ do + cvs' <- mapM tcIfaceLclId cvs + return $ PluginProv str $ mkDVarSet cvs' {- ************************************************************************ ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -156,7 +156,7 @@ synonymTyConsOfType ty go_prov (PhantomProv co) = go_co co go_prov (ProofIrrelProv co) = go_co co - go_prov (PluginProv _) = emptyNameEnv + go_prov (PluginProv _ _) = emptyNameEnv go_tc tc | isTypeSynonymTyCon tc = unitNameEnv (tyConName tc) tc | otherwise = emptyNameEnv ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -1592,7 +1592,10 @@ collect_cand_qtvs_co orig_ty cur_lvl bound = go_co go_prov dv (PhantomProv co) = go_co dv co go_prov dv (ProofIrrelProv co) = go_co dv co - go_prov dv (PluginProv _) = return dv + go_prov dv (PluginProv _ cvs) = strictFoldDVarSet zt_cv (return dv) cvs + + zt_cv :: CoVar -> TcM CandidatesQTvs -> TcM CandidatesQTvs + zt_cv cv mdvs = do { dvs <- mdvs; go_cv dvs cv } go_cv :: CandidatesQTvs -> CoVar -> TcM CandidatesQTvs go_cv dv@(DV { dv_cvs = cvs }) cv ===================================== compiler/GHC/Types/Unique/DSet.hs ===================================== @@ -33,7 +33,7 @@ module GHC.Types.Unique.DSet ( lookupUniqDSet, uniqDSetToList, partitionUniqDSet, - mapUniqDSet + mapUniqDSet, strictFoldUniqDSet ) where import GHC.Prelude @@ -125,7 +125,15 @@ partitionUniqDSet p = coerce . partitionUDFM p . getUniqDSet -- See Note [UniqSet invariant] in GHC.Types.Unique.Set mapUniqDSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b -mapUniqDSet f = mkUniqDSet . map f . uniqDSetToList +mapUniqDSet f (UniqDSet m) = UniqDSet $ unsafeCastUDFMKey $ mapUDFM f m +-- Simply apply `f` to each element, retaining all the structure unchanged. +-- The identification of keys and elements prevents a derived Functor +-- instance, but `unsafeCastUDFMKey` makes it possible to apply the strict +-- mapping from DFM. + +strictFoldUniqDSet :: (a -> r -> r) -> r -> UniqDSet a -> r +strictFoldUniqDSet k r s = foldl' (\ !r e -> k e r) r $ + uniqDSetToList s -- Two 'UniqDSet's are considered equal if they contain the same -- uniques. ===================================== compiler/GHC/Types/Var/Set.hs ===================================== @@ -26,7 +26,7 @@ module GHC.Types.Var.Set ( nonDetStrictFoldVarSet, -- * Deterministic Var set types - DVarSet, DIdSet, DTyVarSet, DTyCoVarSet, + DVarSet, DIdSet, DTyVarSet, DCoVarSet, DTyCoVarSet, -- ** Manipulating these sets emptyDVarSet, unitDVarSet, mkDVarSet, @@ -38,7 +38,7 @@ module GHC.Types.Var.Set ( isEmptyDVarSet, delDVarSet, delDVarSetList, minusDVarSet, nonDetStrictFoldDVarSet, - filterDVarSet, mapDVarSet, + filterDVarSet, mapDVarSet, strictFoldDVarSet, dVarSetMinusVarSet, anyDVarSet, allDVarSet, transCloDVarSet, sizeDVarSet, seqDVarSet, @@ -232,6 +232,9 @@ type DIdSet = UniqDSet Id -- | Deterministic Type Variable Set type DTyVarSet = UniqDSet TyVar +-- | Deterministic Coercion Variable Set +type DCoVarSet = UniqDSet CoVar + -- | Deterministic Type or Coercion Variable Set type DTyCoVarSet = UniqDSet TyCoVar @@ -308,6 +311,9 @@ allDVarSet p = allUDFM p . getUniqDSet mapDVarSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b mapDVarSet = mapUniqDSet +strictFoldDVarSet :: (a -> r -> r) -> r -> UniqDSet a -> r +strictFoldDVarSet = strictFoldUniqDSet + filterDVarSet :: (Var -> Bool) -> DVarSet -> DVarSet filterDVarSet = filterUniqDSet ===================================== compiler/GHC/Utils/FV.hs ===================================== @@ -21,6 +21,7 @@ module GHC.Utils.FV ( delFVs, filterFV, mapUnionFV, + fvDVarSetSome, ) where import GHC.Prelude @@ -195,3 +196,7 @@ mkFVs :: [Var] -> FV mkFVs vars fv_cand in_scope acc = mapUnionFV unitFV vars fv_cand in_scope acc {-# INLINE mkFVs #-} + +fvDVarSetSome :: InterestingVarFun -> FV -> DVarSet +fvDVarSetSome interesting_var fv = + mkDVarSet $ fst $ fv interesting_var emptyVarSet ([], emptyVarSet) ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -760,10 +760,33 @@ This evidence is ignored for Given constraints, which GHC "solves" simply by discarding them; typically this is used when they are uninformative (e.g. reflexive equations). For Wanted constraints, the evidence will form part of the Core term that is generated after -typechecking, and can be checked by ``-dcore-lint``. It is possible for -the plugin to create equality axioms for use in evidence terms, but GHC -does not check their consistency, and inconsistent axiom sets may lead -to segfaults or other runtime misbehaviour. +typechecking, and can be checked by ``-dcore-lint``. + +When solving a Wanted equality constraint (of type ``t1 ~N# t2`` +or ``t1 ~R# t2`` for nominal and representation equalities respectively), +the evidence (of type ``EvTerm``) will take the form ``EvExpr (Coercion co)``, +where the coercion ``co`` has type ``co :: t1 ~N# t2`` or ``co :: t1 ~R# t2`` +respectively. + +It is up to the plugin to construct a suitable coercion ``co``. +However, one possibility is to construct one of form :: + + UnivCo (PluginProv "my-plugin" gcvs) role t1 t2 + +A ``UnivCo`` of this form says "trust me: my-plugin has solved this Wanted +using (only) ``gcvs``". + +Here + +* The ``role`` should be the role of the original equality constraint + (nominal or representational). +* The ``gcvs`` is a set of "given coercion variables"; these are the coercion + variable bound by enclosing Given constraints, which the plugin has used + to justify solving the Wanted. + +For soundness, it is very important to include the ``gcvs``; otherwise +GHC may transform the program into a form that seg-faults. +See #23923 for a long dicussion. Evidence is required also when creating new Given constraints, which are usually implied by old ones. It is not uncommon that the evidence of a new ===================================== testsuite/tests/tcplugins/CtIdPlugin.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Tc.Plugin import GHC.Tc.Types import GHC.Tc.Types.Constraint import GHC.Tc.Types.Evidence +import GHC.Types.Unique.DSet -- common import Common @@ -41,7 +42,7 @@ solver :: [String] -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult solver _args defs ev givens wanteds = do - let pluginCo = mkUnivCo (PluginProv "CtIdPlugin") Representational + let pluginCo = mkUnivCo (PluginProv "CtIdPlugin" emptyUniqDSet) Representational -- Empty is fine. This plugin does not use "givens". let substEvidence ct ct' = evCast (ctEvExpr $ ctEvidence ct') $ pluginCo (ctPred ct') (ctPred ct) ===================================== testsuite/tests/tcplugins/RewritePlugin.hs ===================================== @@ -45,6 +45,8 @@ import GHC.Tc.Types.Constraint ) import GHC.Tc.Types.Evidence ( EvTerm(EvExpr), Role(Nominal) ) +import GHC.Types.Unique.DSet + ( emptyUniqDSet ) import GHC.Types.Unique.FM ( UniqFM, listToUFM ) @@ -85,5 +87,5 @@ mkTyFamReduction :: TyCon -> [ Type ] -> Type -> Reduction mkTyFamReduction tyCon args res = Reduction co res where co :: Coercion - co = mkUnivCo ( PluginProv "RewritePlugin" ) Nominal + co = mkUnivCo ( PluginProv "RewritePlugin" emptyUniqDSet) Nominal -- Empty is fine. This plugin does not use "givens". ( mkTyConApp tyCon args ) res ===================================== testsuite/tests/tcplugins/TyFamPlugin.hs ===================================== @@ -39,6 +39,8 @@ import GHC.Tc.Types.Constraint ) import GHC.Tc.Types.Evidence ( EvBindsVar, EvTerm(EvExpr), Role(Nominal) ) +import GHC.Types.Unique.DSet + ( emptyUniqDSet ) -- common import Common @@ -78,6 +80,6 @@ solveCt ( PluginDefs {..} ) ct@( classifyPredType . ctPred -> EqPred NomEq lhs r , let evTerm :: EvTerm evTerm = EvExpr . Coercion - $ mkUnivCo ( PluginProv "TyFamPlugin" ) Nominal lhs rhs + $ mkUnivCo ( PluginProv "TyFamPlugin" emptyUniqDSet) Nominal lhs rhs -- Empty is fine. This plugin does not use "givens". = pure $ Just ( evTerm, ct ) solveCt _ ct = pure Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d74bc7237300750eec8dc917bd86d1d4e1f2cde9...053fdb81f509cc6158c5d645ef2402e24ca3c115 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d74bc7237300750eec8dc917bd86d1d4e1f2cde9...053fdb81f509cc6158c5d645ef2402e24ca3c115 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 00:29:57 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 19:29:57 -0500 Subject: [Git][ghc/ghc][wip/T24515] 3 commits: Rephrase error message to say "visible arguments" (#24318) Message-ID: <65ea5c05787e_17a6f27314168129094@gitlab.mail> Ben Gamari pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - 164ffe9b by Ben Gamari at 2024-03-07T19:29:45-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 3731e3a5 by Cheng Shao at 2024-03-07T19:29:45-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 29 changed files: - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - testsuite/driver/testlib.py - testsuite/tests/ado/ado002.stderr - testsuite/tests/ghci/scripts/Defer02.stderr - testsuite/tests/indexed-types/should_compile/T10806.stderr - testsuite/tests/indexed-types/should_fail/T8518.stderr - testsuite/tests/rep-poly/T23903.stderr - testsuite/tests/th/T5358.stderr - testsuite/tests/typecheck/should_fail/DoExpansion2.stderr - testsuite/tests/typecheck/should_fail/DoExpansion3.stderr - testsuite/tests/typecheck/should_fail/FD1.stderr - testsuite/tests/typecheck/should_fail/T13902.stderr - testsuite/tests/typecheck/should_fail/T17139.stderr - + testsuite/tests/typecheck/should_fail/T24318.hs - + testsuite/tests/typecheck/should_fail/T24318.stderr - testsuite/tests/typecheck/should_fail/T8603.stderr - testsuite/tests/typecheck/should_fail/T9605.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail001.stderr - testsuite/tests/typecheck/should_fail/tcfail140.stderr - testsuite/tests/typecheck/should_fail/tcfail175.stderr - testsuite/tests/vdq-rta/should_fail/T22326_fail_n_args.stderr - testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr Changes: ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -75,7 +75,7 @@ import GHC.Driver.DynFlags ( getDynFlags ) import GHC.Types.Name import GHC.Types.Id import GHC.Types.SrcLoc -import GHC.Types.Basic( Arity, isDoExpansionGenerated ) +import GHC.Types.Basic( VisArity, isDoExpansionGenerated ) import Control.Monad import Control.Arrow ( second ) @@ -1207,7 +1207,7 @@ the variables they bind into scope, and typecheck the thing_inside. -- The MatchGroup for `f` has arity 2, not 3 checkArgCounts :: AnnoBody body => MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM Arity + -> TcM VisArity checkArgCounts (MG { mg_alts = L _ [] }) = return 1 -- See Note [Empty MatchGroups] in GHC.Rename.Bind -- case e of {} or \case {} @@ -1227,6 +1227,6 @@ checkArgCounts (MG { mg_alts = L _ (match1:matches) }) n_args1 = reqd_args_in_match match1 mb_bad_matches = NE.nonEmpty [m | m <- matches, reqd_args_in_match m /= n_args1] - reqd_args_in_match :: LocatedA (Match GhcRn body1) -> Arity + reqd_args_in_match :: LocatedA (Match GhcRn body1) -> VisArity -- Counts the number of /required/ args in the match reqd_args_in_match (L _ (Match { m_pats = pats })) = count (isVisArgPat . unLoc) pats ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -751,7 +751,7 @@ Example: matchExpectedFunTys :: forall a. ExpectedFunTyOrigin -- See Note [Herald for matchExpectedFunTys] -> UserTypeCtxt - -> Arity + -> VisArity -> ExpSigmaType -> ([ExpPatType] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) @@ -777,7 +777,7 @@ matchExpectedFunTys herald _ arity (Infer inf_res) thing_inside matchExpectedFunTys herald ctx arity (Check top_ty) thing_inside = check 0 [] top_ty where - check :: Arity -> [ExpPatType] -> TcSigmaType -> TcM (HsWrapper, a) + check :: VisArity -> [ExpPatType] -> TcSigmaType -> TcM (HsWrapper, a) -- `check` is called only in the Check{} case -- It collects rev_pat_tys in reversed order -- n_so_far is the number of /visible/ arguments seen so far: @@ -875,7 +875,7 @@ matchExpectedFunTys herald ctx arity (Check top_ty) thing_inside defer n_so_far rev_pat_tys res_ty ------------ - defer :: Arity -> [ExpPatType] -> TcRhoType -> TcM (HsWrapper, a) + defer :: VisArity -> [ExpPatType] -> TcRhoType -> TcM (HsWrapper, a) defer n_so_far rev_pat_tys fun_ty = do { more_arg_tys <- mapM (new_check_arg_ty herald) [n_so_far + 1 .. arity] ; let all_pats = reverse rev_pat_tys ++ map mkCheckExpFunPatTy more_arg_tys @@ -898,19 +898,15 @@ new_check_arg_ty herald arg_pos -- Position for error messages only ; return (mkScaled mult arg_ty) } mkFunTysMsg :: ExpectedFunTyOrigin - -> (Arity, TcType) + -> (VisArity, TcType) -> TidyEnv -> ZonkM (TidyEnv, SDoc) -- See Note [Reporting application arity errors] -mkFunTysMsg herald (n_val_args_in_call, fun_ty) env +mkFunTysMsg herald (n_vis_args_in_call, fun_ty) env = do { (env', fun_ty) <- zonkTidyTcType env fun_ty ; let (pi_ty_bndrs, _) = splitPiTys fun_ty - - -- `all_arg_tys` contains visible quantifiers only, so their number matches - -- the number of arguments that the user needs to pass to the function. n_fun_args = count isVisiblePiTyBinder pi_ty_bndrs - - msg | n_val_args_in_call <= n_fun_args -- Enough args, in the end + msg | n_vis_args_in_call <= n_fun_args -- Enough args, in the end = text "In the result of a function call" | otherwise = hang (full_herald <> comma) @@ -921,7 +917,8 @@ mkFunTysMsg herald (n_val_args_in_call, fun_ty) env ; return (env', msg) } where full_herald = pprExpectedFunTyHerald herald - <+> speakNOf n_val_args_in_call (text "value argument") + <+> speakNOf n_vis_args_in_call (text "visible argument") + -- What are "visible" arguments? See Note [Visibility and arity] in GHC.Types.Basic {- Note [Reporting application arity errors] @@ -931,8 +928,8 @@ and the call foo = f 3 4 5 We'd like to get an error like: • Couldn't match expected type ‘t0 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to three value arguments, - but its type ‘Int -> Int -> Int’ has only two + • The function ‘f’ is applied to three visible arguments, -- What are "visible" arguments? + but its type ‘Int -> Int -> Int’ has only two -- See Note [Visibility and arity] in GHC.Types.Basic That is what `mkFunTysMsg` tries to do. But what is the "type of the function". Most obviously, we can report its full, polymorphic type; that is simple and @@ -943,7 +940,7 @@ We get this error: • Couldn't match type ‘Int’ with ‘t0 -> t’ Expected: Int -> t0 -> t Actual: Int -> Int - • The function ‘f’ is applied to three value arguments, + • The function ‘f’ is applied to three visible arguments, but its type ‘Bool -> t Int Int’ has only one That's not /quite/ right beause we can instantiate `t` to an arrow and get ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -28,7 +28,7 @@ module GHC.Types.Basic ( ConTag, ConTagZ, fIRST_TAG, - Arity, RepArity, JoinArity, FullArgCount, + Arity, VisArity, RepArity, JoinArity, FullArgCount, JoinPointHood(..), isJoinPoint, Alignment, mkAlignment, alignmentOf, alignmentBytes, @@ -183,6 +183,10 @@ instance Binary LeftOrRight where -- See also Note [Definition of arity] in "GHC.Core.Opt.Arity" type Arity = Int +-- | Syntactic (visibility) arity, i.e. the number of visible arguments. +-- See Note [Visibility and arity] +type VisArity = Int + -- | Representation Arity -- -- The number of represented arguments that can be applied to a value before it does @@ -203,6 +207,71 @@ type JoinArity = Int -- both type and value arguments! type FullArgCount = Int +{- Note [Visibility and arity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Arity is the number of arguments that a function expects. In a curried language +like Haskell, there is more than one way to count those arguments. + +* `Arity` is the classic notion of arity, concerned with evalution, so it counts + the number of /value/ arguments that need to be supplied before evaluation can + take place, as described in notes + Note [Definition of arity] in GHC.Core.Opt.Arity + Note [Arity and function types] in GHC.Types.Id.Info + + Examples: + Int has arity == 0 + Int -> Int has arity <= 1 + Int -> Bool -> Int has arity <= 2 + We write (<=) rather than (==) as sometimes evaluation can occur before all + value arguments are supplied, depending on the actual function definition. + + This evaluation-focused notion of arity ignores type arguments, so: + forall a. a has arity == 0 + forall a. a -> a has arity <= 1 + forall a b. a -> b -> a has arity <= 2 + This is true regardless of ForAllTyFlag, so the arity is also unaffected by + (forall {a}. ty) or (forall a -> ty). + + Class dictionaries count towards the arity, as they are passed at runtime + forall a. (Num a) => a has arity <= 1 + forall a. (Num a) => a -> a has arity <= 2 + forall a b. (Num a, Ord b) => a -> b -> a has arity <= 4 + +* `VisArity` is the syntactic notion of arity. It is the number of /visible/ + arguments, i.e. arguments that occur visibly in the source code. + + In a function call `f x y z`, we can confidently say that f's vis-arity >= 3, + simply because we see three arguments [x,y,z]. We write (>=) rather than (==) + as this could be a partial application. + + At definition sites, we can acquire an underapproximation of vis-arity by + counting the patterns on the LHS, e.g. `f a b = rhs` has vis-arity >= 2. + The actual vis-arity can be higher if there is a lambda on the RHS, + e.g. `f a b = \c -> rhs`. + + If we look at the types, we can observe the following + * function arrows (a -> b) add to the vis-arity + * visible foralls (forall a -> b) add to the vis-arity + * constraint arrows (a => b) do not affect the vis-arity + * invisible foralls (forall a. b) do not affect the vis-arity + + This means that ForAllTyFlag matters for VisArity (in contrast to Arity), + while the type/value distinction is unimportant (again in contrast to Arity). + + Examples: + Int -- vis-arity == 0 (no args) + Int -> Int -- vis-arity == 1 (1 funarg) + forall a. a -> a -- vis-arity == 1 (1 funarg) + forall a. Num a => a -> a -- vis-arity == 1 (1 funarg) + forall a -> Num a => a -- vis-arity == 1 (1 req tyarg, 0 funargs) + forall a -> a -> a -- vis-arity == 2 (1 req tyarg, 1 funarg) + Int -> forall a -> Int -- vis-arity == 2 (1 funarg, 1 req tyarg) + + Wrinkle: with TypeApplications and TypeAbstractions, it is possible to visibly + bind and pass invisible arguments, e.g. `f @a x = ...` or `f @Int 42`. Those + @-prefixed arguments are ignored for the purposes of vis-arity. +-} + {- ************************************************************************ * * ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(stem, ".exe"); +#elif defined(wasm32_HOST_OS) + dropExtension(stem, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasm32_HOST_OS) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" ===================================== testsuite/driver/testlib.py ===================================== @@ -2329,14 +2329,13 @@ def write_file(f: Path, s: str) -> None: async def check_hp_ok(name: TestName) -> bool: opts = getTestOpts() - actual_name = name + exe_extension() if not opts.ignore_extension else name # do not qualify for hp2ps because we should be in the right directory - hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {actual_name}'.format(**locals()) + hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {name}'.format(**locals()) hp2psResult = await runCmd(hp2psCmd, print_output=True) - actual_ps_path = in_testdir(actual_name, 'ps') + actual_ps_path = in_testdir(name, 'ps') if hp2psResult == 0: if actual_ps_path.exists(): @@ -2345,15 +2344,15 @@ async def check_hp_ok(name: TestName) -> bool: if (gsResult == 0): return True else: - print("hp2ps output for " + actual_name + " is not valid PostScript") + print("hp2ps output for " + name + " is not valid PostScript") return False else: return True # assume postscript is valid without ghostscript else: - print("hp2ps did not generate PostScript for " + actual_name) + print("hp2ps did not generate PostScript for " + name) return False else: - print("hp2ps error when processing heap profile for " + actual_name) + print("hp2ps error when processing heap profile for " + name) return False async def check_prof_ok(name: TestName, way: WayName) -> bool: @@ -2365,7 +2364,7 @@ async def check_prof_ok(name: TestName, way: WayName) -> bool: if not expected_prof_path.exists(): return True - actual_prof_file = add_suffix(name + exe_extension(), 'prof') + actual_prof_file = add_suffix(name, 'prof') actual_prof_path = in_testdir(actual_prof_file) if not actual_prof_path.exists(): ===================================== testsuite/tests/ado/ado002.stderr ===================================== @@ -2,7 +2,7 @@ ado002.hs:8:8: error: [GHC-83865] • Couldn't match expected type: Char -> IO b0 with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: y <- getChar 'a' In the expression: @@ -45,7 +45,7 @@ ado002.hs:15:13: error: [GHC-83865] ado002.hs:23:9: error: [GHC-83865] • Couldn't match expected type: Char -> IO a0 with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: x5 <- getChar x4 In the expression: ===================================== testsuite/tests/ghci/scripts/Defer02.stderr ===================================== @@ -26,7 +26,7 @@ Defer01.hs:24:4: warning: [GHC-40564] [-Winaccessible-code (in -Wdefault)] Defer01.hs:30:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one value argument, + • The function ‘e’ is applied to one visible argument, but its type ‘Char’ has none In the expression: e 'q' In an equation for ‘f’: f = e 'q' @@ -95,7 +95,7 @@ Defer01.hs:49:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] (deferred type error) *** Exception: Defer01.hs:30:5: error: [GHC-83865] • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one value argument, + • The function ‘e’ is applied to one visible argument, but its type ‘Char’ has none In the expression: e 'q' In an equation for ‘f’: f = e 'q' ===================================== testsuite/tests/indexed-types/should_compile/T10806.stderr ===================================== @@ -2,7 +2,7 @@ T10806.hs:11:32: error: [GHC-83865] • Couldn't match expected type: Char -> Bool with actual type: IO () - • The function ‘print’ is applied to two value arguments, + • The function ‘print’ is applied to two visible arguments, but its type ‘Show a => a -> IO ()’ has only one In the expression: print 'x' 'y' In an equation for ‘triggersLoop’: ===================================== testsuite/tests/indexed-types/should_fail/T8518.stderr ===================================== @@ -2,7 +2,7 @@ T8518.hs:14:18: error: [GHC-83865] • Couldn't match expected type: Z c -> B c -> t0 with actual type: F c - • The function ‘rpt’ is applied to four value arguments, + • The function ‘rpt’ is applied to four visible arguments, but its type ‘t1 -> t2 -> F t2’ has only two In the expression: rpt (4 :: Int) c z b In an equation for ‘callCont’: ===================================== testsuite/tests/rep-poly/T23903.stderr ===================================== @@ -6,5 +6,5 @@ T23903.hs:21:1: error: [GHC-55287] t0 :: TYPE cx0 Cannot unify ‘Rep a’ with the type variable ‘cx0’ because the former is not a concrete ‘RuntimeRep’. - • The equation for ‘f’ has one value argument, + • The equation for ‘f’ has one visible argument, but its type ‘a #-> ()’ has none ===================================== testsuite/tests/th/T5358.stderr ===================================== @@ -1,17 +1,17 @@ T5358.hs:7:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t1 -> t1’ - • The equation for ‘t1’ has one value argument, + • The equation for ‘t1’ has one visible argument, but its type ‘Int’ has none T5358.hs:8:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t0 -> t0’ - • The equation for ‘t2’ has one value argument, + • The equation for ‘t2’ has one visible argument, but its type ‘Int’ has none T5358.hs:10:13: error: [GHC-83865] • Couldn't match expected type ‘t -> a0’ with actual type ‘Int’ - • The function ‘t1’ is applied to one value argument, + • The function ‘t1’ is applied to one visible argument, but its type ‘Int’ has none In the first argument of ‘(==)’, namely ‘t1 x’ In the expression: t1 x == t2 x @@ -21,7 +21,7 @@ T5358.hs:10:13: error: [GHC-83865] T5358.hs:10:21: error: [GHC-83865] • Couldn't match expected type ‘t -> a0’ with actual type ‘Int’ - • The function ‘t2’ is applied to one value argument, + • The function ‘t2’ is applied to one visible argument, but its type ‘Int’ has none In the second argument of ‘(==)’, namely ‘t2 x’ In the expression: t1 x == t2 x ===================================== testsuite/tests/typecheck/should_fail/DoExpansion2.stderr ===================================== @@ -55,7 +55,7 @@ DoExpansion2.hs:31:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type: t0 -> IO (Maybe Int) with actual type: IO String - • The function ‘getVal’ is applied to two value arguments, + • The function ‘getVal’ is applied to two visible arguments, but its type ‘Int -> IO String’ has only one In a stmt of a 'do' block: Just x <- getVal 3 4 In the expression: ===================================== testsuite/tests/typecheck/should_fail/DoExpansion3.stderr ===================================== @@ -10,7 +10,7 @@ DoExpansion3.hs:15:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul DoExpansion3.hs:18:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type: t0 -> t with actual type: IO Char - • The function ‘getChar’ is applied to one value argument, + • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In the expression: getChar 2 In an equation for ‘y’: y = getChar 2 ===================================== testsuite/tests/typecheck/should_fail/FD1.stderr ===================================== @@ -5,6 +5,6 @@ FD1.hs:16:1: error: [GHC-25897] the type signature for: plus :: forall a. E a (Int -> Int) => Int -> a at FD1.hs:15:1-38 - • The equation for ‘plus’ has two value arguments, + • The equation for ‘plus’ has two visible arguments, but its type ‘Int -> a’ has only one • Relevant bindings include plus :: Int -> a (bound at FD1.hs:16:1) ===================================== testsuite/tests/typecheck/should_fail/T13902.stderr ===================================== @@ -1,7 +1,7 @@ T13902.hs:8:5: error: [GHC-83865] • Couldn't match expected type ‘t0 -> Int’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘a -> a’ has only one In the expression: f @Int 42 5 In an equation for ‘g’: g = f @Int 42 5 ===================================== testsuite/tests/typecheck/should_fail/T17139.stderr ===================================== @@ -7,7 +7,7 @@ T17139.hs:15:16: error: [GHC-88464] lift :: forall a b (f :: * -> *). (a -> b) -> TypeFam f (a -> b) at T17139.hs:14:1-38 • In the expression: _ (f <*> x) - The lambda expression ‘\ x -> ...’ has one value argument, + The lambda expression ‘\ x -> ...’ has one visible argument, but its type ‘TypeFam f (a -> b)’ has none In the expression: \ x -> _ (f <*> x) • Relevant bindings include ===================================== testsuite/tests/typecheck/should_fail/T24318.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE ExplicitNamespaces, RequiredTypeArguments #-} + +module T24318 where + +import Data.Kind + +f :: forall (a :: Type) -> Bool +f (type t) x = True ===================================== testsuite/tests/typecheck/should_fail/T24318.stderr ===================================== @@ -0,0 +1,5 @@ + +T24318.hs:8:1: error: [GHC-83865] + • Couldn't match expected type ‘Bool’ with actual type ‘t0 -> Bool’ + • The equation for ‘f’ has two visible arguments, + but its type ‘forall a -> Bool’ has only one ===================================== testsuite/tests/typecheck/should_fail/T8603.stderr ===================================== @@ -6,7 +6,7 @@ T8603.hs:33:17: error: [GHC-18872] [a2] :: * Expected: [a2] -> StateT s RV a0 Actual: t0 ((->) [a1]) (StateT s RV a0) - • The function ‘lift’ is applied to two value arguments, + • The function ‘lift’ is applied to two visible arguments, but its type ‘(Control.Monad.Trans.Class.MonadTrans t, Monad m) => m a -> t m a’ has only one ===================================== testsuite/tests/typecheck/should_fail/T9605.stderr ===================================== @@ -3,7 +3,7 @@ T9605.hs:7:6: error: [GHC-83865] • Couldn't match type ‘Bool’ with ‘m Bool’ Expected: t0 -> m Bool Actual: t0 -> Bool - • The function ‘f1’ is applied to one value argument, + • The function ‘f1’ is applied to one visible argument, but its type ‘Monad m => m Bool’ has none In the expression: f1 undefined In an equation for ‘f2’: f2 = f1 undefined ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -712,6 +712,7 @@ test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always test('T24064', normal, compile_fail, ['']) test('T24298', normal, compile_fail, ['']) test('T24279', normal, compile_fail, ['']) +test('T24318', normal, compile_fail, ['']) # all the various do expansion fail messages test('DoExpansion1', normal, compile, ['-fdefer-type-errors']) ===================================== testsuite/tests/typecheck/should_fail/tcfail001.stderr ===================================== @@ -2,7 +2,7 @@ tcfail001.hs:9:2: error: [GHC-83865] • Couldn't match expected type: [a] with actual type: [a0] -> [a1] - • The equation for ‘op’ has one value argument, + • The equation for ‘op’ has one visible argument, but its type ‘[a]’ has none In the instance declaration for ‘A [a]’ • Relevant bindings include op :: [a] (bound at tcfail001.hs:9:2) ===================================== testsuite/tests/typecheck/should_fail/tcfail140.stderr ===================================== @@ -1,7 +1,7 @@ tcfail140.hs:11:7: error: [GHC-83865] • Couldn't match expected type ‘t1 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘Int -> Int’ has only one In the expression: f 3 9 In an equation for ‘bar’: bar = f 3 9 @@ -9,7 +9,7 @@ tcfail140.hs:11:7: error: [GHC-83865] tcfail140.hs:13:10: error: [GHC-83865] • Couldn't match expected type ‘t2 -> t’ with actual type ‘Int’ - • The function ‘f’ is applied to two value arguments, + • The function ‘f’ is applied to two visible arguments, but its type ‘Int -> Int’ has only one In the expression: 3 `f` 4 In an equation for ‘rot’: rot xs = 3 `f` 4 @@ -28,11 +28,11 @@ tcfail140.hs:15:15: error: [GHC-83865] tcfail140.hs:17:8: error: [GHC-27346] • The data constructor ‘Just’ should have 1 argument, but has been given none • In the pattern: Just - The lambda expression ‘\ Just x -> ...’ has two value arguments, + The lambda expression ‘\ Just x -> ...’ has two visible arguments, but its type ‘Maybe a -> a’ has only one In the expression: ((\ Just x -> x) :: Maybe a -> a) (Just 1) tcfail140.hs:20:1: error: [GHC-83865] • Couldn't match expected type ‘Int’ with actual type ‘t0 -> Bool’ - • The equation for ‘g’ has two value arguments, + • The equation for ‘g’ has two visible arguments, but its type ‘Int -> Int’ has only one ===================================== testsuite/tests/typecheck/should_fail/tcfail175.stderr ===================================== @@ -6,7 +6,7 @@ tcfail175.hs:11:1: error: [GHC-25897] the type signature for: evalRHS :: forall a. Int -> a at tcfail175.hs:10:1-19 - • The equation for ‘evalRHS’ has three value arguments, + • The equation for ‘evalRHS’ has three visible arguments, but its type ‘Int -> a’ has only one • Relevant bindings include evalRHS :: Int -> a (bound at tcfail175.hs:11:1) ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_n_args.stderr ===================================== @@ -5,5 +5,5 @@ T22326_fail_n_args.hs:6:1: error: [GHC-25897] the type signature for: f :: a -> forall b -> b at T22326_fail_n_args.hs:6:1-26 - • The equation for ‘f’ has three value arguments, + • The equation for ‘f’ has three visible arguments, but its type ‘a -> forall b -> b’ has only two ===================================== testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr ===================================== @@ -37,7 +37,7 @@ CaretDiagnostics1.hs:13:7-11: error: [GHC-83865] CaretDiagnostics1.hs:(13,16)-(14,13): error: [GHC-83865] • Couldn't match expected type ‘Char -> t0’ with actual type ‘()’ - • The function ‘()’ is applied to one value argument, + • The function ‘()’ is applied to one visible argument, but its type ‘()’ has none In the expression: () '0' In a case alternative: "γηξ" -> () '0' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c3e02f83edf7fc92e7514f2f05eb0f5c4e9d582...3731e3a528143a87927802c7d8c35ba9088f6dfa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c3e02f83edf7fc92e7514f2f05eb0f5c4e9d582...3731e3a528143a87927802c7d8c35ba9088f6dfa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 00:41:12 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 07 Mar 2024 19:41:12 -0500 Subject: [Git][ghc/ghc][master] 10 commits: Bump array submodule Message-ID: <65ea5ea8c0b0f_17a6f279276181331c7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr - libraries/base/tests/IO/openFile002.stderr - libraries/base/tests/IO/openFile002.stderr-mingw32 - libraries/base/tests/IO/withBinaryFile001.stderr - libraries/base/tests/IO/withBinaryFile002.stderr - libraries/base/tests/IO/withFile001.stderr - libraries/base/tests/IO/withFile002.stderr - libraries/base/tests/IO/withFileBlocking001.stderr - libraries/base/tests/IO/withFileBlocking002.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9cd9efb4de3757fd5eaec006739f75cef288e5eb...dc646e6f8e67add661628f2382fd0b65ed99b4f9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9cd9efb4de3757fd5eaec006739f75cef288e5eb...dc646e6f8e67add661628f2382fd0b65ed99b4f9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 00:42:00 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 07 Mar 2024 19:42:00 -0500 Subject: [Git][ghc/ghc][master] Update showAstData to honour blanking of AnnParen Message-ID: <65ea5ed8c9a3_17a6f27ade25413667@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 12 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/parser/should_compile/T20452.stderr - testsuite/tests/parser/should_compile/T23315/T23315.stderr Changes: ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -71,6 +71,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 `extQ` annotationEpaLocation `extQ` annotationNoEpAnns `extQ` addEpAnn + `extQ` annParen `extQ` lit `extQ` litr `extQ` litt `extQ` sourceText `extQ` deltaPos @@ -173,27 +174,21 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 srcSpan :: SrcSpan -> SDoc srcSpan ss = case bs of BlankSrcSpan -> text "{ ss }" - NoBlankSrcSpan -> braces $ char ' ' <> - (hang (ppr ss) 1 - -- TODO: show annotations here - (text "")) - BlankSrcSpanFile -> braces $ char ' ' <> - (hang (pprUserSpan False ss) 1 - -- TODO: show annotations here - (text "")) + NoBlankSrcSpan -> braces $ char ' ' <> (ppr ss) <> char ' ' + BlankSrcSpanFile -> braces $ char ' ' <> (pprUserSpan False ss) <> char ' ' realSrcSpan :: RealSrcSpan -> SDoc realSrcSpan ss = case bs of BlankSrcSpan -> text "{ ss }" - NoBlankSrcSpan -> braces $ char ' ' <> - (hang (ppr ss) 1 - -- TODO: show annotations here - (text "")) - BlankSrcSpanFile -> braces $ char ' ' <> - (hang (pprUserRealSpan False ss) 1 - -- TODO: show annotations here - (text "")) + NoBlankSrcSpan -> braces $ char ' ' <> (ppr ss) <> char ' ' + BlankSrcSpanFile -> braces $ char ' ' <> (pprUserRealSpan False ss) <> char ' ' + annParen :: AnnParen -> SDoc + annParen (AnnParen a o c) = case ba of + BlankEpAnnotations -> parens $ text "blanked:" <+> text "AnnParen" + NoBlankEpAnnotations -> + parens $ text "AnnParen" + $$ vcat [ppr a, epaAnchor o, epaAnchor c] addEpAnn :: AddEpAnn -> SDoc addEpAnn (AddEpAnn a s) = case ba of ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -745,7 +745,7 @@ data ParenType = AnnParens -- ^ '(', ')' | AnnParensHash -- ^ '(#', '#)' | AnnParensSquare -- ^ '[', ']' - deriving (Eq, Ord, Data) + deriving (Eq, Ord, Data, Show) -- | Maps the 'ParenType' to the related opening and closing -- AnnKeywordId. Used when actually printing the item. @@ -1452,6 +1452,8 @@ instance (Outputable a, OutputableBndr e) pprInfixOcc = pprInfixOcc . unLoc pprPrefixOcc = pprPrefixOcc . unLoc +instance Outputable ParenType where + ppr t = text (show t) instance Outputable AnnListItem where ppr (AnnListItem ts) = text "AnnListItem" <+> ppr ts ===================================== testsuite/tests/ghc-api/exactprint/Test20239.stderr ===================================== @@ -200,10 +200,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { Test20239.hs:7:50 }) - (EpaSpan { Test20239.hs:7:86 })) + (AnnParen AnnParens (EpaSpan { Test20239.hs:7:50 }) (EpaSpan { Test20239.hs:7:86 })) (L (EpAnn (EpaSpan { Test20239.hs:7:51-85 }) @@ -272,10 +269,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { Test20239.hs:7:68 }) - (EpaSpan { Test20239.hs:7:85 })) + (AnnParen AnnParens (EpaSpan { Test20239.hs:7:68 }) (EpaSpan { Test20239.hs:7:85 })) (L (EpAnn (EpaSpan { Test20239.hs:7:69-84 }) @@ -340,10 +334,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { Test20239.hs:7:83 }) - (EpaSpan { Test20239.hs:7:84 })) + (AnnParen AnnParens (EpaSpan { Test20239.hs:7:83 }) (EpaSpan { Test20239.hs:7:84 })) (HsBoxedOrConstraintTuple) [])))))))))))))]) (Nothing)))]) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -227,10 +227,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { T17544_kw.hs:19:18 }) - (EpaSpan { T17544_kw.hs:19:19 })) + (AnnParen AnnParens (EpaSpan { T17544_kw.hs:19:18 }) (EpaSpan { T17544_kw.hs:19:19 })) (HsBoxedOrConstraintTuple) [])))]) (L ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -228,10 +228,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { DumpParsedAst.hs:9:16 }) - (EpaSpan { DumpParsedAst.hs:9:18 })) + (AnnParen AnnParensSquare (EpaSpan { DumpParsedAst.hs:9:16 }) (EpaSpan { DumpParsedAst.hs:9:18 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:9:17 }) @@ -318,10 +315,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:11:10 }) - (EpaSpan { DumpParsedAst.hs:11:17 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:11:10 }) (EpaSpan { DumpParsedAst.hs:11:17 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:11:11-16 }) @@ -416,10 +410,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:11:26 }) - (EpaSpan { DumpParsedAst.hs:11:36 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:11:26 }) (EpaSpan { DumpParsedAst.hs:11:36 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:11:27-35 }) @@ -564,10 +555,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { DumpParsedAst.hs:10:27 }) - (EpaSpan { DumpParsedAst.hs:10:29 })) + (AnnParen AnnParensSquare (EpaSpan { DumpParsedAst.hs:10:27 }) (EpaSpan { DumpParsedAst.hs:10:29 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:10:28 }) @@ -744,10 +732,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:15:25 }) - (EpaSpan { DumpParsedAst.hs:15:29 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:15:25 }) (EpaSpan { DumpParsedAst.hs:15:29 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:15:26-28 }) @@ -882,10 +867,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:17:17 }) - (EpaSpan { DumpParsedAst.hs:17:27 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:17:17 }) (EpaSpan { DumpParsedAst.hs:17:27 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:17:18-26 }) @@ -1478,10 +1460,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:22:22 }) - (EpaSpan { DumpParsedAst.hs:22:37 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:22:22 }) (EpaSpan { DumpParsedAst.hs:22:37 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:22:23-36 }) @@ -1588,10 +1567,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:22:42 }) - (EpaSpan { DumpParsedAst.hs:22:52 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:22:42 }) (EpaSpan { DumpParsedAst.hs:22:52 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:22:43-51 }) @@ -1712,10 +1688,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { DumpParsedAst.hs:23:10 }) - (EpaSpan { DumpParsedAst.hs:23:34 })) + (AnnParen AnnParens (EpaSpan { DumpParsedAst.hs:23:10 }) (EpaSpan { DumpParsedAst.hs:23:34 })) (L (EpAnn (EpaSpan { DumpParsedAst.hs:23:11-33 }) ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr ===================================== @@ -9,8 +9,7 @@ (EpaSpan { DumpParsedAstComments.hs:1:1 }) (AnnsModule [(AddEpAnn AnnModule (EpaSpan { DumpParsedAstComments.hs:5:1-6 })) - ,(AddEpAnn AnnWhere (EpaSpan { DumpParsedAstComments.hs:5:30-34 - }))] + ,(AddEpAnn AnnWhere (EpaSpan { DumpParsedAstComments.hs:5:30-34 }))] [] (Just ((,) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -273,10 +273,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:13:11-16 }) @@ -367,10 +364,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:13:27-35 }) @@ -507,10 +501,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { DumpRenamedAst.hs:12:27 }) - (EpaSpan { DumpRenamedAst.hs:12:29 })) + (AnnParen AnnParensSquare (EpaSpan { DumpRenamedAst.hs:12:27 }) (EpaSpan { DumpRenamedAst.hs:12:29 })) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:12:28 }) @@ -605,10 +596,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { DumpRenamedAst.hs:11:16 }) - (EpaSpan { DumpRenamedAst.hs:11:18 })) + (AnnParen AnnParensSquare (EpaSpan { DumpRenamedAst.hs:11:16 }) (EpaSpan { DumpRenamedAst.hs:11:18 })) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:11:17 }) @@ -793,10 +781,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:19:23-36 }) @@ -896,10 +881,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:19:43-51 }) @@ -1009,10 +991,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:20:11-33 }) @@ -1347,10 +1326,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:22:26-28 }) @@ -1819,10 +1795,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaDelta (SameLine 0) []) - (EpaDelta (SameLine 0) [])) + (AnnParen AnnParens (EpaDelta (SameLine 0) []) (EpaDelta (SameLine 0) [])) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:24:18-26 }) @@ -2066,10 +2039,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { DumpRenamedAst.hs:31:12 }) - (EpaSpan { DumpRenamedAst.hs:31:14 })) + (AnnParen AnnParensSquare (EpaSpan { DumpRenamedAst.hs:31:12 }) (EpaSpan { DumpRenamedAst.hs:31:14 })) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:31:13 }) @@ -2122,10 +2092,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { DumpRenamedAst.hs:32:10 }) - (EpaSpan { DumpRenamedAst.hs:32:12 })) + (AnnParen AnnParensSquare (EpaSpan { DumpRenamedAst.hs:32:10 }) (EpaSpan { DumpRenamedAst.hs:32:12 })) (L (EpAnn (EpaSpan { DumpRenamedAst.hs:32:11 }) ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,10 +212,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { DumpSemis.hs:9:11 }) - (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -501,10 +498,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { DumpSemis.hs:14:11 }) - (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -753,10 +747,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { DumpSemis.hs:21:11 }) - (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -268,10 +268,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { KindSigs.hs:15:14 }) - (EpaSpan { KindSigs.hs:15:51 })) + (AnnParen AnnParens (EpaSpan { KindSigs.hs:15:14 }) (EpaSpan { KindSigs.hs:15:51 })) (HsBoxedOrConstraintTuple) [(L (EpAnn @@ -468,10 +465,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParensHash) - (EpaSpan { KindSigs.hs:16:15-16 }) - (EpaSpan { KindSigs.hs:16:53-54 })) + (AnnParen AnnParensHash (EpaSpan { KindSigs.hs:16:15-16 }) (EpaSpan { KindSigs.hs:16:53-54 })) (HsUnboxedTuple) [(L (EpAnn @@ -649,10 +643,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { KindSigs.hs:19:12 }) - (EpaSpan { KindSigs.hs:19:26 })) + (AnnParen AnnParensSquare (EpaSpan { KindSigs.hs:19:12 }) (EpaSpan { KindSigs.hs:19:26 })) (L (EpAnn (EpaSpan { KindSigs.hs:19:14-24 }) @@ -756,10 +747,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { KindSigs.hs:22:8 }) - (EpaSpan { KindSigs.hs:22:20 })) + (AnnParen AnnParens (EpaSpan { KindSigs.hs:22:8 }) (EpaSpan { KindSigs.hs:22:20 })) (L (EpAnn (EpaSpan { KindSigs.hs:22:9-19 }) @@ -847,10 +835,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { KindSigs.hs:22:33 }) - (EpaSpan { KindSigs.hs:22:44 })) + (AnnParen AnnParens (EpaSpan { KindSigs.hs:22:33 }) (EpaSpan { KindSigs.hs:22:44 })) (L (EpAnn (EpaSpan { KindSigs.hs:22:34-43 }) @@ -868,10 +853,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { KindSigs.hs:22:34 }) - (EpaSpan { KindSigs.hs:22:35 })) + (AnnParen AnnParens (EpaSpan { KindSigs.hs:22:34 }) (EpaSpan { KindSigs.hs:22:35 })) (HsBoxedOrConstraintTuple) [])) (L @@ -1362,10 +1344,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { KindSigs.hs:28:34 }) - (EpaSpan { KindSigs.hs:28:39 })) + (AnnParen AnnParensSquare (EpaSpan { KindSigs.hs:28:34 }) (EpaSpan { KindSigs.hs:28:39 })) (L (EpAnn (EpaSpan { KindSigs.hs:28:35-38 }) @@ -1519,10 +1498,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { KindSigs.hs:34:9 }) - (EpaSpan { KindSigs.hs:34:22 })) + (AnnParen AnnParens (EpaSpan { KindSigs.hs:34:9 }) (EpaSpan { KindSigs.hs:34:22 })) (L (EpAnn (EpaSpan { KindSigs.hs:34:10-21 }) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -163,10 +163,7 @@ (EpaComments [])) (HsParTy - (AnnParen - (AnnParens) - (EpaSpan { T15323.hs:6:31 }) - (EpaSpan { T15323.hs:6:36 })) + (AnnParen AnnParens (EpaSpan { T15323.hs:6:31 }) (EpaSpan { T15323.hs:6:36 })) (L (EpAnn (EpaSpan { T15323.hs:6:32-35 }) ===================================== testsuite/tests/parser/should_compile/T20452.stderr ===================================== @@ -376,10 +376,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { T20452.hs:8:57 }) - (EpaSpan { T20452.hs:8:74 })) + (AnnParen AnnParensSquare (EpaSpan { T20452.hs:8:57 }) (EpaSpan { T20452.hs:8:74 })) (L (EpAnn (EpaSpan { T20452.hs:8:58-73 }) @@ -388,10 +385,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { T20452.hs:8:58 }) - (EpaSpan { T20452.hs:8:73 })) + (AnnParen AnnParens (EpaSpan { T20452.hs:8:58 }) (EpaSpan { T20452.hs:8:73 })) (HsBoxedOrConstraintTuple) [(L (EpAnn @@ -591,10 +585,7 @@ (EpaComments [])) (HsListTy - (AnnParen - (AnnParensSquare) - (EpaSpan { T20452.hs:9:57 }) - (EpaSpan { T20452.hs:9:74 })) + (AnnParen AnnParensSquare (EpaSpan { T20452.hs:9:57 }) (EpaSpan { T20452.hs:9:74 })) (L (EpAnn (EpaSpan { T20452.hs:9:58-73 }) @@ -603,10 +594,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { T20452.hs:9:58 }) - (EpaSpan { T20452.hs:9:73 })) + (AnnParen AnnParens (EpaSpan { T20452.hs:9:58 }) (EpaSpan { T20452.hs:9:73 })) (HsBoxedOrConstraintTuple) [(L (EpAnn ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -94,10 +94,7 @@ (EpaComments [])) (HsTupleTy - (AnnParen - (AnnParens) - (EpaSpan { T23315.hsig:3:6 }) - (EpaSpan { T23315.hsig:3:7 })) + (AnnParen AnnParens (EpaSpan { T23315.hsig:3:6 }) (EpaSpan { T23315.hsig:3:7 })) (HsBoxedOrConstraintTuple) [])))))))) ,(L View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfc09760b995b696fee598861ab4de32ec27e516 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfc09760b995b696fee598861ab4de32ec27e516 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 01:18:24 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 20:18:24 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/linker-got Message-ID: <65ea6760c468e_17a6f28fdc52014109f@gitlab.mail> Ben Gamari pushed new branch wip/linker-got at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/linker-got You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 01:49:51 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 20:49:51 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 15 commits: Rephrase error message to say "visible arguments" (#24318) Message-ID: <65ea6ebf8b65b_17a6f29fb3e30153790@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - b9d7296e by Ben Gamari at 2024-03-07T20:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - c6ac768a by Ben Gamari at 2024-03-07T20:49:26-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - b675a51b by Ben Gamari at 2024-03-07T20:49:37-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr - libraries/base/tests/IO/openFile002.stderr - libraries/base/tests/IO/openFile002.stderr-mingw32 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2efba97d84ce32d50dd48a41955bcb2753b0e186...b675a51b14225b215ecd60928e05684bc6952ddd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2efba97d84ce32d50dd48a41955bcb2753b0e186...b675a51b14225b215ecd60928e05684bc6952ddd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 01:56:27 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 20:56:27 -0500 Subject: [Git][ghc/ghc][wip/T24344] 92 commits: Add @since annotation to Data.Data.mkConstrTag Message-ID: <65ea704b29278_17a6f2a242dcc1592d3@gitlab.mail> Ben Gamari pushed to branch wip/T24344 at Glasgow Haskell Compiler / GHC Commits: 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 46cacf05 by Ben Gamari at 2024-03-07T20:56:17-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/125aa4aab15ec66484002763718acbefdeb50ae6...46cacf055788a5b4b267afc4754738a3ded5c070 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/125aa4aab15ec66484002763718acbefdeb50ae6...46cacf055788a5b4b267afc4754738a3ded5c070 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 01:59:01 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 20:59:01 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] testsuite: Mark T24171 as fragile due to #24512 Message-ID: <65ea70e5188e5_17a6f2a5e2ec816141e@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 2739c799 by Ben Gamari at 2024-03-07T20:58:23-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - 1 changed file: - testsuite/tests/rts/linker/T24171/all.T Changes: ===================================== testsuite/tests/rts/linker/T24171/all.T ===================================== @@ -1,6 +1,7 @@ test('T24171', [req_rts_linker, req_profiling, - extra_files(['Lib.hs', 'main.c'])], + extra_files(['Lib.hs', 'main.c']), + fragile(24512)], makefile_test, ['clean_build_and_run']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2739c799d0a9e4534372feed1e6e2e2d5c1ad34d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2739c799d0a9e4534372feed1e6e2e2d5c1ad34d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 02:05:54 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 07 Mar 2024 21:05:54 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] 21 commits: Rephrase error message to say "visible arguments" (#24318) Message-ID: <65ea72826be14_17a6f2aaba79816189a@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - d20bf797 by Ben Gamari at 2024-03-07T20:29:32-05:00 rts/CloneStack: Bounds check array write - - - - - 860a8d42 by Ben Gamari at 2024-03-07T20:29:32-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - a94e4f91 by Ben Gamari at 2024-03-07T20:31:53-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - a948c384 by Ben Gamari at 2024-03-07T20:31:59-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 443db07f by Ben Gamari at 2024-03-07T20:32:23-05:00 rts/IPE: Don't expose helper in header - - - - - bf00e8f8 by Ben Gamari at 2024-03-07T20:32:23-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - d9bcfdbe by Ben Gamari at 2024-03-07T21:05:48-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6471e038 by Ben Gamari at 2024-03-07T21:05:48-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 60f7999e by Ben Gamari at 2024-03-07T21:05:48-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/src/GHC/Base.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c2c7b4eff9c53e1fd3581d466efd034632cb176...60f7999ed6797cc9c84ae51a939129f51897fed3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c2c7b4eff9c53e1fd3581d466efd034632cb176...60f7999ed6797cc9c84ae51a939129f51897fed3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 02:12:42 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 07 Mar 2024 21:12:42 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: Bump array submodule Message-ID: <65ea741a811d6_17a6f2adec6dc16279b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 9d93316e by Ben Gamari at 2024-03-07T21:12:33-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - acc39486 by Ben Gamari at 2024-03-07T21:12:33-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/src/Data/Kind.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr - libraries/base/tests/IO/openFile002.stderr - libraries/base/tests/IO/openFile002.stderr-mingw32 - libraries/base/tests/IO/withBinaryFile001.stderr - libraries/base/tests/IO/withBinaryFile002.stderr - libraries/base/tests/IO/withFile001.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e5db80f6bacd51fbabdaedbb22b0b91aebc4a33...acc39486d1b9b94a7378d08448b7450248131df5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e5db80f6bacd51fbabdaedbb22b0b91aebc4a33...acc39486d1b9b94a7378d08448b7450248131df5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 08:33:08 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 03:33:08 -0500 Subject: [Git][ghc/ghc][master] ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65eacd444e96a_18ccf22af83701983a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 6 changed files: - libraries/base/src/Data/Kind.hs - libraries/ghc-internal/ghc-internal.cabal - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/src/Data/Kind.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} -- | -- @@ -19,4 +19,6 @@ module Data.Kind FUN ) where -import GHC.Internal.Data.Kind \ No newline at end of file +import GHC.Num.BigNat () -- for build ordering (#23942) +import GHC.Prim (FUN) +import GHC.Types (Type, Constraint) ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -120,7 +120,6 @@ Library GHC.Internal.Data.Functor.Utils GHC.Internal.Data.IORef GHC.Internal.Data.Ix - GHC.Internal.Data.Kind GHC.Internal.Data.List GHC.Internal.Data.Maybe GHC.Internal.Data.Monoid ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/50454a299cdef5375ece5fdaf70b36b4a09c3804 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/50454a299cdef5375ece5fdaf70b36b4a09c3804 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 08:33:46 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 03:33:46 -0500 Subject: [Git][ghc/ghc][master] rts: Fix SET_HDR initialization of retainer set Message-ID: <65eacd6a4de92_18ccf22c81c00242af@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 1 changed file: - rts/include/rts/storage/ClosureMacros.h Changes: ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.hp.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38a4b6ab7bbd5e650f43541d091a52ed2655aff6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38a4b6ab7bbd5e650f43541d091a52ed2655aff6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 09:20:23 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 08 Mar 2024 04:20:23 -0500 Subject: [Git][ghc/ghc][wip/andreask/m_warning] RTS: Emit warning when -M < -H Message-ID: <65ead857395d2_18ccf249b32603615f@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/m_warning at Glasgow Haskell Compiler / GHC Commits: a07a8987 by Andreas Klebinger at 2024-03-08T10:06:09+01:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - 1 changed file: - rts/RtsFlags.c Changes: ===================================== rts/RtsFlags.c ===================================== @@ -1951,6 +1951,9 @@ static void normaliseRtsOpts (void) if (RtsFlags.GcFlags.maxHeapSize != 0 && RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) { + errorBelch("Maximum heap size (-M) is smaller than suggested heap size (-H)\n" + "Setting maximum heap size to suggested heap size ( %" FMT_Word " )", + (StgWord64) RtsFlags.GcFlags.maxHeapSize * (StgWord64) BLOCK_SIZE); RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a07a89877a23136b0cf2cd791931b9646c6c59a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a07a89877a23136b0cf2cd791931b9646c6c59a9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 09:56:49 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 08 Mar 2024 04:56:49 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Split up system.config into host/target config files Message-ID: <65eae0e177486_18ccf25b5f004473c1@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 04bc9786 by Matthew Pickering at 2024-03-08T09:56:31+00:00 Split up system.config into host/target config files There were a number of settings which were not applied per-stage, for example if you specified `--ffi-include-dir` then that was applied to both host and target. Now this will just be passed when building the crosscompiler. The solution for now is to separate these two files into host/target and the host file contains very bare-bones . There isn't currently a way to specify with configure anything in the host file, so if you are building a cross-compiler and you need to do that, you have to modify the file yourself. - - - - - 23 changed files: - configure.ac - hadrian/README.md - + hadrian/cfg/system.config.host.in - hadrian/cfg/system.config.in - + hadrian/cfg/system.config.target.in - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Expression.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Rts.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Common.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Builders/Hsc2Hs.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Packages.hs - hadrian/src/Settings/Warnings.hs Changes: ===================================== configure.ac ===================================== @@ -976,6 +976,8 @@ FIND_GHC_TOOLCHAIN([hadrian/cfg]) AC_CONFIG_FILES( [ mk/project.mk hadrian/cfg/system.config + hadrian/cfg/system.config.host + hadrian/cfg/system.config.target hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack ===================================== hadrian/README.md ===================================== @@ -327,6 +327,16 @@ workflow, for now. Note: On windows you need to use the `reloc-binary-dist` target. +#### Cross Compiling + +If you are cross compiling then all the settings specified to ./configure are +for the target system. For example, if you specify `--with-ffi-includes` then +this is specifically for the target. + +If your host system needs additional configuration in order to build a stage1 compiler, +then at the moment you need to manually edit the "cfg/system.config.host.in" file to +specify these options in the right place. + #### Relocatable Binary Distribution If you require a relocatable binary distribution (for example on Windows), then you ===================================== hadrian/cfg/system.config.host.in ===================================== @@ -0,0 +1,77 @@ +# This file is processed by the configure script. +# See hadrian/src/UserSettings.hs for user-defined settings. +#=========================================================== + +# Paths to builders: +#=================== + +# Information about builders: +#============================ + +cc-llvm-backend = NO + + +# Information about build, host and target systems: +#================================================== + +dynamic-extension = @soext_host@ + +bootstrap-threaded-rts = YES + +# Settings: +#========== + +# We are in the process of moving the settings file from being entirely +# generated by configure, to generated being by the build system. Many of these +# might become redundant. +# See Note [tooldir: How GHC finds mingw on Windows] + +settings-otool-command = otool +settings-install_name_tool-command = install_name_tool +settings-llc-command = llc +settings-opt-command = opt +settings-llvm-as-command = clang +settings-use-distro-mingw = NO + +target-has-libm = YES + +# Include and library directories: +#================================= + +curses-lib-dir = +curses-include-dir = + +iconv-include-dir = +iconv-lib-dir = + +intree-gmp = NO +gmp-framework-preferred = NO +gmp-include-dir = +gmp-lib-dir = + +use-system-ffi = NO +ffi-include-dir = +ffi-lib-dir = + +libdw-include-dir = +libdw-lib-dir = + +libnuma-include-dir = +libnuma-lib-dir = + +libzstd-include-dir = +libzstd-lib-dir = + +# Optional Dependencies: +#======================= + +use-lib-dw = NO +use-lib-zstd = NO +static-lib-zstd = NO +use-lib-numa = NO +use-lib-m = YES +use-lib-rt = YES +use-lib-dl = YES +use-lib-bfd = NO +use-lib-pthread = NO +need-libatomic = NO ===================================== hadrian/cfg/system.config.in ===================================== @@ -32,8 +32,6 @@ python = @PythonCmd@ # Information about builders: #============================ -cc-llvm-backend = @CcLlvmBackend@ - llvm-min-version = @LlvmMinVersion@ llvm-max-version = @LlvmMaxVersion@ @@ -54,8 +52,6 @@ target-platform-full = @TargetPlatformFull@ cross-compiling = @CrossCompiling@ -dynamic-extension = @soext_target@ - ghc-version = @GhcVersion@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ @@ -72,60 +68,3 @@ project-patch-level1 = @ProjectPatchLevel1@ project-patch-level2 = @ProjectPatchLevel2@ project-git-commit-id = @ProjectGitCommitId@ -# Settings: -#========== - -# We are in the process of moving the settings file from being entirely -# generated by configure, to generated being by the build system. Many of these -# might become redundant. -# See Note [tooldir: How GHC finds mingw on Windows] - -settings-otool-command = @SettingsOtoolCommand@ -settings-install_name_tool-command = @SettingsInstallNameToolCommand@ -settings-llc-command = @SettingsLlcCommand@ -settings-opt-command = @SettingsOptCommand@ -settings-llvm-as-command = @SettingsLlvmAsCommand@ -settings-use-distro-mingw = @SettingsUseDistroMINGW@ - -target-has-libm = @TargetHasLibm@ - -# Include and library directories: -#================================= - -curses-lib-dir = @CURSES_LIB_DIRS@ -curses-include-dir = @CURSES_INCLUDE_DIRS@ - -iconv-include-dir = @ICONV_INCLUDE_DIRS@ -iconv-lib-dir = @ICONV_LIB_DIRS@ - -intree-gmp = @GMP_FORCE_INTREE@ -gmp-framework-preferred = @GMP_PREFER_FRAMEWORK@ -gmp-include-dir = @GMP_INCLUDE_DIRS@ -gmp-lib-dir = @GMP_LIB_DIRS@ - -use-system-ffi = @UseSystemLibFFI@ -ffi-include-dir = @FFIIncludeDir@ -ffi-lib-dir = @FFILibDir@ - -libdw-include-dir = @LibdwIncludeDir@ -libdw-lib-dir = @LibdwLibDir@ - -libnuma-include-dir = @LibNumaIncludeDir@ -libnuma-lib-dir = @LibNumaLibDir@ - -libzstd-include-dir = @LibZstdIncludeDir@ -libzstd-lib-dir = @LibZstdLibDir@ - -# Optional Dependencies: -#======================= - -use-lib-dw = @UseLibdw@ -use-lib-zstd = @UseLibZstd@ -static-lib-zstd = @UseStaticLibZstd@ -use-lib-numa = @UseLibNuma@ -use-lib-m = @UseLibm@ -use-lib-rt = @UseLibrt@ -use-lib-dl = @UseLibdl@ -use-lib-bfd = @UseLibbfd@ -use-lib-pthread = @UseLibpthread@ -need-libatomic = @NeedLibatomic@ ===================================== hadrian/cfg/system.config.target.in ===================================== @@ -0,0 +1,83 @@ +# This file is processed by the configure script. +# See hadrian/src/UserSettings.hs for user-defined settings. +#=========================================================== + +# Paths to builders: +#=================== + +# Information about builders: +#============================ + +cc-llvm-backend = @CcLlvmBackend@ + + +# Information about build, host and target systems: +#================================================== + +# Q: Is the *-platform information available in the target? +# A: Yes, it is. We pass @BuildPlatform@ and @HostPlatform@ and @TargetPlatform@ to ghc-toolchain using --target=that +# And we can reconstruct the platform info using targetPlatformTriple +# Q: What is TargetPlatformFull? +target-platform-full = @TargetPlatformFull@ + +dynamic-extension = @soext_target@ + +bootstrap-threaded-rts = @GhcThreadedRts@ + +# Settings: +#========== + +# We are in the process of moving the settings file from being entirely +# generated by configure, to generated being by the build system. Many of these +# might become redundant. +# See Note [tooldir: How GHC finds mingw on Windows] + +settings-otool-command = @SettingsOtoolCommand@ +settings-install_name_tool-command = @SettingsInstallNameToolCommand@ +settings-llc-command = @SettingsLlcCommand@ +settings-opt-command = @SettingsOptCommand@ +settings-llvm-as-command = @SettingsLlvmAsCommand@ +settings-use-distro-mingw = @SettingsUseDistroMINGW@ + +target-has-libm = @TargetHasLibm@ + +# Include and library directories: +#================================= + +curses-lib-dir = @CURSES_LIB_DIRS@ +curses-include-dir = @CURSES_INCLUDE_DIRS@ + +iconv-include-dir = @ICONV_INCLUDE_DIRS@ +iconv-lib-dir = @ICONV_LIB_DIRS@ + +intree-gmp = @GMP_FORCE_INTREE@ +gmp-framework-preferred = @GMP_PREFER_FRAMEWORK@ +gmp-include-dir = @GMP_INCLUDE_DIRS@ +gmp-lib-dir = @GMP_LIB_DIRS@ + +use-system-ffi = @UseSystemLibFFI@ +ffi-include-dir = @FFIIncludeDir@ +ffi-lib-dir = @FFILibDir@ + +libdw-include-dir = @LibdwIncludeDir@ +libdw-lib-dir = @LibdwLibDir@ + +libnuma-include-dir = @LibNumaIncludeDir@ +libnuma-lib-dir = @LibNumaLibDir@ + +libzstd-include-dir = @LibZstdIncludeDir@ +libzstd-lib-dir = @LibZstdLibDir@ + +# Optional Dependencies: +#======================= + +use-lib-dw = @UseLibdw@ +use-lib-zstd = @UseLibZstd@ +static-lib-zstd = @UseStaticLibZstd@ +use-lib-numa = @UseLibNuma@ +use-lib-m = @UseLibm@ +use-lib-rt = @UseLibrt@ +use-lib-dl = @UseLibdl@ +use-lib-bfd = @UseLibbfd@ +use-lib-pthread = @UseLibpthread@ +need-libatomic = @NeedLibatomic@ ===================================== hadrian/src/Base.hs ===================================== @@ -29,7 +29,8 @@ module Base ( module Way, -- * Paths - hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, + hadrianPath, configPath, configFile, buildConfigFileHost, buildConfigFileTarget, + sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, ghcLibDeps, haddockDeps, @@ -80,6 +81,13 @@ configPath = hadrianPath -/- "cfg" configFile :: FilePath configFile = configPath -/- "system.config" +buildConfigFileHost :: FilePath +buildConfigFileHost = configPath -/- "system.config.host" + +buildConfigFileTarget :: FilePath +buildConfigFileTarget = configPath -/- "system.config.target" + + -- | The target configuration file generated by ghc-toolchain for the -- compilation build platform buildTargetFile :: FilePath ===================================== hadrian/src/Builder.hs ===================================== @@ -28,14 +28,13 @@ import Hadrian.Builder.Tar import Hadrian.Oracles.Path import Hadrian.Oracles.TextFile import Hadrian.Utilities -import Oracles.Setting (bashPath, targetStage) import System.Exit import System.IO (stderr) import Base import Context import Oracles.Flag -import Oracles.Setting (setting, Setting(..)) +import Oracles.Setting import Packages import GHC.IO.Encoding (getFileSystemEncoding) ===================================== hadrian/src/Expression.hs ===================================== @@ -146,7 +146,7 @@ buildingCompilerStage' f = f . succStage <$> getStage -- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] -- in Settings.Packages for details. threadedBootstrapper :: Predicate -threadedBootstrapper = expr (flag BootstrapThreadedRts) +threadedBootstrapper = staged (buildFlag BootstrapThreadedRts) -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -13,7 +13,7 @@ -- to read configuration or package metadata files and cache the parsing. ----------------------------------------------------------------------------- module Hadrian.Oracles.TextFile ( - lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig, lookupValues, + lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig, lookupHostBuildConfig, lookupTargetBuildConfig, lookupValues, lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies, textFileOracle, getBuildTarget, getHostTarget, getTargetTarget, queryBuildTarget, queryHostTarget @@ -52,6 +52,23 @@ lookupSystemConfig = lookupValueOrError (Just configError) configFile where configError = "Perhaps you need to rerun ./configure" +lookupHostBuildConfig :: String -> Action String +lookupHostBuildConfig key = do + cross <- (== "YES") <$> lookupSystemConfig "cross-compiling" + -- If we are not cross compiling, the build the host compiler like the target. + let cfgFile = if cross then buildConfigFileHost else buildConfigFileTarget + lookupValueOrError (Just configError) cfgFile key + where + configError = "Perhaps you need to rerun ./configure" + +lookupTargetBuildConfig :: String -> Action String +lookupTargetBuildConfig key = + lookupValueOrError (Just configError) buildConfigFileTarget key + where + configError = "Perhaps you need to rerun ./configure" + + + -- | Lookup a list of values in a text file, tracking the result. Each line of -- the file is expected to have @key value1 value2 ...@ format. lookupValues :: FilePath -> String -> Action (Maybe [String]) @@ -104,6 +121,7 @@ getHostTarget = do -- MP: If we are not cross compiling then we should use the target file in order to -- build things for the host, in particular we want to use the configured values for the -- target for building the RTS (ie are we using Libffi for adjustors, and the wordsize) + -- TODO: Use "flag CrossCompiling" ht <- getTargetConfig hostTargetFile tt <- getTargetConfig targetTargetFile if (Toolchain.targetPlatformTriple ht) == (Toolchain.targetPlatformTriple tt) ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -2,6 +2,7 @@ module Oracles.Flag ( Flag (..), flag, getFlag, + BuildFlag(..), buildFlag, targetSupportsSharedLibs, targetSupportsGhciObjects, targetSupportsThreadedRts, @@ -22,7 +23,8 @@ import qualified GHC.Toolchain as Toolchain import GHC.Platform.ArchOS data Flag = CrossCompiling - | CcLlvmBackend + | UseGhcToolchain +data BuildFlag = CcLlvmBackend | GmpInTree | GmpFrameworkPref | UseSystemFfi @@ -38,7 +40,15 @@ data Flag = CrossCompiling | UseLibbfd | UseLibpthread | NeedLibatomic - | UseGhcToolchain + | TargetHasLibm + +parseFlagResult :: String -> String -> Bool +parseFlagResult key value = + if (value `notElem` ["YES", "NO", ""]) + then error $ "Configuration flag " + ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." + else value == "YES" + -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this. @@ -46,6 +56,12 @@ flag :: Flag -> Action Bool flag f = do let key = case f of CrossCompiling -> "cross-compiling" + UseGhcToolchain -> "use-ghc-toolchain" + parseFlagResult key <$> lookupSystemConfig key + +buildFlag :: BuildFlag -> Stage -> Action Bool +buildFlag f st = + let key = case f of CcLlvmBackend -> "cc-llvm-backend" GmpInTree -> "intree-gmp" GmpFrameworkPref -> "gmp-framework-preferred" @@ -62,11 +78,13 @@ flag f = do UseLibbfd -> "use-lib-bfd" UseLibpthread -> "use-lib-pthread" NeedLibatomic -> "need-libatomic" - UseGhcToolchain -> "use-ghc-toolchain" - value <- lookupSystemConfig key - when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " - ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." - return $ value == "YES" + TargetHasLibm -> "target-has-libm" + in parseFlagResult key <$> (tgtConfig st key) + where + tgtConfig Stage0 {} = lookupHostBuildConfig + tgtConfig Stage1 = lookupHostBuildConfig + tgtConfig Stage2 = lookupTargetBuildConfig + tgtConfig Stage3 = lookupTargetBuildConfig -- | Get a configuration setting. getFlag :: Flag -> Expr c b Bool ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -1,7 +1,8 @@ module Oracles.Setting ( configFile, -- * Settings - Setting (..), setting, getSetting, + ProjectSetting (..), setting, getSetting, + BuildSetting(..), buildSetting, ToolchainSetting (..), settingsFileSetting, -- * Helpers @@ -39,28 +40,14 @@ import GHC.Platform.ArchOS -- tracking the result in the Shake database. -- -- * ROMES:TODO: How to handle target-platform-full? -data Setting = CursesIncludeDir - | CursesLibDir - | DynamicExtension - | FfiIncludeDir - | FfiLibDir - | GhcMajorVersion +data ProjectSetting = + GhcMajorVersion | GhcMinorVersion | GhcPatchLevel | GhcVersion | GhcSourcePath | LlvmMinVersion | LlvmMaxVersion - | GmpIncludeDir - | GmpLibDir - | IconvIncludeDir - | IconvLibDir - | LibdwIncludeDir - | LibdwLibDir - | LibnumaIncludeDir - | LibnumaLibDir - | LibZstdIncludeDir - | LibZstdLibDir | ProjectGitCommitId | ProjectName | ProjectVersion @@ -73,6 +60,25 @@ data Setting = CursesIncludeDir | TargetPlatformFull | BourneShell + +-- Things which configure how a specific stage is built +data BuildSetting = + CursesIncludeDir + | CursesLibDir + | DynamicExtension + | FfiIncludeDir + | FfiLibDir + | GmpIncludeDir + | GmpLibDir + | IconvIncludeDir + | IconvLibDir + | LibdwIncludeDir + | LibdwLibDir + | LibnumaIncludeDir + | LibnumaLibDir + | LibZstdIncludeDir + | LibZstdLibDir + -- TODO compute solely in Hadrian, removing these variables' definitions -- from aclocal.m4 whenever they can be calculated from other variables -- already fed into Hadrian. @@ -93,13 +99,8 @@ data ToolchainSetting -- | Look up the value of a 'Setting' in @cfg/system.config@, tracking the -- result. -setting :: Setting -> Action String +setting :: ProjectSetting -> Action String setting key = lookupSystemConfig $ case key of - CursesIncludeDir -> "curses-include-dir" - CursesLibDir -> "curses-lib-dir" - DynamicExtension -> "dynamic-extension" - FfiIncludeDir -> "ffi-include-dir" - FfiLibDir -> "ffi-lib-dir" GhcMajorVersion -> "ghc-major-version" GhcMinorVersion -> "ghc-minor-version" GhcPatchLevel -> "ghc-patch-level" @@ -107,16 +108,6 @@ setting key = lookupSystemConfig $ case key of GhcSourcePath -> "ghc-source-path" LlvmMinVersion -> "llvm-min-version" LlvmMaxVersion -> "llvm-max-version" - GmpIncludeDir -> "gmp-include-dir" - GmpLibDir -> "gmp-lib-dir" - IconvIncludeDir -> "iconv-include-dir" - IconvLibDir -> "iconv-lib-dir" - LibdwIncludeDir -> "libdw-include-dir" - LibdwLibDir -> "libdw-lib-dir" - LibnumaIncludeDir -> "libnuma-include-dir" - LibnumaLibDir -> "libnuma-lib-dir" - LibZstdIncludeDir -> "libzstd-include-dir" - LibZstdLibDir -> "libzstd-lib-dir" ProjectGitCommitId -> "project-git-commit-id" ProjectName -> "project-name" ProjectVersion -> "project-version" @@ -129,22 +120,51 @@ setting key = lookupSystemConfig $ case key of TargetPlatformFull -> "target-platform-full" BourneShell -> "bourne-shell" +buildSetting :: BuildSetting -> Stage -> Action String +buildSetting key stage = tgtConfig stage $ case key of + CursesIncludeDir -> "curses-include-dir" + CursesLibDir -> "curses-lib-dir" + DynamicExtension -> "dynamic-extension" + FfiIncludeDir -> "ffi-include-dir" + FfiLibDir -> "ffi-lib-dir" + GmpIncludeDir -> "gmp-include-dir" + GmpLibDir -> "gmp-lib-dir" + IconvIncludeDir -> "iconv-include-dir" + IconvLibDir -> "iconv-lib-dir" + LibdwIncludeDir -> "libdw-include-dir" + LibdwLibDir -> "libdw-lib-dir" + LibnumaIncludeDir -> "libnuma-include-dir" + LibnumaLibDir -> "libnuma-lib-dir" + LibZstdIncludeDir -> "libzstd-include-dir" + LibZstdLibDir -> "libzstd-lib-dir" + where + tgtConfig Stage0 {} = lookupHostBuildConfig + tgtConfig Stage1 = lookupHostBuildConfig + tgtConfig Stage2 = lookupTargetBuildConfig + tgtConfig Stage3 = lookupTargetBuildConfig + + -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the -- result. -- See Note [tooldir: How GHC finds mingw on Windows] -- ROMES:TODO: This should be queryTargetTargetConfig -settingsFileSetting :: ToolchainSetting -> Action String -settingsFileSetting key = lookupSystemConfig $ case key of +settingsFileSetting :: ToolchainSetting -> Stage -> Action String +settingsFileSetting key stage = tgtConfig stage $ case key of ToolchainSetting_OtoolCommand -> "settings-otool-command" ToolchainSetting_InstallNameToolCommand -> "settings-install_name_tool-command" ToolchainSetting_LlcCommand -> "settings-llc-command" ToolchainSetting_OptCommand -> "settings-opt-command" ToolchainSetting_LlvmAsCommand -> "settings-llvm-as-command" ToolchainSetting_DistroMinGW -> "settings-use-distro-mingw" -- ROMES:TODO: This option doesn't seem to be in ghc-toolchain yet. It corresponds to EnableDistroToolchain + where + tgtConfig Stage0 {} = lookupHostBuildConfig + tgtConfig Stage1 = lookupHostBuildConfig + tgtConfig Stage2 = lookupTargetBuildConfig + tgtConfig Stage3 = lookupTargetBuildConfig -- | An expression that looks up the value of a 'Setting' in @cfg/system.config@, -- tracking the result. -getSetting :: Setting -> Expr c b String +getSetting :: ProjectSetting -> Expr c b String getSetting = expr . setting -- | The path to a Bourne shell interpreter. @@ -247,7 +267,7 @@ libsuf :: Stage -> Way -> Action String libsuf st way | not (wayUnit Dynamic way) = return (waySuffix way ++ ".a") -- e.g., _p.a | otherwise = do - extension <- setting DynamicExtension -- e.g., .dll or .so + extension <- buildSetting DynamicExtension st-- e.g., .dll or .so version <- ghcVersionStage st -- e.g. 8.4.4 or 8.9.xxxx let suffix = waySuffix (removeWayUnit Dynamic way) return (suffix ++ "-ghc" ++ version ++ extension) ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -10,7 +10,7 @@ module Oracles.TestSettings import Base import Hadrian.Oracles.TextFile -import Oracles.Setting (topDirectory, setting, Setting(..), crossStage) +import Oracles.Setting (topDirectory, setting, ProjectSetting(..), crossStage) import Packages import Settings.Program (programContext) import Hadrian.Oracles.Path ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -10,7 +10,6 @@ import qualified Data.Set as Set import Base import qualified Context import Expression -import Hadrian.Oracles.TextFile (lookupSystemConfig) import Oracles.Flag hiding (arSupportsAtFile, arSupportsDashL) import Oracles.ModuleFiles import Oracles.Setting @@ -49,10 +48,9 @@ ghcPrimDependencies = do rtsDependencies :: Expr [FilePath] rtsDependencies = do - stage <- getStage - rtsPath <- expr (rtsBuildPath stage) - jsTarget <- expr (isJsTarget stage) - useSystemFfi <- expr (flag UseSystemFfi) + rtsPath <- staged rtsBuildPath + jsTarget <- staged isJsTarget + useSystemFfi <- staged (buildFlag UseSystemFfi) let -- headers common to native and JS RTS common_headers = @@ -276,7 +274,7 @@ runInterpolations (Interpolations mk_substs) input = do return (subst input) -- | Interpolate the given variable with the value of the given 'Setting'. -interpolateSetting :: String -> Setting -> Interpolations +interpolateSetting :: String -> ProjectSetting -> Interpolations interpolateSetting name settng = interpolateVar name $ setting settng -- | Interpolate the @ProjectVersion@ and @ProjectVersionMunged@ variables. @@ -401,8 +399,8 @@ generateSettings settingsFile = do , ("ar supports at file", queryTarget stage arSupportsAtFile') , ("ar supports -L", queryTarget stage arSupportsDashL') , ("ranlib command", queryTarget stage ranlibPath) - , ("otool command", expr $ settingsFileSetting ToolchainSetting_OtoolCommand) - , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) + , ("otool command", staged $ settingsFileSetting ToolchainSetting_OtoolCommand) + , ("install_name_tool command", staged $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("windres command", queryTarget stage (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit, Context.stage = predStage stage }))) , ("cross compiling", expr $ yesNo <$> crossStage (predStage stage)) @@ -414,13 +412,13 @@ generateSettings settingsFile = do , ("target has GNU nonexec stack", queryTarget stage (yesNo . Toolchain.tgtSupportsGnuNonexecStack)) , ("target has .ident directive", queryTarget stage (yesNo . Toolchain.tgtSupportsIdentDirective)) , ("target has subsections via symbols", queryTarget stage (yesNo . Toolchain.tgtSupportsSubsectionsViaSymbols)) - , ("target has libm", expr $ lookupSystemConfig "target-has-libm") + , ("target has libm", yesNo <$> staged (buildFlag TargetHasLibm)) , ("Unregisterised", queryTarget stage (yesNo . tgtUnregisterised)) , ("LLVM target", queryTarget stage tgtLlvmTarget) - , ("LLVM llc command", expr $ settingsFileSetting ToolchainSetting_LlcCommand) - , ("LLVM opt command", expr $ settingsFileSetting ToolchainSetting_OptCommand) - , ("LLVM llvm-as command", expr $ settingsFileSetting ToolchainSetting_LlvmAsCommand) - , ("Use inplace MinGW toolchain", expr $ settingsFileSetting ToolchainSetting_DistroMinGW) + , ("LLVM llc command", staged $ settingsFileSetting ToolchainSetting_LlcCommand) + , ("LLVM opt command", staged $ settingsFileSetting ToolchainSetting_OptCommand) + , ("LLVM llvm-as command", staged $ settingsFileSetting ToolchainSetting_LlvmAsCommand) + , ("Use inplace MinGW toolchain", staged $ settingsFileSetting ToolchainSetting_DistroMinGW) , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter stage) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP stage) @@ -428,7 +426,7 @@ generateSettings settingsFile = do , ("Tables next to code", queryTarget stage (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget stage (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> targetUseLibffiForAdjustors stage) - , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("RTS expects libdw", yesNo <$> staged (buildFlag UseLibdw)) , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" ===================================== hadrian/src/Rules/Gmp.hs ===================================== @@ -17,7 +17,7 @@ import Settings.Builders.Common (cArgs, getStagedCCFlags) -- their paths. gmpObjects :: Stage -> Action [FilePath] gmpObjects s = do - isInTree <- flag GmpInTree + isInTree <- buildFlag GmpInTree s if not isInTree then return [] else do @@ -65,8 +65,9 @@ gmpRules = do packageP = takeDirectory buildP librariesP = takeDirectory packageP stageP = takeDirectory librariesP + stage <- parsePath parseStage "" (takeFileName stageP) - isInTree <- flag GmpInTree + isInTree <- buildFlag GmpInTree stage if isInTree then do ===================================== hadrian/src/Rules/Libffi.hs ===================================== @@ -87,7 +87,7 @@ libffiContext stage = do -- | The name of the library libffiName :: Expr String libffiName = do - useSystemFfi <- expr (flag UseSystemFfi) + useSystemFfi <- staged (buildFlag UseSystemFfi) if useSystemFfi then pure "ffi" else libffiLocalName Nothing @@ -118,8 +118,8 @@ libffiHeaderDir stage = do path <- libffiBuildPath stage return $ path -/- "inst/include" -libffiSystemHeaderDir :: Action FilePath -libffiSystemHeaderDir = setting FfiIncludeDir +libffiSystemHeaderDir :: Stage -> Action FilePath +libffiSystemHeaderDir = buildSetting FfiIncludeDir fixLibffiMakefile :: FilePath -> String -> String fixLibffiMakefile top = ===================================== hadrian/src/Rules/Rts.hs ===================================== @@ -53,9 +53,9 @@ withLibffi stage action = needLibffi stage -- See Note [Packaging libffi headers] in GHC.Driver.CodeOutput. copyLibffiHeader :: Stage -> FilePath -> Action () copyLibffiHeader stage header = do - useSystemFfi <- flag UseSystemFfi + useSystemFfi <- buildFlag UseSystemFfi stage (fromStr, headerDir) <- if useSystemFfi - then ("system",) <$> libffiSystemHeaderDir + then ("system",) <$> libffiSystemHeaderDir stage else needLibffi stage >> ("custom",) <$> libffiHeaderDir stage copyFile @@ -122,7 +122,7 @@ rtsLibffiLibrary stage way = do needRtsLibffiTargets :: Stage -> Action [FilePath] needRtsLibffiTargets stage = do rtsPath <- rtsBuildPath stage - useSystemFfi <- flag UseSystemFfi + useSystemFfi <- buildFlag UseSystemFfi stage jsTarget <- isJsTarget stage -- Header files (in the rts build dir). ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -199,11 +199,11 @@ configureArgs cFlags' ldFlags' = do mconcat [ conf "CFLAGS" cFlags , conf "LDFLAGS" ldFlags - , conf "--with-iconv-includes" $ arg =<< getSetting IconvIncludeDir - , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir - , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir - , conf "--with-gmp-libraries" $ arg =<< getSetting GmpLibDir - , conf "--with-curses-libraries" $ arg =<< getSetting CursesLibDir + , conf "--with-iconv-includes" $ arg =<< staged (buildSetting IconvIncludeDir) + , conf "--with-iconv-libraries" $ arg =<< staged (buildSetting IconvLibDir) + , conf "--with-gmp-includes" $ arg =<< staged (buildSetting GmpIncludeDir) + , conf "--with-gmp-libraries" $ arg =<< staged (buildSetting GmpLibDir) + , conf "--with-curses-libraries" $ arg =<< staged (buildSetting CursesLibDir) , conf "--host" $ arg =<< flip queryTarget targetPlatformTriple . predStage' =<< getStage , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage , ghcVersionH ===================================== hadrian/src/Settings/Builders/Common.hs ===================================== @@ -51,9 +51,9 @@ cppArgs = mempty cWarnings :: Args cWarnings = mconcat [ arg "-Wall" - , flag CcLlvmBackend ? arg "-Wno-unknown-pragmas" - , notM (flag CcLlvmBackend) ? not windowsHost ? arg "-Werror=unused-but-set-variable" - , notM (flag CcLlvmBackend) ? arg "-Wno-error=inline" ] + , staged (buildFlag CcLlvmBackend) ? arg "-Wno-unknown-pragmas" + , notM (staged (buildFlag CcLlvmBackend)) ? not windowsHost ? arg "-Werror=unused-but-set-variable" + , notM (staged (buildFlag CcLlvmBackend)) ? arg "-Wno-error=inline" ] packageDatabaseArgs :: Args packageDatabaseArgs = do ===================================== hadrian/src/Settings/Builders/Ghc.hs ===================================== @@ -103,7 +103,7 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do st <- getStage distDir <- expr (Context.distDir st) - useSystemFfi <- expr (flag UseSystemFfi) + useSystemFfi <- staged (buildFlag UseSystemFfi) buildPath <- getBuildPath libffiName' <- libffiName debugged <- buildingCompilerStage' . ghcDebugged =<< expr flavour ===================================== hadrian/src/Settings/Builders/Hsc2Hs.hs ===================================== @@ -12,7 +12,7 @@ hsc2hsBuilderArgs :: Args hsc2hsBuilderArgs = builder Hsc2Hs ? do stage <- getStage ccPath <- getBuilderPath $ Cc CompileC stage - gmpDir <- getSetting GmpIncludeDir + gmpDir <- staged (buildSetting GmpIncludeDir) top <- expr topDirectory hArch <- queryHost queryArch hOs <- queryHost queryOS ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -114,7 +114,7 @@ inTreeCompilerArgs stg = do platform <- queryTargetTarget ghcStage targetPlatformTriple wordsize <- show @Int . (*8) <$> queryTargetTarget ghcStage (wordSize2Bytes . tgtWordSize) - llc_cmd <- settingsFileSetting ToolchainSetting_LlcCommand + llc_cmd <- settingsFileSetting ToolchainSetting_LlcCommand ghcStage have_llvm <- liftIO (isJust <$> findExecutable llc_cmd) top <- topDirectory ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -30,10 +30,10 @@ packageArgs = do compilerStageOption f = buildingCompilerStage' . f =<< expr flavour - cursesIncludeDir <- getSetting CursesIncludeDir - cursesLibraryDir <- getSetting CursesLibDir - ffiIncludeDir <- getSetting FfiIncludeDir - ffiLibraryDir <- getSetting FfiLibDir + cursesIncludeDir <- staged (buildSetting CursesIncludeDir) + cursesLibraryDir <- staged (buildSetting CursesLibDir) + ffiIncludeDir <- staged (buildSetting FfiIncludeDir) + ffiLibraryDir <- staged (buildSetting FfiLibDir) stageVersion <- readVersion <$> (expr $ ghcVersionStage stage) mconcat @@ -80,13 +80,13 @@ packageArgs = do [ andM [expr (ghcWithInterpreter stage), notStage0] `cabalFlag` "internal-interpreter" , notM cross `cabalFlag` "terminfo" , arg "-build-tool-depends" - , flag UseLibzstd `cabalFlag` "with-libzstd" + , staged (buildFlag UseLibzstd) `cabalFlag` "with-libzstd" -- ROMES: While the boot compiler is not updated wrt -this-unit-id -- not being fixed to `ghc`, when building stage0, we must set -- -this-unit-id to `ghc` because the boot compiler expects that. -- We do it through a cabal flag in ghc.cabal , stageVersion < makeVersion [9,8,1] ? arg "+hadrian-stage0" - , flag StaticLibzstd `cabalFlag` "static-libzstd" + , staged (buildFlag StaticLibzstd) `cabalFlag` "static-libzstd" ] , builder (Haddock BuildPackage) ? arg ("--optghc=-I" ++ path) ] @@ -116,9 +116,9 @@ packageArgs = do -------------------------------- ghcPrim ------------------------------- , package ghcPrim ? mconcat - [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic" + [ builder (Cabal Flags) ? staged (buildFlag NeedLibatomic) `cabalFlag` "need-atomic" - , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ? + , builder (Cc CompileC) ? (not <$> staged (buildFlag CcLlvmBackend)) ? input "**/cbits/atomic.c" ? arg "-Wno-sync-nand" ] --------------------------------- ghci --------------------------------- @@ -229,8 +229,8 @@ packageArgs = do ghcBignumArgs :: Args ghcBignumArgs = package ghcBignum ? do -- These are only used for non-in-tree builds. - librariesGmp <- getSetting GmpLibDir - includesGmp <- getSetting GmpIncludeDir + librariesGmp <- staged (buildSetting GmpLibDir) + includesGmp <- staged (buildSetting GmpIncludeDir) backend <- getBignumBackend check <- getBignumCheck @@ -253,15 +253,15 @@ ghcBignumArgs = package ghcBignum ? do -- enable in-tree support: don't depend on external "gmp" -- library - , flag GmpInTree ? arg "--configure-option=--with-intree-gmp" + , staged (buildFlag GmpInTree) ? arg "--configure-option=--with-intree-gmp" -- prefer framework over library (on Darwin) - , flag GmpFrameworkPref ? + , staged (buildFlag GmpFrameworkPref) ? arg "--configure-option=--with-gmp-framework-preferred" -- Ensure that the ghc-bignum package registration includes -- knowledge of the system gmp's library and include directories. - , notM (flag GmpInTree) ? cabalExtraDirs includesGmp librariesGmp + , notM (staged (buildFlag GmpInTree)) ? cabalExtraDirs includesGmp librariesGmp ] ] _ -> mempty @@ -290,15 +290,15 @@ rtsPackageArgs = package rts ? do way <- getWay path <- getBuildPath top <- expr topDirectory - useSystemFfi <- getFlag UseSystemFfi - ffiIncludeDir <- getSetting FfiIncludeDir - ffiLibraryDir <- getSetting FfiLibDir - libdwIncludeDir <- getSetting LibdwIncludeDir - libdwLibraryDir <- getSetting LibdwLibDir - libnumaIncludeDir <- getSetting LibnumaIncludeDir - libnumaLibraryDir <- getSetting LibnumaLibDir - libzstdIncludeDir <- getSetting LibZstdIncludeDir - libzstdLibraryDir <- getSetting LibZstdLibDir + useSystemFfi <- staged (buildFlag UseSystemFfi) + ffiIncludeDir <- staged (buildSetting FfiIncludeDir) + ffiLibraryDir <- staged (buildSetting FfiLibDir) + libdwIncludeDir <- staged (buildSetting LibdwIncludeDir) + libdwLibraryDir <- staged (buildSetting LibdwLibDir) + libnumaIncludeDir <- staged (buildSetting LibnumaIncludeDir) + libnumaLibraryDir <- staged (buildSetting LibnumaLibDir) + libzstdIncludeDir <- staged (buildSetting LibZstdIncludeDir) + libzstdLibraryDir <- staged (buildSetting LibZstdLibDir) -- Arguments passed to GHC when compiling C and .cmm sources. @@ -392,10 +392,10 @@ rtsPackageArgs = package rts ? do -- any warnings in the module. See: -- https://gitlab.haskell.org/ghc/ghc/wikis/working-conventions#Warnings - , (not <$> flag CcLlvmBackend) ? + , (not <$> staged (buildFlag CcLlvmBackend)) ? inputs ["**/Compact.c"] ? arg "-finline-limit=2500" - , input "**/RetainerProfile.c" ? flag CcLlvmBackend ? + , input "**/RetainerProfile.c" ? staged (buildFlag CcLlvmBackend) ? arg "-Wno-incompatible-pointer-types" ] @@ -405,18 +405,18 @@ rtsPackageArgs = package rts ? do , any (wayUnit Debug) rtsWays `cabalFlag` "debug" , any (wayUnit Dynamic) rtsWays `cabalFlag` "dynamic" , any (wayUnit Threaded) rtsWays `cabalFlag` "threaded" - , flag UseLibm `cabalFlag` "libm" - , flag UseLibrt `cabalFlag` "librt" - , flag UseLibdl `cabalFlag` "libdl" + , staged (buildFlag UseLibm) `cabalFlag` "libm" + , staged (buildFlag UseLibrt) `cabalFlag` "librt" + , staged (buildFlag UseLibdl) `cabalFlag` "libdl" , useSystemFfi `cabalFlag` "use-system-libffi" , targetUseLibffiForAdjustors stage `cabalFlag` "libffi-adjustors" - , flag UseLibpthread `cabalFlag` "need-pthread" - , flag UseLibbfd `cabalFlag` "libbfd" - , flag NeedLibatomic `cabalFlag` "need-atomic" - , flag UseLibdw `cabalFlag` "libdw" - , flag UseLibnuma `cabalFlag` "libnuma" - , flag UseLibzstd `cabalFlag` "libzstd" - , flag StaticLibzstd `cabalFlag` "static-libzstd" + , staged (buildFlag UseLibpthread) `cabalFlag` "need-pthread" + , staged (buildFlag UseLibbfd ) `cabalFlag` "libbfd" + , staged (buildFlag NeedLibatomic) `cabalFlag` "need-atomic" + , staged (buildFlag UseLibdw ) `cabalFlag` "libdw" + , staged (buildFlag UseLibnuma ) `cabalFlag` "libnuma" + , staged (buildFlag UseLibzstd ) `cabalFlag` "libzstd" + , staged (buildFlag StaticLibzstd) `cabalFlag` "static-libzstd" , queryTargetTarget stage tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore" , ghcUnreg `cabalFlag` "unregisterised" , ghcEnableTNC `cabalFlag` "tables-next-to-code" @@ -437,7 +437,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] + , builder HsCpp ? staged (buildFlag UseLibdw) ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== hadrian/src/Settings/Warnings.hs ===================================== @@ -10,16 +10,15 @@ import Packages -- | Default Haskell warning-related arguments. defaultGhcWarningsArgs :: Args defaultGhcWarningsArgs = do - stage <- getStage mconcat [ notStage0 ? arg "-Wnoncanonical-monad-instances" - , notM (flag CcLlvmBackend) ? arg "-optc-Wno-error=inline" - , flag CcLlvmBackend ? arg "-optc-Wno-unknown-pragmas" + , notM (staged (buildFlag CcLlvmBackend)) ? arg "-optc-Wno-error=inline" + , staged (buildFlag CcLlvmBackend) ? arg "-optc-Wno-unknown-pragmas" -- Cabal can seemingly produce filepaths with incorrect case on filesystems -- with case-insensitive names. Ignore such issues for now as they seem benign. -- See #17798. - , isOsxTarget stage ? arg "-optP-Wno-nonportable-include-path" - , isWinTarget stage ? arg "-optP-Wno-nonportable-include-path" + , staged isOsxTarget ? arg "-optP-Wno-nonportable-include-path" + , staged isWinTarget ? arg "-optP-Wno-nonportable-include-path" ] -- | Package-specific warnings-related arguments, mostly suppressing various warnings. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04bc9786e169cb88ca4a15a9d28e1819b58ee7a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04bc9786e169cb88ca4a15a9d28e1819b58ee7a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 11:35:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 06:35:34 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65eaf8062177e_18ccf284b4ae456549@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - d17e0cfc by Patrick at 2024-03-08T08:54:36+00:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 21c7494d by Ben Gamari at 2024-03-08T06:35:23-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 21 changed files: - compiler/GHC.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - libraries/base/src/Data/Kind.hs - libraries/ghc-internal/ghc-internal.cabal - rts/include/rts/storage/ClosureMacros.h - rts/linker/Elf.c - + testsuite/tests/hiefile/should_compile/T24493.hs - + testsuite/tests/hiefile/should_compile/T24493.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -1157,7 +1157,7 @@ instance DesugaredMod DesugaredModule where type ParsedSource = Located (HsModule GhcPs) type RenamedSource = (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], - Maybe (LHsDoc GhcRn)) + Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName)) type TypecheckedSource = LHsBinds GhcTc -- NOTE: ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -63,12 +63,12 @@ extractDocs dflags , tcg_imports = import_avails , tcg_insts = insts , tcg_fam_insts = fam_insts - , tcg_doc_hdr = mb_doc_hdr + , tcg_hdr_info = mb_hdr_info , tcg_th_docs = th_docs_var , tcg_type_env = ty_env } = do th_docs <- liftIO $ readIORef th_docs_var - let doc_hdr = (unLoc <$> mb_doc_hdr) + let doc_hdr = unLoc <$> fst mb_hdr_info ExtractedTHDocs th_hdr th_decl_docs th_arg_docs th_inst_docs = extractTHDocs th_docs mod_docs = Docs ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -210,7 +210,8 @@ call and just recurse directly in to the subexpressions. -- These synonyms match those defined in compiler/GHC.hs type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn] , Maybe [(LIE GhcRn, Avails)] - , Maybe (LHsDoc GhcRn) ) + , Maybe (LHsDoc GhcRn) + , Maybe (XRec GhcRn ModuleName) ) type TypecheckedSource = LHsBinds GhcTc @@ -321,8 +322,9 @@ getCompressedAsts ts rs top_ev_binds insts tcs = enrichHie :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon] -> HieASTs Type -enrichHie ts (hsGrp, imports, exports, docs) ev_bs insts tcs = +enrichHie ts (hsGrp, imports, exports, docs, modName) ev_bs insts tcs = runIdentity $ flip evalStateT initState $ flip runReaderT SourceInfo $ do + modName <- toHie (IEC Export <$> modName) tasts <- toHie $ fmap (BC RegularBind ModuleScope) ts rasts <- processGrp hsGrp imps <- toHie $ filter (not . ideclImplicit . ideclExt . unLoc) imports @@ -344,7 +346,8 @@ enrichHie ts (hsGrp, imports, exports, docs) ev_bs insts tcs = (realSrcSpanEnd $ nodeSpan (NE.last children)) flat_asts = concat - [ tasts + [ modName + , tasts , rasts , imps , exps ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -297,8 +297,8 @@ tcRnModuleTcRnM hsc_env mod_sum -- We will rename it properly after renaming everything else so that -- haddock can link the identifiers ; tcg_env <- return (tcg_env - { tcg_doc_hdr = fmap (\(WithHsDocIdentifiers str _) -> WithHsDocIdentifiers str []) - <$> maybe_doc_hdr }) + { tcg_hdr_info = (fmap (\(WithHsDocIdentifiers str _) -> WithHsDocIdentifiers str []) + <$> maybe_doc_hdr , maybe_mod ) }) ; -- If the whole module is warned about or deprecated -- (via mod_deprec) record that in tcg_warns. If we do thereby add -- a WarnAll, it will override any subsequent deprecations added to tcg_warns @@ -347,7 +347,7 @@ tcRnModuleTcRnM hsc_env mod_sum -- Rename the module header properly after we have renamed everything else ; maybe_doc_hdr <- traverse rnLHsDoc maybe_doc_hdr; ; tcg_env <- return (tcg_env - { tcg_doc_hdr = maybe_doc_hdr }) + { tcg_hdr_info = (maybe_doc_hdr, maybe_mod) }) ; -- add extra source files to tcg_dependent_files addDependentFiles src_files @@ -3115,14 +3115,15 @@ runRenamerPlugin gbl_env hs_group = do -- exception/signal an error. type RenamedStuff = (Maybe (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], - Maybe (LHsDoc GhcRn))) + Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))) -- | Extract the renamed information from TcGblEnv. getRenamedStuff :: TcGblEnv -> RenamedStuff getRenamedStuff tc_result = fmap (\decls -> ( decls, tcg_rn_imports tc_result - , tcg_rn_exports tc_result, tcg_doc_hdr tc_result ) ) + , tcg_rn_exports tc_result, doc_hdr, name_hdr )) (tcg_rn_decls tc_result) + where (doc_hdr, name_hdr) = tcg_hdr_info tc_result runTypecheckerPlugin :: ModSummary -> TcGblEnv -> TcM TcGblEnv runTypecheckerPlugin sum gbl_env = do ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -605,7 +605,9 @@ data TcGblEnv tcg_fords :: [LForeignDecl GhcTc], -- ...Foreign import & exports tcg_patsyns :: [PatSyn], -- ...Pattern synonyms - tcg_doc_hdr :: Maybe (LHsDoc GhcRn), -- ^ Maybe Haddock header docs + tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName)), + -- ^ Maybe Haddock header docs and Maybe located module name + tcg_hpc :: !AnyHpcUsage, -- ^ @True@ if any part of the -- prog uses hpc instrumentation. -- NB. BangPattern is to fix a leak, see #15111 ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -523,8 +523,8 @@ mergeSignatures tcg_rn_decls = tcg_rn_decls orig_tcg_env, -- Annotations tcg_ann_env = tcg_ann_env orig_tcg_env, - -- Documentation header - tcg_doc_hdr = tcg_doc_hdr orig_tcg_env + -- Documentation header and located module name + tcg_hdr_info = tcg_hdr_info orig_tcg_env -- tcg_dus? -- tcg_th_used = tcg_th_used orig_tcg_env, -- tcg_th_splice_used = tcg_th_splice_used orig_tcg_env ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -346,7 +346,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this tcg_merged = [], tcg_dfun_n = dfun_n_var, tcg_keep = keep_var, - tcg_doc_hdr = Nothing, + tcg_hdr_info = (Nothing,Nothing), tcg_hpc = False, tcg_main = Nothing, tcg_self_boot = NoSelfBoot, ===================================== libraries/base/src/Data/Kind.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} -- | -- @@ -19,4 +19,6 @@ module Data.Kind FUN ) where -import GHC.Internal.Data.Kind \ No newline at end of file +import GHC.Num.BigNat () -- for build ordering (#23942) +import GHC.Prim (FUN) +import GHC.Types (Type, Constraint) ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -120,7 +120,6 @@ Library GHC.Internal.Data.Functor.Utils GHC.Internal.Data.IORef GHC.Internal.Data.Ix - GHC.Internal.Data.Kind GHC.Internal.Data.List GHC.Internal.Data.Maybe GHC.Internal.Data.Monoid ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.hp.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else ===================================== rts/linker/Elf.c ===================================== @@ -101,10 +101,10 @@ # include #endif +#include "elf_got.h" + #if defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH) -# define NEED_GOT # define NEED_PLT -# include "elf_got.h" # include "elf_plt.h" # include "elf_reloc.h" #endif @@ -798,7 +798,7 @@ ocGetNames_ELF ( ObjectCode* oc ) /* This is a non-empty .bss section. Allocate zeroed space for it, and set its .sh_offset field such that ehdrC + .sh_offset == addr_of_zeroed_space. */ -#if defined(NEED_GOT) || RTS_LINKER_USE_MMAP +#if RTS_LINKER_USE_MMAP if (USE_CONTIGUOUS_MMAP || RtsFlags.MiscFlags.linkerAlwaysPic) { /* The space for bss sections is already preallocated */ CHECK(oc->bssBegin != NULL); @@ -1113,13 +1113,11 @@ ocGetNames_ELF ( ObjectCode* oc ) } } -#if defined(NEED_GOT) if(makeGot( oc )) errorBelch("Failed to create GOT for %s", oc->archiveMemberName ? oc->archiveMemberName : oc->fileName); -#endif result = 1; goto end; @@ -1987,13 +1985,11 @@ ocResolve_ELF ( ObjectCode* oc ) } } -#if defined(NEED_GOT) if(fillGot( oc )) return 0; /* silence warnings */ (void) shnum; (void) shdr; -#endif /* NEED_GOT */ #if defined(aarch64_HOST_ARCH) /* use new relocation design */ ===================================== testsuite/tests/hiefile/should_compile/T24493.hs ===================================== @@ -0,0 +1,3 @@ +module T24493 where + +go = "1" ===================================== testsuite/tests/hiefile/should_compile/T24493.stderr ===================================== @@ -0,0 +1,33 @@ +==================== HIE AST ==================== +File: T24493.hs +Node at T24493.hs:(1,8)-(3,8): Source: From source + {(annotations: {(Module, Module)}), (types: []), + (identifier info: {})} + + Node at T24493.hs:1:8-13: Source: From source + {(annotations: {}), (types: []), + (identifier info: {(module T24493, Details: Nothing {export})})} + + Node at T24493.hs:3:1-8: Source: From source + {(annotations: {(FunBind, HsBindLR), (Match, Match), + (XHsBindsLR, HsBindLR)}), + (types: [0]), (identifier info: {})} + + Node at T24493.hs:3:1-2: Source: From source + {(annotations: {}), (types: []), + (identifier info: {(name T24493.go, Details: Just 0 {LHS of a match group, + regular value bound with scope: ModuleScope bound at: T24493.hs:3:1-8})})} + + Node at T24493.hs:3:4-8: Source: From source + {(annotations: {(GRHS, GRHS)}), (types: []), + (identifier info: {})} + + Node at T24493.hs:3:6-8: Source: From source + {(annotations: {(HsLit, HsExpr)}), (types: [0]), + (identifier info: {})} + + + + +Got valid scopes +Got no roundtrip errors \ No newline at end of file ===================================== testsuite/tests/hiefile/should_compile/all.T ===================================== @@ -23,3 +23,4 @@ test('Scopes', normal, compile, ['-fno-code -fwrite-ide- test('ScopesBug', expect_broken(18425), compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T18425', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T22416', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) +test('T24493', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info -ddump-hie']) ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -2,7 +2,7 @@ ==================== Renamer ==================== (Just - ((,,,) + ((,,,,) (HsGroup (NoExtField) (XValBindsLR @@ -2367,6 +2367,16 @@ {Name: GHC.Types.Type}))) (Nothing)))])))))] (Nothing) - (Nothing))) + (Nothing) + (Just + (L + (EpAnn + (EpaSpan { DumpRenamedAst.hs:4:8-21 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: DumpRenamedAst})))) + ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -2,7 +2,7 @@ ==================== Renamer ==================== (Just - ((,,,) + ((,,,,) (HsGroup (NoExtField) (XValBindsLR @@ -316,6 +316,13 @@ [{Name: T14189.MyType} ,{Name: T14189.f} ,{Name: T14189.NT}])])]) - (Nothing))) - - + (Nothing) + (Just + (L + (EpAnn + (EpaSpan { T14189.hs:1:8-13 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: T14189})))) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 91f338a4f1ae59fd6ea482b73a27708113912d5d +Subproject commit 730749b48c3d7b358f4fb07774a1ccfc1d63968a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/acc39486d1b9b94a7378d08448b7450248131df5...21c7494d64fc83bcfbb3dbb4f8cb7965efb129cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/acc39486d1b9b94a7378d08448b7450248131df5...21c7494d64fc83bcfbb3dbb4f8cb7965efb129cd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 11:41:48 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 08 Mar 2024 06:41:48 -0500 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 175 commits: Improve Monad, Functor & Applicative docs Message-ID: <65eaf97ce8ce8_18ccf288ae7a86218c@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - b77dbb51 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 83bf77f6 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The net result is good: a 1.5% improvement in compile time. The table below shows changes over 1%. The main changes are: * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Many new or rewritten Notes. E.g. Note [Avoiding simplifying repeatedly] Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * When considering inlining a join point, never do so unless there is a positive gain: see (DJ5) in Note [Duplicating join points]. * Do not float join points at all, except to top level. See GHC.Core.Opt.SetLevels.dontFloatNonRec * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. * Use plan A for dataToTag and tagToEnum I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I added an INLINE pragma to it. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -8.2% GOOD LargeRecord(normal) -22.7% GOOD PmSeriesS(normal) -4.1% PmSeriesT(normal) -3.1% PmSeriesV(normal) -1.6% T11195(normal) -1.9% T12227(normal) -19.9% GOOD T12545(normal) -5.4% T12707(normal) -2.1% GOOD T13253-spj(normal) -13.1% GOOD T13386(normal) -1.6% T14766(normal) -2.2% GOOD T15630a(normal) NEW T15703(normal) -13.5% GOOD T16577(normal) -4.3% GOOD T17096(normal) -4.4% T17516(normal) -0.2% T18223(normal) -16.3% GOOD T18282(normal) -5.3% GOOD T18730(optasm) NEW T18923(normal) -3.7% GOOD T21839c(normal) -2.3% GOOD T3064(normal) -1.3% T5030(normal) -16.1% GOOD T5321Fun(normal) -1.5% T6048(optasm) -11.8% GOOD T783(normal) -1.4% T8095(normal) -5.9% GOOD T9630(normal) -5.1% GOOD T9020(optasm) +1.5% T18698a(normal) +1.5% BAD T14683(normal) +1.2% DsIncompleteRecSel3(normal) +1.2% MultiComponentModulesRecomp(normal) +1.0% MultiLayerModulesRecomp(normal) +1.9% MultiLayerModulesTH_Make(normal) +1.4% T10421(normal) +1.9% BAD T10421a(normal) +3.0% T13056(optasm) +1.1% T13253(normal) +1.0% T1969(normal) +1.1% BAD T15304(normal) +1.7% T9675(optasm) +1.2% T9961(normal) +2.4% BAD geo. mean -1.5% minimum -22.7% maximum +3.0% Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T12990 T13253-spj T13536a T14766 T15703 T16577 T18223 T18282 T18923 T21839c T5030 T6048 T8095 T9630 Metric Increase: T10421 T18698a T1969 T9961 - - - - - 47354ebd by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Improve postInlineUnconditionally This commit adds two things to postInlineUnconditionally: 1. Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. 2. Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. - - - - - 871b220a by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 More wibbles * Inline join points whose RHS just calls another join point * Don't float join points at all (SetLevels) * Ensure that WorkWrap preserves lambda binders, in case of join points - - - - - a5233f5a by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Unused variable wibbles - - - - - 357baf70 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 More import wibbles - - - - - eecf517a by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 More imports - - - - - 10b0e737 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 More wibbles - - - - - 94fea9a2 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 More on floating join points * Get rid of the "join ceiling" which I have always hated * Float joins to top level in final pass only (needs documenting--see my GHC log) * Refactor wantToFloat so that it applies to Rec and NonRec uniformly - - - - - 56a7e908 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Comments about floating joins - - - - - 3b936b63 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Improve occurrence analyis for bottoming function calls See Note [Bottoming function calls] - - - - - 6c844a18 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Test output wibbles - - - - - 78d37b5e by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 More testsuite wibbles - - - - - 79e0fed4 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Float recursive joins to top level This seems be be a net win. Example joinrec { f x = ..f x'... } in f v Despite Note [Floating join point bindings] - - - - - c0a935d4 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Inline join points that have evaluated things at the use site. This helps quite a bit with wheel-sieve1. Example let x = <small thunk> in join $j = (x,y) in case z of A -> case x of P -> $j Q -> blah B -> x C -> True Here `x` can't be duplicated into the branches becuase it is used in both the join point and the A branch. But if we inline $j we get let x = <small thunk> in join $j = (x,y) in case z of A -> case x of x' P -> (x', y) Q -> blah B -> x C -> True and now we /can/ duplicate x into the branches. - - - - - a33476b9 by Simon Peyton Jones at 2024-03-08T11:41:36+00:00 Two small things * isConLikeUnfolding is false for OtherCon * Evaluated args look like NonTrivArg not ValueArg See GHC log 15 Feb - - - - - 22 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - CODEOWNERS - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.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/d29435b5c97e38a1b2f639c76a74841b3f775764...a33476b9bdca731d1a90466fe866b417f2cdd09c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d29435b5c97e38a1b2f639c76a74841b3f775764...a33476b9bdca731d1a90466fe866b417f2cdd09c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 13:24:41 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 08:24:41 -0500 Subject: [Git][ghc/ghc][wip/T24515] 15 commits: Bump array submodule Message-ID: <65eb1199230f_18ccf2b36d87c72448@gitlab.mail> Ben Gamari pushed to branch wip/T24515 at Glasgow Haskell Compiler / GHC Commits: d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 9662651a by Ben Gamari at 2024-03-08T08:24:35-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 44922e4f by Cheng Shao at 2024-03-08T08:24:35-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.8.1-notes.rst - docs/users_guide/using-warnings.rst - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/Control/Exception.hs - + libraries/base/src/Control/Exception/Annotation.hs - + libraries/base/src/Control/Exception/Backtrace.hs - + libraries/base/src/Control/Exception/Context.hs - libraries/base/src/Data/Kind.hs - libraries/base/tests/IO/T21336/T21336a.stderr - libraries/base/tests/IO/T21336/T21336b.stderr - libraries/base/tests/IO/T4808.stderr - libraries/base/tests/IO/mkdirExists.stderr - libraries/base/tests/IO/openFile002.stderr - libraries/base/tests/IO/openFile002.stderr-mingw32 - libraries/base/tests/IO/withBinaryFile001.stderr - libraries/base/tests/IO/withBinaryFile002.stderr - libraries/base/tests/IO/withFile001.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3731e3a528143a87927802c7d8c35ba9088f6dfa...44922e4f735c8f3c3fa06e6b59d43ebaba9fa3c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3731e3a528143a87927802c7d8c35ba9088f6dfa...44922e4f735c8f3c3fa06e6b59d43ebaba9fa3c7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 13:25:03 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 08 Mar 2024 08:25:03 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22859 Message-ID: <65eb11afd7325_18ccf2b41132873016@gitlab.mail> Teo Camarasu pushed new branch wip/T22859 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22859 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 13:26:26 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 08 Mar 2024 08:26:26 -0500 Subject: [Git][ghc/ghc][wip/T22859] Implement user-defined allocation limit handlers Message-ID: <65eb12025c802_18ccf2b4a8c0074812@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: d73943ab by Teo Camarasu at 2024-03-08T13:26:20+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 8 changed files: - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h Changes: ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,6 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,69 @@ +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + ) + where +import GHC.Internal.Foreign.C.Types +import GHC.Internal.Control.Monad (return, join) +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.IO (IO, unsafePerformIO) +import GHC.Internal.System.IO (print) +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Base + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziIOziException_allocationLimitExceeded_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/Schedule.c ===================================== @@ -94,6 +94,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1118,14 +1122,31 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // the AllocationLimitExceeded exception. if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3348,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d73943ab91d0a2e202cb8096a048b3ae9423bca9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d73943ab91d0a2e202cb8096a048b3ae9423bca9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 13:30:33 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 08:30:33 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 7 commits: ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65eb12f98c042_18ccf2bb4d49877944@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 59d808d6 by Ben Gamari at 2024-03-08T08:27:26-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - d3f91b30 by Ben Gamari at 2024-03-08T08:27:35-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - 10a1be48 by Cheng Shao at 2024-03-08T08:27:48-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. (cherry picked from commit 44922e4f735c8f3c3fa06e6b59d43ebaba9fa3c7) - - - - - 5ebdf90a by Ben Gamari at 2024-03-08T08:27:54-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. (cherry picked from commit 9662651af3e5d24ae4e0bd275bdee1e718954c0b) - - - - - 1da0bdcb by Ben Gamari at 2024-03-08T08:28:58-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - 15 changed files: - .gitlab-ci.yml - libraries/base/src/Data/Kind.hs - libraries/ghc-internal/ghc-internal.cabal - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/include/rts/storage/ClosureMacros.h - testsuite/driver/testlib.py - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/rts/linker/T24171/all.T - testsuite/tests/rts/linker/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 7f63b34ac87b85470eef9c668e9528e8e2f5b46a + DOCKER_REV: a9297a370025101b479cfd4977f8f910814e03ab # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. ===================================== libraries/base/src/Data/Kind.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} -- | -- @@ -19,4 +19,6 @@ module Data.Kind FUN ) where -import GHC.Internal.Data.Kind \ No newline at end of file +import GHC.Num.BigNat () -- for build ordering (#23942) +import GHC.Prim (FUN) +import GHC.Types (Type, Constraint) ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -120,7 +120,6 @@ Library GHC.Internal.Data.Functor.Utils GHC.Internal.Data.IORef GHC.Internal.Data.Ix - GHC.Internal.Data.Kind GHC.Internal.Data.List GHC.Internal.Data.Maybe GHC.Internal.Data.Monoid ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(stem, ".exe"); +#elif defined(wasm32_HOST_ARCH) + dropExtension(stem, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasm32_HOST_ARCH) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.hp.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else ===================================== testsuite/driver/testlib.py ===================================== @@ -2329,14 +2329,13 @@ def write_file(f: Path, s: str) -> None: async def check_hp_ok(name: TestName) -> bool: opts = getTestOpts() - actual_name = name + exe_extension() if not opts.ignore_extension else name # do not qualify for hp2ps because we should be in the right directory - hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {actual_name}'.format(**locals()) + hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {name}'.format(**locals()) hp2psResult = await runCmd(hp2psCmd, print_output=True) - actual_ps_path = in_testdir(actual_name, 'ps') + actual_ps_path = in_testdir(name, 'ps') if hp2psResult == 0: if actual_ps_path.exists(): @@ -2345,15 +2344,15 @@ async def check_hp_ok(name: TestName) -> bool: if (gsResult == 0): return True else: - print("hp2ps output for " + actual_name + " is not valid PostScript") + print("hp2ps output for " + name + " is not valid PostScript") return False else: return True # assume postscript is valid without ghostscript else: - print("hp2ps did not generate PostScript for " + actual_name) + print("hp2ps did not generate PostScript for " + name) return False else: - print("hp2ps error when processing heap profile for " + actual_name) + print("hp2ps error when processing heap profile for " + name) return False async def check_prof_ok(name: TestName, way: WayName) -> bool: @@ -2365,7 +2364,7 @@ async def check_prof_ok(name: TestName, way: WayName) -> bool: if not expected_prof_path.exists(): return True - actual_prof_file = add_suffix(name + exe_extension(), 'prof') + actual_prof_file = add_suffix(name, 'prof') actual_prof_path = in_testdir(actual_prof_file) if not actual_prof_path.exists(): ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/rts/linker/T24171/all.T ===================================== @@ -1,6 +1,7 @@ test('T24171', [req_rts_linker, req_profiling, - extra_files(['Lib.hs', 'main.c'])], + extra_files(['Lib.hs', 'main.c']), + fragile(24512)], makefile_test, ['clean_build_and_run']) ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -113,6 +113,7 @@ test('linker_unload_native', [extra_files(['LinkerUnload.hs', 'Test.hs']), req_rts_linker, unless(have_dynamic(), skip), + fragile(23993), when(opsys('darwin') or opsys('mingw32'), skip)], makefile_test, ['linker_unload_native']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2739c799d0a9e4534372feed1e6e2e2d5c1ad34d...1da0bdcb4adbf4eb7d0584c0d76aee83bc7f5166 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2739c799d0a9e4534372feed1e6e2e2d5c1ad34d...1da0bdcb4adbf4eb7d0584c0d76aee83bc7f5166 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 13:36:10 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 08 Mar 2024 08:36:10 -0500 Subject: [Git][ghc/ghc][wip/sand-witch/fix-tysyn] Fix compiler crash caused by implicit RHS quantification in type synonyms (24470) Message-ID: <65eb144a8ee89_18ccf2bef76707818c@gitlab.mail> Vladislav Zavialov pushed to branch wip/sand-witch/fix-tysyn at Glasgow Haskell Compiler / GHC Commits: 350f84ea by Andrei Borzenkov at 2024-03-08T16:34:35+03:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (24470) - - - - - 9 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1911,6 +1911,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accomodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2543,6 +2555,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3209,6 +3223,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4263,6 +4265,24 @@ data TcRnMessage where -} TcRnNamespacedFixitySigWithoutFlag :: FixitySig GhcPs -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accomodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accomodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -605,6 +605,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -911,3 +911,4 @@ test('T22788', normal, compile, ['']) test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accomodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -721,3 +721,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/350f84ea75f5c4ab69716ae9e42ebdcb3e5ecef1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/350f84ea75f5c4ab69716ae9e42ebdcb3e5ecef1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 14:00:27 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 08 Mar 2024 09:00:27 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/comment-illformed-type-pattern Message-ID: <65eb19fb45bf6_18ccf2ca4096486092@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/comment-illformed-type-pattern at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/comment-illformed-type-pattern You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 14:13:15 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 08 Mar 2024 09:13:15 -0500 Subject: [Git][ghc/ghc][wip/T22859] 29 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65eb1cfb1415f_18ccf2cfc2978943f5@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 84ff1c78 by Teo Camarasu at 2024-03-08T14:13:08+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Panic.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/runtime_control.rst - docs/users_guide/using-warnings.rst - hadrian/README.md - hadrian/src/CommandLine.hs - hadrian/src/Settings/Builders/Haddock.hs - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d73943ab91d0a2e202cb8096a048b3ae9423bca9...84ff1c78f642a373568d41fa24468e40a95d0ada -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d73943ab91d0a2e202cb8096a048b3ae9423bca9...84ff1c78f642a373568d41fa24468e40a95d0ada You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 14:45:54 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 09:45:54 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: base: Use strerror_r instead of strerror Message-ID: <65eb24a2b3ac5_18ccf2de523081024dd@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: fb6b99f9 by Ben Gamari at 2024-03-08T09:45:44-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - 3e90e2b1 by Jade at 2024-03-08T09:45:45-05:00 Error Messages: Improve response for illegal forall and GADT Syntax forall in a type with -XNoExplicitForAll used to suggest RankNTypes. In this patch this is changed to the correct ExplicitForAll. using a where in a data declaration with -XNoGADTSyntax used to suggest GADTs In this patch this is changed to the correct GADTSyntax. Fixes: #24448 - - - - - 16a41a21 by Jade at 2024-03-08T09:45:46-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - 38f45533 by Patrick at 2024-03-08T09:45:47-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - e6a1f2dc by Ben Gamari at 2024-03-08T09:45:48-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - libraries/base/changelog.md - + libraries/ghc-internal/cbits/strerror.c - libraries/ghc-internal/configure.ac - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/jsbits/errno.js - libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs - rts/linker/Elf.c - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - + testsuite/tests/hiefile/should_compile/T24493.hs - + testsuite/tests/hiefile/should_compile/T24493.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/module/mod98.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_fail/NoPatternSynonyms.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - + testsuite/tests/parser/should_fail/T17879a.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21c7494d64fc83bcfbb3dbb4f8cb7965efb129cd...e6a1f2dc9e28e3a1cf35e688561d901693958707 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21c7494d64fc83bcfbb3dbb4f8cb7965efb129cd...e6a1f2dc9e28e3a1cf35e688561d901693958707 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 15:57:01 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 10:57:01 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] base: Do not expose whereFrom# from GHC.Exts Message-ID: <65eb354d6ceb7_3ea39f18b04d8160a0@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 411f5289 by Ben Gamari at 2024-03-08T10:56:43-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 10 changed files: - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -46,6 +46,7 @@ matches a `data` or `data instance` declaration) with all of its constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ([CLC proposal #104](https://github.com/haskell/core-libraries-committee/issues/104)) ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -139,7 +139,12 @@ module GHC.Base ) where import GHC.Internal.Base -import GHC.Prim hiding (dataToTagLarge#, dataToTagSmall#) +import GHC.Prim hiding (dataToTagLarge#, dataToTagSmall#, whereFrom#) + -- Hide dataToTagLarge# because it is expected to break for + -- GHC-internal reasons in the near future, and shouldn't + -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. + import GHC.Prim.Ext import GHC.Prim.PtrEq import GHC.Internal.Err ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -111,10 +111,11 @@ module GHC.Exts import GHC.Internal.Exts import GHC.Internal.ArrayArray -import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge#, whereFrom# ) -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Prim.Ext ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -315,7 +315,7 @@ import GHC.Classes hiding ( import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#) +import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#, whereFrom#) -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -133,10 +133,11 @@ module GHC.Internal.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) - -- Hide dataToTag# ops because they are expected to break for +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge#, whereFrom# ) + -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Types hiding ( IO -- Exported from "GHC.IO" ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -29,6 +29,7 @@ import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) import GHC.Internal.ClosureTypes import GHC.Internal.Text.Read +import GHC.Prim (whereFrom##) data InfoProv = InfoProv { ipName :: String, ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4755,7 +4755,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6857,7 +6856,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4755,7 +4755,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6826,7 +6825,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4758,7 +4758,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -7006,7 +7005,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4755,7 +4755,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6857,7 +6856,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/411f5289da39b5a4aacd07ba7532c23c0347694a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/411f5289da39b5a4aacd07ba7532c23c0347694a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 16:14:17 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 08 Mar 2024 11:14:17 -0500 Subject: [Git][ghc/ghc][wip/T22859] Implement user-defined allocation limit handlers Message-ID: <65eb3959a3593_3ea39f21f5818166ba@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 44f95ed2 by Teo Camarasu at 2024-03-08T16:13:54+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 8 changed files: - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h Changes: ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,6 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,69 @@ +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + ) + where +import GHC.Internal.Foreign.C.Types +import GHC.Internal.Control.Monad (return, join) +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.IO (IO, unsafePerformIO) +import GHC.Internal.System.IO (print) +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Base + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/Schedule.c ===================================== @@ -94,6 +94,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1118,14 +1122,31 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // the AllocationLimitExceeded exception. if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3348,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44f95ed2c9588e99d70fe1ceca2059ef8820735a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44f95ed2c9588e99d70fe1ceca2059ef8820735a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 16:21:52 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 08 Mar 2024 11:21:52 -0500 Subject: [Git][ghc/ghc][wip/T22859] Implement user-defined allocation limit handlers Message-ID: <65eb3b2088434_3ea39f23da32c18691@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 4ab9de86 by Teo Camarasu at 2024-03-08T16:21:43+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 8 changed files: - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h Changes: ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,6 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,67 @@ +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + ) + where +import GHC.Internal.Foreign.C.Types +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.IO (unsafePerformIO) +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Base + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/Schedule.c ===================================== @@ -94,6 +94,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1118,14 +1122,31 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // the AllocationLimitExceeded exception. if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3348,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ab9de86d91015e3675d26b75f5ad21250dcd852 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ab9de86d91015e3675d26b75f5ad21250dcd852 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 17:00:59 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 12:00:59 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24512 Message-ID: <65eb444b26ba4_3ea39f36c34ac2332b@gitlab.mail> Ben Gamari pushed new branch wip/T24512 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24512 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 18:56:53 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 13:56:53 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: base: Use strerror_r instead of strerror Message-ID: <65eb5f75276ae_3ea39f6ac9044529c5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2f7121b9 by Ben Gamari at 2024-03-08T13:56:35-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - f5898080 by Jade at 2024-03-08T13:56:36-05:00 Error Messages: Improve response for illegal forall and GADT Syntax forall in a type with -XNoExplicitForAll used to suggest RankNTypes. In this patch this is changed to the correct ExplicitForAll. using a where in a data declaration with -XNoGADTSyntax used to suggest GADTs In this patch this is changed to the correct GADTSyntax. Fixes: #24448 - - - - - 0d33112f by Jade at 2024-03-08T13:56:37-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - f646f65c by Patrick at 2024-03-08T13:56:38-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 0af6b5ea by Ben Gamari at 2024-03-08T13:56:38-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 33f16f40 by Cheng Shao at 2024-03-08T13:56:38-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - a7c876e3 by Ben Gamari at 2024-03-08T13:56:39-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - libraries/base/changelog.md - + libraries/ghc-internal/cbits/strerror.c - libraries/ghc-internal/configure.ac - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/jsbits/errno.js - libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/linker/Elf.c - testsuite/driver/testlib.py - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - + testsuite/tests/hiefile/should_compile/T24493.hs - + testsuite/tests/hiefile/should_compile/T24493.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/module/mod98.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e6a1f2dc9e28e3a1cf35e688561d901693958707...a7c876e35ee0998bba256d4bf0808750d57dc7b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e6a1f2dc9e28e3a1cf35e688561d901693958707...a7c876e35ee0998bba256d4bf0808750d57dc7b4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 19:38:06 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 14:38:06 -0500 Subject: [Git][ghc/ghc][wip/T24512] 4 commits: ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65eb691ee06c2_2fe318aee12458421@gitlab.mail> Ben Gamari pushed to branch wip/T24512 at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - dbb0be97 by Ben Gamari at 2024-03-08T14:37:41-05:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 0c6dc060 by Ben Gamari at 2024-03-08T14:37:59-05:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 11 changed files: - libraries/base/src/Data/Kind.hs - libraries/ghc-internal/ghc-internal.cabal - rts/CheckUnload.c - rts/Linker.c - rts/LinkerInternals.h - rts/include/rts/storage/ClosureMacros.h - rts/linker/Elf.c - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/src/Data/Kind.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} -- | -- @@ -19,4 +19,6 @@ module Data.Kind FUN ) where -import GHC.Internal.Data.Kind \ No newline at end of file +import GHC.Num.BigNat () -- for build ordering (#23942) +import GHC.Prim (FUN) +import GHC.Types (Type, Constraint) ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -120,7 +120,6 @@ Library GHC.Internal.Data.Functor.Utils GHC.Internal.Data.IORef GHC.Internal.Data.Ix - GHC.Internal.Data.Kind GHC.Internal.Data.List GHC.Internal.Data.Maybe GHC.Internal.Data.Monoid ===================================== rts/CheckUnload.c ===================================== @@ -165,6 +165,18 @@ ObjectCode *loaded_objects; // map static closures to their ObjectCode. static OCSectionIndices *global_s_indices = NULL; +// Is it safe for us to unload code? +static bool safeToUnload(void) +{ + if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) { + // We mustn't unload anything as the heap census may contain + // references into static data (e.g. cost centre names). + // See #24512. + return false; + } + return true; +} + static OCSectionIndices *createOCSectionIndices(void) { // TODO (osa): Maybe initialize as empty (without allocation) and allocate @@ -457,6 +469,8 @@ void checkUnload(void) { if (global_s_indices == NULL) { return; + } else if (!safeToUnload()) { + return; } // At this point we've marked all dynamically loaded static objects @@ -478,8 +492,6 @@ void checkUnload(void) next = oc->next; ASSERT(oc->status == OBJECT_UNLOADED); - removeOCSectionIndices(s_indices, oc); - // Symbols should be removed by unloadObj_. // NB (osa): If this assertion doesn't hold then freeObjectCode below // will corrupt symhash as keys of that table live in ObjectCodes. If @@ -487,8 +499,17 @@ void checkUnload(void) // RTS) then it's probably because this assertion did not hold. ASSERT(oc->symbols == NULL); - freeObjectCode(oc); - n_unloaded_objects -= 1; + if (oc->unloadable) { + removeOCSectionIndices(s_indices, oc); + freeObjectCode(oc); + n_unloaded_objects -= 1; + } else { + // If we don't have enough information to + // accurately determine the reachability of + // the object then hold onto it. + oc->next = objects; + objects = oc; + } } old_objects = NULL; ===================================== rts/Linker.c ===================================== @@ -1385,6 +1385,7 @@ mkOc( ObjectType type, pathchar *path, char *image, int imageSize, oc->prev = NULL; oc->next_loaded_object = NULL; oc->mark = object_code_mark_bit; + oc->unloadable = false; oc->dependencies = allocHashSet(); #if defined(NEED_M32) @@ -1527,6 +1528,12 @@ preloadObjectFile (pathchar *path) /* FIXME (AP): =mapped= parameter unconditionally set to true */ oc = mkOc(STATIC_OBJECT, path, image, fileSize, true, NULL, misalignment); + /* assume that static objects are safely unloadable since + * we have know of all references to symbols provided by + * the object. These are tracked by lookupDependentSymbol. + */ + oc->unloadable = true; + #if defined(OBJFORMAT_MACHO) if (ocVerifyImage_MachO( oc )) ocInit_MachO( oc ); ===================================== rts/LinkerInternals.h ===================================== @@ -313,8 +313,14 @@ struct _ObjectCode { struct _ObjectCode *next_loaded_object; // Mark bit + // N.B. This is a full word as we CAS it. StgWord mark; + // Can this object be safely unloaded? Not true for + // dynamic objects when dlinfo is not available as + // we cannot determine liveness. + bool unloadable; + // Set of dependencies (ObjectCode*) of the object file. Traverse // dependencies using `iterHashTable`. // @@ -376,7 +382,9 @@ struct _ObjectCode { /* handle returned from dlopen */ void *dlopen_handle; - /* virtual memory ranges of loaded code */ + /* virtual memory ranges of loaded code. NULL if no range information is + * available (e.g. if dlinfo is unavailable on the current platform). + */ NativeCodeRange *nc_ranges; }; ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -147,17 +147,10 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) #if defined(PROFILING) /* The following macro works for both retainer profiling and LDV profiling. For - retainer profiling, 'era' remains 0, so by setting the 'ldvw' field we also set - 'rs' to zero. - - Note that we don't have to bother handling the 'flip' bit properly[1] since the - retainer profiling code will just set 'rs' to NULL upon visiting a closure with - an invalid 'flip' bit anyways. - - See Note [Profiling heap traversal visited bit] for details. - - [1]: Technically we should set 'rs' to `NULL | flip`. + retainer profiling, we set 'trav' to 0, which is an invalid + RetainerSet. */ + /* MP: Various other places use the check era > 0 to check whether LDV profiling is enabled. The use of these predicates here is the reason for including RtsFlags.h in @@ -168,17 +161,14 @@ EXTERN_INLINE StgHalfWord GET_TAG(const StgClosure *con) */ #define SET_PROF_HDR(c, ccs_) \ { \ - (c)->header.prof.ccs = ccs_; \ - if (doingLDVProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - } \ -\ - if (doingRetainerProfiling()) { \ - LDV_RECORD_CREATE((c)); \ - }; \ - if (doingErasProfiling()){ \ - ERA_RECORD_CREATE((c)); \ - }; \ + (c)->header.prof.ccs = ccs_; \ + if (doingLDVProfiling()) { \ + LDV_RECORD_CREATE((c)); \ + } else if (doingRetainerProfiling()) { \ + (c)->header.prof.hp.trav = 0; \ + } else if (doingErasProfiling()){ \ + ERA_RECORD_CREATE((c)); \ + } \ } #else ===================================== rts/linker/Elf.c ===================================== @@ -2190,6 +2190,10 @@ void * loadNativeObj_ELF (pathchar *path, char **errmsg) copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); goto dl_iterate_phdr_fail; } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; #endif /* defined (HAVE_DLINFO) */ insertOCSectionIndices(nc); ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1276,7 +1276,7 @@ module Data.Ix where {-# MINIMAL range, (index | GHC.Internal.Ix.unsafeIndex), inRange #-} module Data.Kind where - -- Safety: Safe + -- Safety: Trustworthy type Constraint :: * type Constraint = GHC.Prim.CONSTRAINT GHC.Types.LiftedRep type role FUN nominal representational representational View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d3edc79eb17250515550344f3d75cf897eae880...0c6dc060c39a14e4eb4679aab655c2bcd32a87df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d3edc79eb17250515550344f3d75cf897eae880...0c6dc060c39a14e4eb4679aab655c2bcd32a87df You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 20:04:24 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 08 Mar 2024 15:04:24 -0500 Subject: [Git][ghc/ghc][wip/int-index/comment-illformed-type-pattern] Drop outdated comment on TcRnIllformedTypePattern Message-ID: <65eb6f48799dd_2fe31817789e465839@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/comment-illformed-type-pattern at Glasgow Haskell Compiler / GHC Commits: b79a9071 by Vladislav Zavialov at 2024-03-08T23:04:14+03:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - 6 changed files: - compiler/GHC/Tc/Errors/Types.hs - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.hs - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.stderr - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.hs - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.stderr - testsuite/tests/vdq-rta/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -4129,19 +4129,15 @@ data TcRnMessage where corresponding to a required type argument (visible forall) does not have a form that can be interpreted as a type pattern. - At the moment, only patterns constructed using the @type@ keyword - are considered well-formed, but this restriction will be relaxed - when part 2 of GHC Proposal #281 is implemented. - Example: vfun :: forall (a :: k) -> () - vfun x = () - -- ^ - -- expected `type x` instead of `x` + vfun !x = () + -- ^^ + -- bang-patterns not allowed as type patterns Test cases: - T22326_fail_raw_pat + T22326_fail_bang_pat -} TcRnIllformedTypePattern :: !(Pat GhcRn) -> TcRnMessage @@ -4173,7 +4169,7 @@ data TcRnMessage where -- lambdas not allowed in type arguments Test cases: - T22326_fail_raw_arg + T22326_fail_lam_arg -} TcRnIllformedTypeArgument :: !(LHsExpr GhcRn) -> TcRnMessage ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.hs ===================================== @@ -1,6 +1,6 @@ {-# LANGUAGE RequiredTypeArguments #-} -module T22326_fail_raw_pat where +module T22326_fail_bang_pat where f :: forall (a :: k) -> () f !x = () \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.stderr ===================================== @@ -1,5 +1,5 @@ -T22326_fail_raw_pat.hs:6:3: error: [GHC-88754] +T22326_fail_bang_pat.hs:6:3: error: [GHC-88754] • Ill-formed type pattern: !x • In the pattern: !x In an equation for ‘f’: f !x = () ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RequiredTypeArguments #-} -module T22326_fail_raw_arg where +module T22326_fail_lam_arg where f :: forall (a :: k) -> () f (type _) = () ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.stderr ===================================== @@ -1,5 +1,5 @@ -T22326_fail_raw_arg.hs:9:5: error: [GHC-29092] +T22326_fail_lam_arg.hs:9:5: error: [GHC-29092] • Ill-formed type argument: \ _ -> _ • In the expression: f (\ _ -> _) In an equation for ‘x’: x = f (\ _ -> _) ===================================== testsuite/tests/vdq-rta/should_fail/all.T ===================================== @@ -3,8 +3,8 @@ test('T22326_fail_ext2', normal, compile_fail, ['']) test('T22326_fail_top', normal, compile_fail, ['']) test('T22326_fail_app', normal, compile_fail, ['']) test('T22326_fail_notInScope', normal, compile_fail, ['']) -test('T22326_fail_raw_pat', normal, compile_fail, ['']) -test('T22326_fail_raw_arg', normal, compile_fail, ['']) +test('T22326_fail_bang_pat', normal, compile_fail, ['']) +test('T22326_fail_lam_arg', normal, compile_fail, ['']) test('T22326_fail_pat', normal, compile_fail, ['']) test('T22326_fail_nonlinear', normal, compile_fail, ['']) test('T22326_fail_caseof', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b79a9071bd9a8f1de378567320c112ea05822a1c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b79a9071bd9a8f1de378567320c112ea05822a1c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 20:22:18 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 15:22:18 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 3 commits: configure: Bump version to 9.10 Message-ID: <65eb737aa23de_2fe31822b790469331@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: cdb256b0 by Ben Gamari at 2024-03-08T10:38:53-05:00 configure: Bump version to 9.10 - - - - - 53b7a1fb by Ben Gamari at 2024-03-08T11:15:25-05:00 Bump transformers submodule to 0.6.1.1 - - - - - ea2615f4 by Ben Gamari at 2024-03-08T15:19:21-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - 3 changed files: - configure.ac - libraries/transformers - testsuite/tests/rts/T18623/all.T Changes: ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.9], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.10.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are ===================================== libraries/transformers ===================================== @@ -1 +1 @@ -Subproject commit ef4fa181ebea77ac6997d392d1ef5a09524f06b2 +Subproject commit ba3503905dec072acc6515323c884706efd4dbb4 ===================================== testsuite/tests/rts/T18623/all.T ===================================== @@ -8,7 +8,7 @@ test('T18623', # Recent versions of osx report an error when running `ulimit -v` when(opsys('darwin'), skip), when(arch('powerpc64le'), skip), - cmd_prefix('ulimit -v ' + str(1024 ** 2) + ' && '), + cmd_prefix('ulimit -v ' + str(8 * 1024 ** 2) + ' && '), ignore_stdout], run_command, ['{compiler} --version']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1da0bdcb4adbf4eb7d0584c0d76aee83bc7f5166...ea2615f4d12f8d4fa5a1fe3824ed9a2ee588469f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1da0bdcb4adbf4eb7d0584c0d76aee83bc7f5166...ea2615f4d12f8d4fa5a1fe3824ed9a2ee588469f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 20:53:47 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 15:53:47 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 13 commits: base: Use strerror_r instead of strerror Message-ID: <65eb7adbab1b2_2fe3183170a407481b@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 2f7121b9 by Ben Gamari at 2024-03-08T13:56:35-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - f5898080 by Jade at 2024-03-08T13:56:36-05:00 Error Messages: Improve response for illegal forall and GADT Syntax forall in a type with -XNoExplicitForAll used to suggest RankNTypes. In this patch this is changed to the correct ExplicitForAll. using a where in a data declaration with -XNoGADTSyntax used to suggest GADTs In this patch this is changed to the correct GADTSyntax. Fixes: #24448 - - - - - 0d33112f by Jade at 2024-03-08T13:56:37-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - f646f65c by Patrick at 2024-03-08T13:56:38-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 0af6b5ea by Ben Gamari at 2024-03-08T13:56:38-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 33f16f40 by Cheng Shao at 2024-03-08T13:56:38-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - a7c876e3 by Ben Gamari at 2024-03-08T13:56:39-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - c2c039ae by Ben Gamari at 2024-03-08T15:52:01-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 8c456113 by Ben Gamari at 2024-03-08T15:52:01-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - 773c4d58 by Ben Gamari at 2024-03-08T15:52:01-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - 9f2df4c4 by Ben Gamari at 2024-03-08T15:52:01-05:00 configure: Bump version to 9.10 - - - - - 4913e54c by Ben Gamari at 2024-03-08T15:52:01-05:00 Bump transformers submodule to 0.6.1.1 - - - - - ec4d01fe by Ben Gamari at 2024-03-08T15:52:01-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - configure.ac - libraries/base/changelog.md - + libraries/ghc-internal/cbits/strerror.c - libraries/ghc-internal/configure.ac - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/jsbits/errno.js - libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs - libraries/transformers - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/linker/Elf.c - testsuite/driver/testlib.py - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - + testsuite/tests/hiefile/should_compile/T24493.hs - + testsuite/tests/hiefile/should_compile/T24493.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea2615f4d12f8d4fa5a1fe3824ed9a2ee588469f...ec4d01feec804f80aef03f97f75f9095903e65d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea2615f4d12f8d4fa5a1fe3824ed9a2ee588469f...ec4d01feec804f80aef03f97f75f9095903e65d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 23:08:34 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 18:08:34 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 7 commits: configure: Bump version to 9.10 Message-ID: <65eb9a72bcf85_2fe31868defa48352d@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 2a9e11c8 by Ben Gamari at 2024-03-08T17:43:04-05:00 configure: Bump version to 9.10 - - - - - feb08492 by Ben Gamari at 2024-03-08T17:43:04-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 02b9731a by Ben Gamari at 2024-03-08T17:43:04-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - 5c75d647 by Ben Gamari at 2024-03-08T17:44:31-05:00 base: Bump version to 4.20.0.0 - - - - - 56e18b26 by Ben Gamari at 2024-03-08T17:44:31-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 7c25cc05 by Ben Gamari at 2024-03-08T17:44:31-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 9b97d2c4 by Ben Gamari at 2024-03-08T17:44:31-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 30 changed files: - compiler/ghc.cabal.in - configure.ac - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-experimental/ghc-experimental.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-prim/ghc-prim.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - libraries/hpc - libraries/os-string - libraries/parsec - libraries/process - libraries/semaphore-compat - libraries/stm - libraries/template-haskell/template-haskell.cabal.in - libraries/terminfo - libraries/text - libraries/transformers - libraries/unix The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ec4d01feec804f80aef03f97f75f9095903e65d5...9b97d2c46e2d86ba4af9c10ece9e1b29553657cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ec4d01feec804f80aef03f97f75f9095903e65d5...9b97d2c46e2d86ba4af9c10ece9e1b29553657cc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 23:27:26 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 18:27:26 -0500 Subject: [Git][ghc/ghc][master] base: Use strerror_r instead of strerror Message-ID: <65eb9edea1118_2fe31877ba69088934@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - 6 changed files: - libraries/base/changelog.md - + libraries/ghc-internal/cbits/strerror.c - libraries/ghc-internal/configure.ac - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/jsbits/errno.js - libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs Changes: ===================================== libraries/base/changelog.md ===================================== @@ -28,6 +28,7 @@ and [CLC proposal #258](https://github.com/haskell/core-libraries-committee/issues/258)) * Add `System.Mem.performMajorGC` ([CLC proposal #230](https://github.com/haskell/core-libraries-committee/issues/230)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) + * `Foreign.C.Error.errnoToIOError` now uses the reentrant `strerror_r` to render system errors when possible ([CLC proposal #249](https://github.com/haskell/core-libraries-committee/issues/249)) * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) * Change the types of the `GHC.Stack.StackEntry.closureType` and `GHC.InfoProv.InfoProv.ipDesc` record fields to use `GHC.Exts.Heap.ClosureType` rather than an `Int`. To recover the old value use `fromEnum`. ([CLC proposal #210](https://github.com/haskell/core-libraries-committee/issues/210)) ===================================== libraries/ghc-internal/cbits/strerror.c ===================================== @@ -0,0 +1,29 @@ +// glibc will only expose the POSIX strerror_r if this is defined. +#define _POSIX_C_SOURCE 200112L + +#include +#include + +// This must be included after lest _GNU_SOURCE may be defined. +#include "HsBaseConfig.h" + +// returns zero on success +int base_strerror_r(int errnum, char *ptr, size_t buflen) +{ +#if defined(HAVE_STRERROR_R) + int ret = strerror_r(errnum, ptr, buflen); + if (ret == ERANGE) { + // Ellipsize the error + ptr[buflen-4] = '.'; + ptr[buflen-3] = '.'; + ptr[buflen-2] = '.'; + ret = 0; + } + return ret; +#elif defined(HAVE_STRERROR_S) + strerror_s(ptr, buflen, errnum); + return 0; +#else +#error neither strerror_r nor strerror_s are supported +#endif +} ===================================== libraries/ghc-internal/configure.ac ===================================== @@ -41,6 +41,12 @@ AC_CHECK_DECLS([CLOCK_PROCESS_CPUTIME_ID], [], [], [[#include ]]) AC_CHECK_FUNCS([getclock getrusage times]) AC_CHECK_FUNCS([_chsize_s ftruncate]) +AC_CHECK_FUNCS([strerror_r strerror_s]) + +if test "$ac_cv_func_strerror_r" = no && test "$ac_cv_func_strerror_s" = no; then + AC_MSG_ERROR([Either strerror_r or strerror_s must be available]) +fi + # event-related fun # The line below already defines HAVE_KQUEUE and HAVE_POLL, so technically some of the # subsequent portions that redefine them could be skipped. However, we keep those portions ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -330,6 +330,7 @@ Library cbits/primFloat.c cbits/sysconf.c cbits/fs.c + cbits/strerror.c cmm-sources: cbits/StackCloningDecoding.cmm ===================================== libraries/ghc-internal/jsbits/errno.js ===================================== @@ -22,7 +22,7 @@ function h$unsupported(status, c) { return status; } -function h$strerror(err) { +function h$base_strerror(err) { if(err === 12456) { RETURN_UBX_TUP2(h$encodeUtf8("operation unsupported on this platform"), 0); } ===================================== libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs ===================================== @@ -91,6 +91,9 @@ module GHC.Internal.Foreign.C.Error ( #include "HsBaseConfig.h" import GHC.Internal.Foreign.Ptr +#if !defined(javascript_HOST_ARCH) +import GHC.Internal.Foreign.Marshal.Alloc +#endif import GHC.Internal.Foreign.C.Types import GHC.Internal.Foreign.C.String import GHC.Internal.Data.Functor ( void ) @@ -460,6 +463,29 @@ throwErrnoPathIfMinus1_ = throwErrnoPathIf_ (== -1) -- conversion of an "errno" value into IO error -- -------------------------------------------- +errnoToString :: Errno -> IO String + +#if defined(javascript_HOST_ARCH) +foreign import ccall unsafe "base_strerror" + c_strerror :: Errno -> IO (Ptr CChar) + +errnoToString errno = c_strerror errno >>= peekCString + +#else +foreign import ccall "base_strerror_r" + c_strerror_r :: Errno -> Ptr CChar -> CSize -> IO CInt + +errnoToString errno = + allocaBytes len $ \ptr -> do + ret <- c_strerror_r errno ptr len + if ret /= 0 + then return "errnoToString failed" + else peekCString ptr + where + len :: Num a => a + len = 512 +#endif + -- | Construct an 'IOError' based on the given 'Errno' value. -- The optional information can be used to improve the accuracy of -- error messages. @@ -470,7 +496,7 @@ errnoToIOError :: String -- ^ the location where the error occurred -> Maybe String -- ^ optional filename associated with the error -> IOError errnoToIOError loc errno maybeHdl maybeName = unsafePerformIO $ do - str <- strerror errno >>= peekCString + str <- errnoToString errno return (IOError maybeHdl errType loc str (Just errno') maybeName) where Errno errno' = errno @@ -576,5 +602,3 @@ errnoToIOError loc errno maybeHdl maybeName = unsafePerformIO $ do | errno == eXDEV = UnsupportedOperation | otherwise = OtherError -foreign import ccall unsafe "string.h" strerror :: Errno -> IO (Ptr CChar) - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2859a6379be53c5f6de34f6dd868ef0f0738b08c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2859a6379be53c5f6de34f6dd868ef0f0738b08c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 23:28:50 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 08 Mar 2024 18:28:50 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 16 commits: base: Use strerror_r instead of strerror Message-ID: <65eb9f32cbd4e_2fe31878e170890327@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - e2ea2ce8 by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/CloneStack: Bounds check array write - - - - - 23f81003 by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - c34a51b6 by Ben Gamari at 2024-03-08T18:28:35-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - c2608564 by Ben Gamari at 2024-03-08T18:28:35-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - a983949a by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/IPE: Don't expose helper in header - - - - - 00b4fe2e by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - 69118f5f by Ben Gamari at 2024-03-08T18:28:36-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 13568b23 by Ben Gamari at 2024-03-08T18:28:36-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 0c93142d by Ben Gamari at 2024-03-08T18:28:36-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 6d4bdf9e by Jade at 2024-03-08T18:28:37-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - a930b2fd by Patrick at 2024-03-08T18:28:38-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 0852436a by Vaibhav Sagar at 2024-03-08T18:28:42-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 52525fcc by Ben Gamari at 2024-03-08T18:28:42-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - bb867146 by Cheng Shao at 2024-03-08T18:28:42-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 4e3e1f8b by Ben Gamari at 2024-03-08T18:28:43-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - + libraries/ghc-internal/cbits/strerror.c - libraries/ghc-internal/configure.ac - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/jsbits/errno.js - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs - + libraries/ghc-internal/src/GHC/Internal/InfoProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv.hsc → libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - libraries/ghc-internal/src/GHC/Internal/Stack/CloneStack.hs - rts/CloneStack.c - rts/CloneStack.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7c876e35ee0998bba256d4bf0808750d57dc7b4...4e3e1f8be39871b43c788584543d27718a9dbe35 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7c876e35ee0998bba256d4bf0808750d57dc7b4...4e3e1f8be39871b43c788584543d27718a9dbe35 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 8 23:52:50 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 08 Mar 2024 18:52:50 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 26 commits: base: Use strerror_r instead of strerror Message-ID: <65eba4d2642ea_2fe31886f9a5c1015d6@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - e2ea2ce8 by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/CloneStack: Bounds check array write - - - - - 23f81003 by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - c34a51b6 by Ben Gamari at 2024-03-08T18:28:35-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - c2608564 by Ben Gamari at 2024-03-08T18:28:35-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - a983949a by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/IPE: Don't expose helper in header - - - - - 00b4fe2e by Ben Gamari at 2024-03-08T18:28:35-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - 69118f5f by Ben Gamari at 2024-03-08T18:28:36-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 13568b23 by Ben Gamari at 2024-03-08T18:28:36-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 0c93142d by Ben Gamari at 2024-03-08T18:28:36-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 6d4bdf9e by Jade at 2024-03-08T18:28:37-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - a930b2fd by Patrick at 2024-03-08T18:28:38-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 0852436a by Vaibhav Sagar at 2024-03-08T18:28:42-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 52525fcc by Ben Gamari at 2024-03-08T18:28:42-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - bb867146 by Cheng Shao at 2024-03-08T18:28:42-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 4e3e1f8b by Ben Gamari at 2024-03-08T18:28:43-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - f2b975d1 by Ben Gamari at 2024-03-08T18:36:11-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - ce0fb007 by Ben Gamari at 2024-03-08T18:36:12-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - 1c688389 by Ben Gamari at 2024-03-08T18:36:12-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - a3b450a6 by Ben Gamari at 2024-03-08T18:36:12-05:00 configure: Bump version to 9.10 - - - - - 49fd6982 by Ben Gamari at 2024-03-08T18:36:12-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 7548efc0 by Ben Gamari at 2024-03-08T18:36:12-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - 9752f8cd by Ben Gamari at 2024-03-08T18:52:24-05:00 base: Bump version to 4.20.0.0 - - - - - 936a0e62 by Ben Gamari at 2024-03-08T18:52:24-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4576390b by Ben Gamari at 2024-03-08T18:52:24-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 0ef1f84b by Ben Gamari at 2024-03-08T18:52:24-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - configure.ac - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/ghc-boot-th.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b97d2c46e2d86ba4af9c10ece9e1b29553657cc...0ef1f84b5381e189a92a8b0dd1c63796dac1cee1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b97d2c46e2d86ba4af9c10ece9e1b29553657cc...0ef1f84b5381e189a92a8b0dd1c63796dac1cee1 You're receiving 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 Mar 9 03:32:54 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 08 Mar 2024 22:32:54 -0500 Subject: [Git][ghc/ghc][wip/T23942] 21 commits: Rephrase error message to say "visible arguments" (#24318) Message-ID: <65ebd866c4cb7_2fe318e648a081095d@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 35de5373 by Matthew Craven at 2024-03-08T16:01:07-05:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. - - - - - 69583bdb by Matthew Craven at 2024-03-08T16:01:07-05:00 small fixes and improvements - - - - - a776b257 by Matthew Craven at 2024-03-08T16:01:08-05:00 Accept test output changes - - - - - 2a506880 by Matthew Craven at 2024-03-08T16:01:08-05:00 review suggestion - - - - - 177e258e by Matthew Craven at 2024-03-08T22:30:44-05:00 Mess with an awful lot of build-order imports - - - - - 7530714c by Matthew Craven at 2024-03-08T22:31:24-05:00 Improve a variable name - - - - - 2e20ca9d by Matthew Craven at 2024-03-08T22:31:59-05:00 'toStrict' is not exported from Data.ByteString until 0.11 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/StgToJS/Types.hs - compiler/GHC/Tc/Errors/Hole/Plugin.hs-boot - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Types/LclEnv.hs-boot - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Unify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/438278dd05e17598384b5bd74c930ad1747317a9...2e20ca9d12b4f3b64b2e51a258e6c929c5de4f59 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/438278dd05e17598384b5bd74c930ad1747317a9...2e20ca9d12b4f3b64b2e51a258e6c929c5de4f59 You're receiving 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 Mar 9 03:40:26 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Fri, 08 Mar 2024 22:40:26 -0500 Subject: [Git][ghc/ghc][wip/T23942] Reference newly-created ticket Message-ID: <65ebda2a55021_2fe318eb173cc11335e@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: ac5a901f by Matthew Craven at 2024-03-08T22:39:51-05:00 Reference newly-created ticket - - - - - 1 changed file: - libraries/ghc-internal/src/GHC/Internal/Base.hs Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -394,7 +394,7 @@ W1: build failures, so enforcement of that requirement has historically been pretty spotty, causing issues like #23942. - Improving this situation is discussed at #. + Improving this situation is discussed at #24520. W2: Non-exhaustive pattern matches, incomplete record selectors, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac5a901f489568ce6869cff6faa77c883077cf8c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac5a901f489568ce6869cff6faa77c883077cf8c You're receiving 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 Mar 9 05:39:50 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 00:39:50 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Error messages: Improve Error messages for Data constructors in type signatures. Message-ID: <65ebf626cb718_2fe3181217522013619@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4ee269db by Jade at 2024-03-09T00:39:27-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - 1a1ada5d by Patrick at 2024-03-09T00:39:28-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - ebf4709c by Vaibhav Sagar at 2024-03-09T00:39:30-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 2ea5608e by Ben Gamari at 2024-03-09T00:39:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 610d3c87 by Cheng Shao at 2024-03-09T00:39:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c4e85d48 by Ben Gamari at 2024-03-09T00:39:31-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 6204c3e7 by Vladislav Zavialov at 2024-03-09T00:39:31-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - rts/linker/Elf.c - testsuite/driver/testlib.py - + testsuite/tests/hiefile/should_compile/T24493.hs - + testsuite/tests/hiefile/should_compile/T24493.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/module/mod98.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_fail/NoPatternSynonyms.stderr - + testsuite/tests/parser/should_fail/T17879a.hs - + testsuite/tests/parser/should_fail/T17879a.stderr - + testsuite/tests/parser/should_fail/T17879b.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e3e1f8be39871b43c788584543d27718a9dbe35...6204c3e781fd3f279eed73d6756a83a4ad7e5d78 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e3e1f8be39871b43c788584543d27718a9dbe35...6204c3e781fd3f279eed73d6756a83a4ad7e5d78 You're receiving 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 Mar 9 08:40:10 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 03:40:10 -0500 Subject: [Git][ghc/ghc][master] Error messages: Improve Error messages for Data constructors in type signatures. Message-ID: <65ec206a39e9e_13136c4ce0bcc293bd@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - 14 changed files: - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - testsuite/tests/module/mod98.stderr - testsuite/tests/parser/should_fail/NoPatternSynonyms.stderr - + testsuite/tests/parser/should_fail/T17879a.hs - + testsuite/tests/parser/should_fail/T17879a.stderr - + testsuite/tests/parser/should_fail/T17879b.hs - + testsuite/tests/parser/should_fail/T17879b.stderr - testsuite/tests/parser/should_fail/T3811.stderr - testsuite/tests/parser/should_fail/all.T - testsuite/tests/parser/should_fail/readFail031.stderr Changes: ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -455,11 +455,17 @@ instance Diagnostic PsMessage where PsErrIllegalRoleName role _nearby -> mkSimpleDecorated $ text "Illegal role name" <+> quotes (ppr role) - PsErrInvalidTypeSignature lhs - -> mkSimpleDecorated $ - text "Invalid type signature:" - <+> ppr lhs - <+> text ":: ..." + PsErrInvalidTypeSignature reason lhs + -> mkSimpleDecorated $ case reason of + PsErrInvalidTypeSig_DataCon -> text "Invalid data constructor" <+> quotes (ppr lhs) <+> + text "in type signature" <> colon $$ + text "You can only define data constructors in data type declarations." + PsErrInvalidTypeSig_Qualified -> text "Invalid qualified name in type signature." + PsErrInvalidTypeSig_Other -> text "Invalid type signature" <> colon $$ + text "A type signature should be of form" <+> + placeHolder "variables" <+> dcolon <+> placeHolder "type" <> + dot + where placeHolder = angleBrackets . text PsErrUnexpectedTypeInDecl t what tc tparms equals_or_where -> mkSimpleDecorated $ vcat [ text "Unexpected type" <+> quotes (ppr t) @@ -779,15 +785,17 @@ instance Diagnostic PsMessage where sug_missingdo _ = Nothing PsErrParseRightOpSectionInPat{} -> noHints PsErrIllegalRoleName _ nearby -> [SuggestRoles nearby] - PsErrInvalidTypeSignature lhs -> + PsErrInvalidTypeSignature reason lhs -> if | foreign_RDR `looks_like` lhs -> [suggestExtension LangExt.ForeignFunctionInterface] | default_RDR `looks_like` lhs -> [suggestExtension LangExt.DefaultSignatures] | pattern_RDR `looks_like` lhs -> [suggestExtension LangExt.PatternSynonyms] + | PsErrInvalidTypeSig_Qualified <- reason + -> [SuggestTypeSignatureRemoveQualifier] | otherwise - -> [SuggestTypeSignatureForm] + -> [] where -- A common error is to forget the ForeignFunctionInterface flag -- so check for that, and suggest. cf #3805 ===================================== compiler/GHC/Parser/Errors/Types.hs ===================================== @@ -389,7 +389,7 @@ data PsMessage | PsErrIllegalRoleName !FastString [Role] -- | Invalid type signature - | PsErrInvalidTypeSignature !(LHsExpr GhcPs) + | PsErrInvalidTypeSignature !PsInvalidTypeSignature !(LHsExpr GhcPs) -- | Unexpected type in declaration | PsErrUnexpectedTypeInDecl !(LHsType GhcPs) @@ -480,6 +480,11 @@ data PsErrParseDetails -- ^ Did we parse a \"pattern\" keyword? } +data PsInvalidTypeSignature + = PsErrInvalidTypeSig_Qualified + | PsErrInvalidTypeSig_DataCon + | PsErrInvalidTypeSig_Other + -- | Is the parsed pattern recursive? data PatIsRecursive = YesPatIsRecursive @@ -531,6 +536,7 @@ data NumUnderscoreReason | NumUnderscore_Float deriving (Show,Eq,Ord) + data LexErrKind = LexErrKind_EOF -- ^ End of input | LexErrKind_UTF8 -- ^ UTF-8 decoding error ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1398,13 +1398,19 @@ checkPatBind _loc annsIn lhs (L _ grhss) mult = do checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName) -checkValSigLhs (L _ (HsVar _ lrdr@(L _ v))) - | isUnqual v - , not (isDataOcc (rdrNameOcc v)) - = return lrdr +checkValSigLhs lhs@(L l lhs_expr) = + case lhs_expr of + HsVar _ lrdr@(L _ v) -> check_var v lrdr + _ -> make_err PsErrInvalidTypeSig_Other + where + check_var v lrdr + | not (isUnqual v) = make_err PsErrInvalidTypeSig_Qualified + | isDataOcc occ_n = make_err PsErrInvalidTypeSig_DataCon + | otherwise = pure lrdr + where occ_n = rdrNameOcc v + make_err reason = addFatalError $ + mkPlainErrorMsgEnvelope (locA l) (PsErrInvalidTypeSignature reason lhs) -checkValSigLhs lhs@(L l _) - = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ PsErrInvalidTypeSignature lhs checkDoAndIfThenElse :: (Outputable a, Outputable b, Outputable c) ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -54,6 +54,7 @@ data AvailableBindings | UnnamedBinding -- ^ An unknown binding (i.e. too complicated to turn into a 'Name') + data LanguageExtensionHint = -- | Suggest to enable the input extension. This is the hint that -- GHC emits if this is not a \"known\" fix, i.e. this is GHC giving @@ -297,13 +298,13 @@ data GhcHint -} | SuggestQualifyStarOperator - {-| Suggests that a type signature should have form :: + {-| Suggests that for a type signature 'M.x :: ...' the qualifier should be omitted in order to be accepted by GHC. Triggered by: 'GHC.Parser.Errors.Types.PsErrInvalidTypeSignature' - Test case(s): parser/should_fail/T3811 + Test case(s): module/mod98 -} - | SuggestTypeSignatureForm + | SuggestTypeSignatureRemoveQualifier {-| Suggests to move an orphan instance (for a typeclass or a type or data family), or to newtype-wrap it. ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -127,8 +127,8 @@ instance Outputable GhcHint where -> text "To use (or export) this operator in" <+> text "modules with StarIsType," $$ text " including the definition module, you must qualify it." - SuggestTypeSignatureForm - -> text "A type signature should be of form :: " + SuggestTypeSignatureRemoveQualifier + -> text "Perhaps you meant to omit the qualifier" SuggestAddToHSigExportList _name mb_mod -> let header = text "Try adding it to the export list of" in case mb_mod of ===================================== testsuite/tests/module/mod98.stderr ===================================== @@ -1,5 +1,4 @@ mod98.hs:3:1: error: [GHC-94426] - Invalid type signature: M.x :: ... - Suggested fix: - A type signature should be of form :: + Invalid qualified name in type signature. + Suggested fix: Perhaps you meant to omit the qualifier ===================================== testsuite/tests/parser/should_fail/NoPatternSynonyms.stderr ===================================== @@ -1,4 +1,5 @@ NoPatternSynonyms.hs:3:1: error: [GHC-94426] - Invalid type signature: pattern P :: ... + Invalid type signature: + A type signature should be of form :: . Suggested fix: Perhaps you intended to use PatternSynonyms ===================================== testsuite/tests/parser/should_fail/T17879a.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +Foo :: () +Foo = () ===================================== testsuite/tests/parser/should_fail/T17879a.stderr ===================================== @@ -0,0 +1,4 @@ + +T17879a.hs:3:1: error: [GHC-94426] + Invalid data constructor ‘Foo’ in type signature: + You can only define data constructors in data type declarations. ===================================== testsuite/tests/parser/should_fail/T17879b.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +_ :: () +_ = () ===================================== testsuite/tests/parser/should_fail/T17879b.stderr ===================================== @@ -0,0 +1,4 @@ + +T17879b.hs:3:1: error: [GHC-94426] + Invalid type signature: + A type signature should be of form :: . ===================================== testsuite/tests/parser/should_fail/T3811.stderr ===================================== @@ -1,5 +1,4 @@ T3811.hs:4:1: error: [GHC-94426] - Invalid type signature: f x :: ... - Suggested fix: - A type signature should be of form :: + Invalid type signature: + A type signature should be of form :: . ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -225,3 +225,5 @@ test('ListTuplePunsFail2', extra_files(['ListTuplePunsFail2.hs']), ghci_script, test('ListTuplePunsFail3', extra_files(['ListTuplePunsFail3.hs']), ghci_script, ['ListTuplePunsFail3.script']) test('ListTuplePunsFail4', extra_files(['ListTuplePunsFail4.hs']), ghci_script, ['ListTuplePunsFail4.script']) test('ListTuplePunsFail5', extra_files(['ListTuplePunsFail5.hs']), ghci_script, ['ListTuplePunsFail5.script']) +test('T17879a', normal, compile_fail, ['']) +test('T17879b', normal, compile_fail, ['']) ===================================== testsuite/tests/parser/should_fail/readFail031.stderr ===================================== @@ -1,5 +1,4 @@ readFail031.hs:4:3: error: [GHC-94426] - Invalid type signature: (:+) :: ... - Suggested fix: - A type signature should be of form :: + Invalid data constructor ‘(:+)’ in type signature: + You can only define data constructors in data type declarations. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/edb9bf77104a8afec6e54e646f07b1a9849dfc76 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/edb9bf77104a8afec6e54e646f07b1a9849dfc76 You're receiving 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 Mar 9 08:41:17 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 03:41:17 -0500 Subject: [Git][ghc/ghc][master] HieAst: add module name #24493 Message-ID: <65ec20ad9f625_13136c51fc9803549c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 13 changed files: - compiler/GHC.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - + testsuite/tests/hiefile/should_compile/T24493.hs - + testsuite/tests/hiefile/should_compile/T24493.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -1157,7 +1157,7 @@ instance DesugaredMod DesugaredModule where type ParsedSource = Located (HsModule GhcPs) type RenamedSource = (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], - Maybe (LHsDoc GhcRn)) + Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName)) type TypecheckedSource = LHsBinds GhcTc -- NOTE: ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -63,12 +63,12 @@ extractDocs dflags , tcg_imports = import_avails , tcg_insts = insts , tcg_fam_insts = fam_insts - , tcg_doc_hdr = mb_doc_hdr + , tcg_hdr_info = mb_hdr_info , tcg_th_docs = th_docs_var , tcg_type_env = ty_env } = do th_docs <- liftIO $ readIORef th_docs_var - let doc_hdr = (unLoc <$> mb_doc_hdr) + let doc_hdr = unLoc <$> fst mb_hdr_info ExtractedTHDocs th_hdr th_decl_docs th_arg_docs th_inst_docs = extractTHDocs th_docs mod_docs = Docs ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -210,7 +210,8 @@ call and just recurse directly in to the subexpressions. -- These synonyms match those defined in compiler/GHC.hs type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn] , Maybe [(LIE GhcRn, Avails)] - , Maybe (LHsDoc GhcRn) ) + , Maybe (LHsDoc GhcRn) + , Maybe (XRec GhcRn ModuleName) ) type TypecheckedSource = LHsBinds GhcTc @@ -321,8 +322,9 @@ getCompressedAsts ts rs top_ev_binds insts tcs = enrichHie :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon] -> HieASTs Type -enrichHie ts (hsGrp, imports, exports, docs) ev_bs insts tcs = +enrichHie ts (hsGrp, imports, exports, docs, modName) ev_bs insts tcs = runIdentity $ flip evalStateT initState $ flip runReaderT SourceInfo $ do + modName <- toHie (IEC Export <$> modName) tasts <- toHie $ fmap (BC RegularBind ModuleScope) ts rasts <- processGrp hsGrp imps <- toHie $ filter (not . ideclImplicit . ideclExt . unLoc) imports @@ -344,7 +346,8 @@ enrichHie ts (hsGrp, imports, exports, docs) ev_bs insts tcs = (realSrcSpanEnd $ nodeSpan (NE.last children)) flat_asts = concat - [ tasts + [ modName + , tasts , rasts , imps , exps ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -297,8 +297,8 @@ tcRnModuleTcRnM hsc_env mod_sum -- We will rename it properly after renaming everything else so that -- haddock can link the identifiers ; tcg_env <- return (tcg_env - { tcg_doc_hdr = fmap (\(WithHsDocIdentifiers str _) -> WithHsDocIdentifiers str []) - <$> maybe_doc_hdr }) + { tcg_hdr_info = (fmap (\(WithHsDocIdentifiers str _) -> WithHsDocIdentifiers str []) + <$> maybe_doc_hdr , maybe_mod ) }) ; -- If the whole module is warned about or deprecated -- (via mod_deprec) record that in tcg_warns. If we do thereby add -- a WarnAll, it will override any subsequent deprecations added to tcg_warns @@ -347,7 +347,7 @@ tcRnModuleTcRnM hsc_env mod_sum -- Rename the module header properly after we have renamed everything else ; maybe_doc_hdr <- traverse rnLHsDoc maybe_doc_hdr; ; tcg_env <- return (tcg_env - { tcg_doc_hdr = maybe_doc_hdr }) + { tcg_hdr_info = (maybe_doc_hdr, maybe_mod) }) ; -- add extra source files to tcg_dependent_files addDependentFiles src_files @@ -3115,14 +3115,15 @@ runRenamerPlugin gbl_env hs_group = do -- exception/signal an error. type RenamedStuff = (Maybe (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], - Maybe (LHsDoc GhcRn))) + Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))) -- | Extract the renamed information from TcGblEnv. getRenamedStuff :: TcGblEnv -> RenamedStuff getRenamedStuff tc_result = fmap (\decls -> ( decls, tcg_rn_imports tc_result - , tcg_rn_exports tc_result, tcg_doc_hdr tc_result ) ) + , tcg_rn_exports tc_result, doc_hdr, name_hdr )) (tcg_rn_decls tc_result) + where (doc_hdr, name_hdr) = tcg_hdr_info tc_result runTypecheckerPlugin :: ModSummary -> TcGblEnv -> TcM TcGblEnv runTypecheckerPlugin sum gbl_env = do ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -605,7 +605,9 @@ data TcGblEnv tcg_fords :: [LForeignDecl GhcTc], -- ...Foreign import & exports tcg_patsyns :: [PatSyn], -- ...Pattern synonyms - tcg_doc_hdr :: Maybe (LHsDoc GhcRn), -- ^ Maybe Haddock header docs + tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName)), + -- ^ Maybe Haddock header docs and Maybe located module name + tcg_hpc :: !AnyHpcUsage, -- ^ @True@ if any part of the -- prog uses hpc instrumentation. -- NB. BangPattern is to fix a leak, see #15111 ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -523,8 +523,8 @@ mergeSignatures tcg_rn_decls = tcg_rn_decls orig_tcg_env, -- Annotations tcg_ann_env = tcg_ann_env orig_tcg_env, - -- Documentation header - tcg_doc_hdr = tcg_doc_hdr orig_tcg_env + -- Documentation header and located module name + tcg_hdr_info = tcg_hdr_info orig_tcg_env -- tcg_dus? -- tcg_th_used = tcg_th_used orig_tcg_env, -- tcg_th_splice_used = tcg_th_splice_used orig_tcg_env ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -346,7 +346,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this tcg_merged = [], tcg_dfun_n = dfun_n_var, tcg_keep = keep_var, - tcg_doc_hdr = Nothing, + tcg_hdr_info = (Nothing,Nothing), tcg_hpc = False, tcg_main = Nothing, tcg_self_boot = NoSelfBoot, ===================================== testsuite/tests/hiefile/should_compile/T24493.hs ===================================== @@ -0,0 +1,3 @@ +module T24493 where + +go = "1" ===================================== testsuite/tests/hiefile/should_compile/T24493.stderr ===================================== @@ -0,0 +1,33 @@ +==================== HIE AST ==================== +File: T24493.hs +Node at T24493.hs:(1,8)-(3,8): Source: From source + {(annotations: {(Module, Module)}), (types: []), + (identifier info: {})} + + Node at T24493.hs:1:8-13: Source: From source + {(annotations: {}), (types: []), + (identifier info: {(module T24493, Details: Nothing {export})})} + + Node at T24493.hs:3:1-8: Source: From source + {(annotations: {(FunBind, HsBindLR), (Match, Match), + (XHsBindsLR, HsBindLR)}), + (types: [0]), (identifier info: {})} + + Node at T24493.hs:3:1-2: Source: From source + {(annotations: {}), (types: []), + (identifier info: {(name T24493.go, Details: Just 0 {LHS of a match group, + regular value bound with scope: ModuleScope bound at: T24493.hs:3:1-8})})} + + Node at T24493.hs:3:4-8: Source: From source + {(annotations: {(GRHS, GRHS)}), (types: []), + (identifier info: {})} + + Node at T24493.hs:3:6-8: Source: From source + {(annotations: {(HsLit, HsExpr)}), (types: [0]), + (identifier info: {})} + + + + +Got valid scopes +Got no roundtrip errors \ No newline at end of file ===================================== testsuite/tests/hiefile/should_compile/all.T ===================================== @@ -23,3 +23,4 @@ test('Scopes', normal, compile, ['-fno-code -fwrite-ide- test('ScopesBug', expect_broken(18425), compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T18425', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T22416', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) +test('T24493', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info -ddump-hie']) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -2,7 +2,7 @@ ==================== Renamer ==================== (Just - ((,,,) + ((,,,,) (HsGroup (NoExtField) (XValBindsLR @@ -2367,6 +2367,16 @@ {Name: GHC.Types.Type}))) (Nothing)))])))))] (Nothing) - (Nothing))) + (Nothing) + (Just + (L + (EpAnn + (EpaSpan { DumpRenamedAst.hs:4:8-21 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: DumpRenamedAst})))) + ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -2,7 +2,7 @@ ==================== Renamer ==================== (Just - ((,,,) + ((,,,,) (HsGroup (NoExtField) (XValBindsLR @@ -316,6 +316,13 @@ [{Name: T14189.MyType} ,{Name: T14189.f} ,{Name: T14189.NT}])])]) - (Nothing))) - - + (Nothing) + (Just + (L + (EpAnn + (EpaSpan { T14189.hs:1:8-13 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: T14189})))) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 91f338a4f1ae59fd6ea482b73a27708113912d5d +Subproject commit 730749b48c3d7b358f4fb07774a1ccfc1d63968a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfb197e3dee6781978a8143d686f0fb593614e52 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfb197e3dee6781978a8143d686f0fb593614e52 You're receiving 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 Mar 9 08:42:05 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 03:42:05 -0500 Subject: [Git][ghc/ghc][master] GHC.Utils.Binary: fix a couple of typos Message-ID: <65ec20dd74747_13136c53eaa44406be@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 1 changed file: - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -597,9 +597,9 @@ getSLEB128 bh = do -- is to the interface file without the variable length encoding we usually -- apply. --- | Encode the argument in it's full length. This is different from many default +-- | Encode the argument in its 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. +-- might do things using variable length encoding. newtype FixedLengthEncoding a = FixedLengthEncoding { unFixedLength :: a } deriving (Eq,Ord,Show) @@ -824,11 +824,11 @@ we stored a tag byte to discriminate between the two cases. This made some sense as it's highly portable but also not very efficient. -However GHC stores a surprisingly large number off large Integer +However GHC stores a surprisingly large number of large Integer values. In the examples looked at between 25% and 50% of Integers serialized were outside of the Int32 range. -Consider a valie like `2724268014499746065`, some sort of hash +Consider a value like `2724268014499746065`, some sort of hash actually generated by GHC. In the old scheme this was encoded as a list of 19 chars. This gave a size of 77 Bytes, one for the length of the list and 76 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2341d81ec72f5ae963072957911a67a739a83db9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2341d81ec72f5ae963072957911a67a739a83db9 You're receiving 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 Mar 9 08:42:46 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 03:42:46 -0500 Subject: [Git][ghc/ghc][master] 2 commits: rts: Drop .wasm suffix from .prof file names Message-ID: <65ec210645a50_13136c5588ba84377f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - 5 changed files: - rts/ProfHeap.c - rts/Profiling.c - rts/RtsUtils.c - rts/RtsUtils.h - testsuite/driver/testlib.py Changes: ===================================== rts/ProfHeap.c ===================================== @@ -448,18 +448,14 @@ initHeapProfiling(void) stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); } else { - stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); strcpy(stem, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(stem,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(stem, ".exe"); +#elif defined(wasm32_HOST_ARCH) + dropExtension(stem, ".wasm"); #endif } ===================================== rts/Profiling.c ===================================== @@ -245,19 +245,14 @@ initProfilingLogFile(void) if (RtsFlags.CcFlags.outputFileNameStem) { stem = RtsFlags.CcFlags.outputFileNameStem; } else { - char *prog; - - prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + char *prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); strcpy(prog, prog_name); + + // Drop the platform's executable suffix if there is one #if defined(mingw32_HOST_OS) - // on Windows, drop the .exe suffix if there is one - { - char *suff; - suff = strrchr(prog,'.'); - if (suff != NULL && !strcmp(suff,".exe")) { - *suff = '\0'; - } - } + dropExtension(prog, ".exe"); +#elif defined(wasm32_HOST_ARCH) + dropExtension(prog, ".wasm"); #endif stem = prog; } ===================================== rts/RtsUtils.c ===================================== @@ -456,3 +456,15 @@ void checkFPUStack(void) } #endif } + +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension) { + int ext_len = strlen(extension); + int path_len = strlen(path); + if (ext_len < path_len) { + char *s = &path[path_len - ext_len]; + if (strcmp(s, extension) == 0) { + *s = '\0'; + } + } +} ===================================== rts/RtsUtils.h ===================================== @@ -62,4 +62,7 @@ void checkFPUStack(void); #define xstr(s) str(s) #define str(s) #s +// Drop the given extension from a filepath. +void dropExtension(char *path, const char *extension); + #include "EndPrivate.h" ===================================== testsuite/driver/testlib.py ===================================== @@ -2329,14 +2329,13 @@ def write_file(f: Path, s: str) -> None: async def check_hp_ok(name: TestName) -> bool: opts = getTestOpts() - actual_name = name + exe_extension() if not opts.ignore_extension else name # do not qualify for hp2ps because we should be in the right directory - hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {actual_name}'.format(**locals()) + hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {name}'.format(**locals()) hp2psResult = await runCmd(hp2psCmd, print_output=True) - actual_ps_path = in_testdir(actual_name, 'ps') + actual_ps_path = in_testdir(name, 'ps') if hp2psResult == 0: if actual_ps_path.exists(): @@ -2345,15 +2344,15 @@ async def check_hp_ok(name: TestName) -> bool: if (gsResult == 0): return True else: - print("hp2ps output for " + actual_name + " is not valid PostScript") + print("hp2ps output for " + name + " is not valid PostScript") return False else: return True # assume postscript is valid without ghostscript else: - print("hp2ps did not generate PostScript for " + actual_name) + print("hp2ps did not generate PostScript for " + name) return False else: - print("hp2ps error when processing heap profile for " + actual_name) + print("hp2ps error when processing heap profile for " + name) return False async def check_prof_ok(name: TestName, way: WayName) -> bool: @@ -2365,7 +2364,7 @@ async def check_prof_ok(name: TestName, way: WayName) -> bool: if not expected_prof_path.exists(): return True - actual_prof_file = add_suffix(name + exe_extension(), 'prof') + actual_prof_file = add_suffix(name, 'prof') actual_prof_path = in_testdir(actual_prof_file) if not actual_prof_path.exists(): View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2341d81ec72f5ae963072957911a67a739a83db9...259495ee3de352d259a07b577f3089b34ddf283f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2341d81ec72f5ae963072957911a67a739a83db9...259495ee3de352d259a07b577f3089b34ddf283f You're receiving 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 Mar 9 08:43:20 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 03:43:20 -0500 Subject: [Git][ghc/ghc][master] rts/linker: Enable GOT support on all platforms Message-ID: <65ec2128f2041_13136c57b0868481b8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 1 changed file: - rts/linker/Elf.c Changes: ===================================== rts/linker/Elf.c ===================================== @@ -101,10 +101,10 @@ # include #endif +#include "elf_got.h" + #if defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH) -# define NEED_GOT # define NEED_PLT -# include "elf_got.h" # include "elf_plt.h" # include "elf_reloc.h" #endif @@ -798,7 +798,7 @@ ocGetNames_ELF ( ObjectCode* oc ) /* This is a non-empty .bss section. Allocate zeroed space for it, and set its .sh_offset field such that ehdrC + .sh_offset == addr_of_zeroed_space. */ -#if defined(NEED_GOT) || RTS_LINKER_USE_MMAP +#if RTS_LINKER_USE_MMAP if (USE_CONTIGUOUS_MMAP || RtsFlags.MiscFlags.linkerAlwaysPic) { /* The space for bss sections is already preallocated */ CHECK(oc->bssBegin != NULL); @@ -1113,13 +1113,11 @@ ocGetNames_ELF ( ObjectCode* oc ) } } -#if defined(NEED_GOT) if(makeGot( oc )) errorBelch("Failed to create GOT for %s", oc->archiveMemberName ? oc->archiveMemberName : oc->fileName); -#endif result = 1; goto end; @@ -1987,13 +1985,11 @@ ocResolve_ELF ( ObjectCode* oc ) } } -#if defined(NEED_GOT) if(fillGot( oc )) return 0; /* silence warnings */ (void) shnum; (void) shdr; -#endif /* NEED_GOT */ #if defined(aarch64_HOST_ARCH) /* use new relocation design */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c477a8d28d6dd28b0b2e2ca6a937aa2a1db92ea5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c477a8d28d6dd28b0b2e2ca6a937aa2a1db92ea5 You're receiving 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 Mar 9 08:43:47 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 03:43:47 -0500 Subject: [Git][ghc/ghc][master] Drop outdated comment on TcRnIllformedTypePattern Message-ID: <65ec2143c5af0_13136c5884a8c4832@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - 6 changed files: - compiler/GHC/Tc/Errors/Types.hs - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.hs - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.stderr - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.hs - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.stderr - testsuite/tests/vdq-rta/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -4129,19 +4129,15 @@ data TcRnMessage where corresponding to a required type argument (visible forall) does not have a form that can be interpreted as a type pattern. - At the moment, only patterns constructed using the @type@ keyword - are considered well-formed, but this restriction will be relaxed - when part 2 of GHC Proposal #281 is implemented. - Example: vfun :: forall (a :: k) -> () - vfun x = () - -- ^ - -- expected `type x` instead of `x` + vfun !x = () + -- ^^ + -- bang-patterns not allowed as type patterns Test cases: - T22326_fail_raw_pat + T22326_fail_bang_pat -} TcRnIllformedTypePattern :: !(Pat GhcRn) -> TcRnMessage @@ -4173,7 +4169,7 @@ data TcRnMessage where -- lambdas not allowed in type arguments Test cases: - T22326_fail_raw_arg + T22326_fail_lam_arg -} TcRnIllformedTypeArgument :: !(LHsExpr GhcRn) -> TcRnMessage ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.hs ===================================== @@ -1,6 +1,6 @@ {-# LANGUAGE RequiredTypeArguments #-} -module T22326_fail_raw_pat where +module T22326_fail_bang_pat where f :: forall (a :: k) -> () f !x = () \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_pat.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_bang_pat.stderr ===================================== @@ -1,5 +1,5 @@ -T22326_fail_raw_pat.hs:6:3: error: [GHC-88754] +T22326_fail_bang_pat.hs:6:3: error: [GHC-88754] • Ill-formed type pattern: !x • In the pattern: !x In an equation for ‘f’: f !x = () ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.hs → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RequiredTypeArguments #-} -module T22326_fail_raw_arg where +module T22326_fail_lam_arg where f :: forall (a :: k) -> () f (type _) = () ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr → testsuite/tests/vdq-rta/should_fail/T22326_fail_lam_arg.stderr ===================================== @@ -1,5 +1,5 @@ -T22326_fail_raw_arg.hs:9:5: error: [GHC-29092] +T22326_fail_lam_arg.hs:9:5: error: [GHC-29092] • Ill-formed type argument: \ _ -> _ • In the expression: f (\ _ -> _) In an equation for ‘x’: x = f (\ _ -> _) ===================================== testsuite/tests/vdq-rta/should_fail/all.T ===================================== @@ -3,8 +3,8 @@ test('T22326_fail_ext2', normal, compile_fail, ['']) test('T22326_fail_top', normal, compile_fail, ['']) test('T22326_fail_app', normal, compile_fail, ['']) test('T22326_fail_notInScope', normal, compile_fail, ['']) -test('T22326_fail_raw_pat', normal, compile_fail, ['']) -test('T22326_fail_raw_arg', normal, compile_fail, ['']) +test('T22326_fail_bang_pat', normal, compile_fail, ['']) +test('T22326_fail_lam_arg', normal, compile_fail, ['']) test('T22326_fail_pat', normal, compile_fail, ['']) test('T22326_fail_nonlinear', normal, compile_fail, ['']) test('T22326_fail_caseof', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e592857b6e028fbad83712ceda6a0860191d379 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e592857b6e028fbad83712ceda6a0860191d379 You're receiving 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 Mar 9 11:40:20 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 09 Mar 2024 06:40:20 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Fix odd register move reduction Message-ID: <65ec4aa46064b_13136ca8962f059854@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 46b55bb4 by Sven Tennie at 2024-03-09T12:38:09+01:00 Fix odd register move reduction Probably, there're OpRegs with wrong format around. - - - - - 1 changed file: - compiler/GHC/CmmToAsm/RV64/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/Instr.hs ===================================== @@ -434,7 +434,20 @@ mkRegRegMoveInstr src dst = ANN desc instr -- We have to be a bit careful here: A `MOV` can also mean an implicit -- conversion. This case is filtered out. takeRegRegMoveInstr :: Instr -> Maybe (Reg,Reg) -takeRegRegMoveInstr (MOV (OpReg fmt dst) (OpReg fmt' src)) | fmt == fmt' = pure (src, dst) +-- TODO: If this doesn't work (I don't understand WHY): +-- ghc: panic! (the 'impossible' happened) +-- GHC version 9.6.3: +-- RV64.ppr: unhandled CSET conditional +-- FLE t6, t0, ft0 +-- Call stack: +-- CallStack (from HasCallStack): +-- callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic +-- pprPanic, called at compiler/GHC/CmmToAsm/RV64/Ppr.hs:598:11 in ghc:GHC.CmmToAsm.RV64.Ppr +-- CallStack (from HasCallStack): +-- panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error +-- +-- Maybe, checking the format isn't enough and we have to check register types by their number? +-- takeRegRegMoveInstr (MOV (OpReg fmt dst) (OpReg fmt' src)) | fmt == fmt' = pure (src, dst) takeRegRegMoveInstr _ = Nothing -- | Make an unconditional jump instruction. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46b55bb485edadb28be7b9fcf7e16abea4f5a12e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46b55bb485edadb28be7b9fcf7e16abea4f5a12e You're receiving 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 Mar 9 12:47:43 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sat, 09 Mar 2024 07:47:43 -0500 Subject: [Git][ghc/ghc][wip/T23942] Even more implicit dependency import stuff Message-ID: <65ec5a6f21f38_13136cc4231a862422@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 62c6ce49 by Matthew Craven at 2024-03-09T07:46:58-05:00 Even more implicit dependency import stuff - - - - - 3 changed files: - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exception/Context.hs-boot - libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Conc/Internal.hs Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -370,7 +370,7 @@ imports of X must include Y. Such implicit dependencies can be introduced in at least the following ways: W1: - Awkward dependencies: + Common awkward dependencies: * TypeRep metadata introduces references to GHC.Types in EVERY module. * A String literal introduces a reference to GHC.CString, for either unpackCString# or unpackCStringUtf8# depending on its contents. @@ -443,6 +443,11 @@ W5: type-checking. (This doesn't apply to hs-boot files, which can't be given "default" declarations anyway.) +W6: + In the wasm backend, JSFFI imports and exports pull in a bunch of stuff; + see Note [Desugaring JSFFI static export] and Note [Desugaring JSFFI import] + in GHC.HsToCore.Foreign.Wasm. + A complete list could probably be made by going through the known-key names in GHC.Builtin.Names and GHC.Builtin.Names.TH. To test whether the transitive imports are sufficient for any single module, instruct ===================================== libraries/ghc-internal/src/GHC/Internal/Exception/Context.hs-boot ===================================== @@ -2,5 +2,8 @@ module GHC.Internal.Exception.Context where +-- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base +import GHC.Types () + data ExceptionContext ===================================== libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Conc/Internal.hs ===================================== @@ -7,6 +7,9 @@ module GHC.Internal.Wasm.Prim.Conc.Internal ( import GHC.Internal.Base import GHC.Internal.IO +-- See W6 of Note [Tracking dependencies on primitives] in GHC.Internal.Base +import GHC.Internal.Wasm.Prim.Imports () + foreign import javascript safe "new Promise(res => setTimeout(res, $1 / 1000))" js_delay :: Int -> IO () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62c6ce498cd2bd1fe0cf8e17cfc7d84fa3ae44c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62c6ce498cd2bd1fe0cf8e17cfc7d84fa3ae44c0 You're receiving 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 Mar 9 14:09:49 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 09 Mar 2024 09:09:49 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Re-implement takeRegRegMoveInstr Message-ID: <65ec6dad6299_1f4c8ba5730096329@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 886d2e7a by Sven Tennie at 2024-03-09T15:07:51+01:00 Re-implement takeRegRegMoveInstr - - - - - 2 changed files: - compiler/GHC/CmmToAsm/RV64/Instr.hs - compiler/GHC/CmmToAsm/RV64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/Instr.hs ===================================== @@ -433,21 +433,9 @@ mkRegRegMoveInstr src dst = ANN desc instr -- -- We have to be a bit careful here: A `MOV` can also mean an implicit -- conversion. This case is filtered out. -takeRegRegMoveInstr :: Instr -> Maybe (Reg,Reg) --- TODO: If this doesn't work (I don't understand WHY): --- ghc: panic! (the 'impossible' happened) --- GHC version 9.6.3: --- RV64.ppr: unhandled CSET conditional --- FLE t6, t0, ft0 --- Call stack: --- CallStack (from HasCallStack): --- callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic --- pprPanic, called at compiler/GHC/CmmToAsm/RV64/Ppr.hs:598:11 in ghc:GHC.CmmToAsm.RV64.Ppr --- CallStack (from HasCallStack): --- panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error --- --- Maybe, checking the format isn't enough and we have to check register types by their number? --- takeRegRegMoveInstr (MOV (OpReg fmt dst) (OpReg fmt' src)) | fmt == fmt' = pure (src, dst) +takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) +takeRegRegMoveInstr (MOV (OpReg width dst) (OpReg width' src)) + | width == width' && (isFloatReg dst == isFloatReg src) = pure (src, dst) takeRegRegMoveInstr _ = Nothing -- | Make an unconditional jump instruction. @@ -863,6 +851,20 @@ isNbitEncodeable n i = let shift = n - 1 in (-1 `shiftL` shift) <= i && i < (1 ` isEncodeableInWidth :: Width -> Integer -> Bool isEncodeableInWidth = isNbitEncodeable . widthInBits +isIntOp :: Operand -> Bool +isIntOp = not . isFloatOp + +isFloatOp :: Operand -> Bool +isFloatOp (OpReg _ reg) | isFloatReg reg = True +isFloatOp _ = False + +isFloatReg :: Reg -> Bool +isFloatReg (RegReal (RealRegSingle i)) | i > 31 = True +isFloatReg (RegVirtual (VirtualRegF _)) = True +isFloatReg (RegVirtual (VirtualRegD _)) = True +isFloatReg _ = False + + -- | Making far branches -- Conditional branch instructions can target labels in a range of +/- 4 KiB. ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -393,15 +393,6 @@ pprReg w r = case r of -- no support for widths > W64. | otherwise = pprPanic "Unsupported width in register (max is 64)" (ppr w <+> int i) -isIntOp :: Operand -> Bool -isIntOp = not . isFloatOp - -isFloatOp :: Operand -> Bool -isFloatOp (OpReg _ (RegReal (RealRegSingle i))) | i > 31 = True -isFloatOp (OpReg _ (RegVirtual (VirtualRegF _))) = True -isFloatOp (OpReg _ (RegVirtual (VirtualRegD _))) = True -isFloatOp _ = False - isSingleOp :: Operand -> Bool isSingleOp (OpReg W32 _) = True isSingleOp _ = False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/886d2e7aa463200f39dd6eedcc07d7e3a3fd420f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/886d2e7aa463200f39dd6eedcc07d7e3a3fd420f You're receiving 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 Mar 9 14:39:46 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 09:39:46 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] 19 commits: ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65ec74b26c7d7_1f4c8b17da57c99223@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - libraries/base/changelog.md - libraries/base/src/Data/Kind.hs - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - + libraries/ghc-internal/cbits/strerror.c - libraries/ghc-internal/configure.ac - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/jsbits/errno.js - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs - + libraries/ghc-internal/src/GHC/Internal/InfoProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv.hsc → libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - libraries/ghc-internal/src/GHC/Internal/Stack/CloneStack.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/411f5289da39b5a4aacd07ba7532c23c0347694a...ed0b69dc069a23692bff89cfcab1ad9d61999506 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/411f5289da39b5a4aacd07ba7532c23c0347694a...ed0b69dc069a23692bff89cfcab1ad9d61999506 You're receiving 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 Mar 9 14:41:04 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 09:41:04 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 27 commits: Error messages: Improve Error messages for Data constructors in type signatures. Message-ID: <65ec7500c1a07_1f4c8b18f09c01018c3@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - 0e5ffaba by Ben Gamari at 2024-03-09T09:37:37-05:00 rts/CloneStack: Bounds check array write - - - - - 8340a88e by Ben Gamari at 2024-03-09T09:37:37-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - 11790370 by Ben Gamari at 2024-03-09T09:37:37-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 0b998ac8 by Ben Gamari at 2024-03-09T09:37:37-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - e369a4eb by Ben Gamari at 2024-03-09T09:37:37-05:00 rts/IPE: Don't expose helper in header - - - - - 42581aa7 by Ben Gamari at 2024-03-09T09:37:37-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - 1d489ee0 by Ben Gamari at 2024-03-09T09:37:37-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 8d60d39c by Ben Gamari at 2024-03-09T09:40:48-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 783b8e27 by Ben Gamari at 2024-03-09T09:40:48-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 55ad2cee by Ben Gamari at 2024-03-09T09:40:48-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 9280b252 by Ben Gamari at 2024-03-09T09:40:48-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - 2849f53d by Ben Gamari at 2024-03-09T09:40:48-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - e4eb4a0b by Ben Gamari at 2024-03-09T09:40:48-05:00 configure: Bump version to 9.10 - - - - - d11dd298 by Ben Gamari at 2024-03-09T09:40:48-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 04feee4d by Ben Gamari at 2024-03-09T09:40:48-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - 59889436 by Ben Gamari at 2024-03-09T09:40:48-05:00 base: Bump version to 4.20.0.0 - - - - - c27bdcad by Ben Gamari at 2024-03-09T09:40:48-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 1689700b by Ben Gamari at 2024-03-09T09:40:48-05:00 ghc-prim: Bump version to 0.11.0 - - - - - b1c7d8ad by Ben Gamari at 2024-03-09T09:40:48-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 5772336b by Ben Gamari at 2024-03-09T09:40:48-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - configure.ac - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0ef1f84b5381e189a92a8b0dd1c63796dac1cee1...5772336bad8480459a6a8fe2e7d5d9e340738bd4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0ef1f84b5381e189a92a8b0dd1c63796dac1cee1...5772336bad8480459a6a8fe2e7d5d9e340738bd4 You're receiving 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 Mar 9 16:43:09 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 11:43:09 -0500 Subject: [Git][ghc/ghc][wip/T24512] rts/linker: Don't unload native objects when dlinfo isn't available Message-ID: <65ec919d78993_1f4c8b4cb58dc104391@gitlab.mail> Ben Gamari pushed to branch wip/T24512 at Glasgow Haskell Compiler / GHC Commits: 7eeef6b8 by Ben Gamari at 2024-03-09T11:42:25-05:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 5 changed files: - rts/CheckUnload.c - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c Changes: ===================================== rts/CheckUnload.c ===================================== @@ -492,8 +492,6 @@ void checkUnload(void) next = oc->next; ASSERT(oc->status == OBJECT_UNLOADED); - removeOCSectionIndices(s_indices, oc); - // Symbols should be removed by unloadObj_. // NB (osa): If this assertion doesn't hold then freeObjectCode below // will corrupt symhash as keys of that table live in ObjectCodes. If @@ -501,8 +499,17 @@ void checkUnload(void) // RTS) then it's probably because this assertion did not hold. ASSERT(oc->symbols == NULL); - freeObjectCode(oc); - n_unloaded_objects -= 1; + if (oc->unloadable) { + removeOCSectionIndices(s_indices, oc); + freeObjectCode(oc); + n_unloaded_objects -= 1; + } else { + // If we don't have enough information to + // accurately determine the reachability of + // the object then hold onto it. + oc->next = objects; + objects = oc; + } } old_objects = NULL; ===================================== rts/Linker.c ===================================== @@ -1385,6 +1385,8 @@ mkOc( ObjectType type, pathchar *path, char *image, int imageSize, oc->prev = NULL; oc->next_loaded_object = NULL; oc->mark = object_code_mark_bit; + /* this will get cleared by the caller if object is not safely unloadable */ + oc->unloadable = true; oc->dependencies = allocHashSet(); #if defined(NEED_M32) ===================================== rts/LinkerInternals.h ===================================== @@ -313,8 +313,14 @@ struct _ObjectCode { struct _ObjectCode *next_loaded_object; // Mark bit + // N.B. This is a full word as we CAS it. StgWord mark; + // Can this object be safely unloaded? Not true for + // dynamic objects when dlinfo is not available as + // we cannot determine liveness. + bool unloadable; + // Set of dependencies (ObjectCode*) of the object file. Traverse // dependencies using `iterHashTable`. // @@ -376,7 +382,9 @@ struct _ObjectCode { /* handle returned from dlopen */ void *dlopen_handle; - /* virtual memory ranges of loaded code */ + /* virtual memory ranges of loaded code. NULL if no range information is + * available (e.g. if dlinfo is unavailable on the current platform). + */ NativeCodeRange *nc_ranges; }; ===================================== rts/linker/Elf.c ===================================== @@ -2190,6 +2190,10 @@ void * loadNativeObj_ELF (pathchar *path, char **errmsg) copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); goto dl_iterate_phdr_fail; } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; #endif /* defined (HAVE_DLINFO) */ insertOCSectionIndices(nc); ===================================== testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c ===================================== @@ -64,7 +64,7 @@ void check_object_freed(char *obj_path) { OStatus st; st = getObjectLoadStatus(toPathchar(obj_path)); if (st != OBJECT_NOT_LOADED) { - errorBelch("object %s status != OBJECT_NOT_LOADED", obj_path); + errorBelch("object %s status != OBJECT_NOT_LOADED, is %d instead", obj_path, st); exit(1); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7eeef6b8d719fe8886cc521003a8d6fa379ee32c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7eeef6b8d719fe8886cc521003a8d6fa379ee32c You're receiving 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 Mar 9 17:42:49 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 09 Mar 2024 12:42:49 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/type-abstractions-release-notes Message-ID: <65ec9f99c42c6_1f4c8b6866450109368@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/type-abstractions-release-notes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/type-abstractions-release-notes You're receiving 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 Mar 9 18:00:18 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 13:00:18 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/build-ordering Message-ID: <65eca3b2c2a54_1f4c8b70ce7b4118110@gitlab.mail> Ben Gamari pushed new branch wip/build-ordering at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/build-ordering You're receiving 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 Mar 9 18:00:37 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 13:00:37 -0500 Subject: [Git][ghc/ghc][wip/build-ordering] base: Ensure that ghc-bignum builds before GHC.IO.Encoding.Iconv Message-ID: <65eca3c566b5b_1f4c8b7123ef81183d0@gitlab.mail> Ben Gamari pushed to branch wip/build-ordering at Glasgow Haskell Compiler / GHC Commits: 244a1c32 by Ben Gamari at 2024-03-09T13:00:32-05:00 base: Ensure that ghc-bignum builds before GHC.IO.Encoding.Iconv On Windows `GHC.IO.Encoding.Iconv` is empty and has no dependencies. Consequently, we must add dummy build ordering imports to ensure that, e.g., `GHC.Types` and `GHC.BigNum.Nat` are built before `GHC.IO.Encoding.Iconv`. - - - - - 1 changed file: - libraries/base/src/GHC/IO/Encoding/Iconv.hs Changes: ===================================== libraries/base/src/GHC/IO/Encoding/Iconv.hs ===================================== @@ -15,8 +15,8 @@ -- This module provides text encoding/decoding using iconv -- -module GHC.IO.Encoding.Iconv #if !defined(mingw32_HOST_OS) +module GHC.IO.Encoding.Iconv (iconvEncoding, mkIconvEncoding, localeEncodingName @@ -25,6 +25,8 @@ module GHC.IO.Encoding.Iconv import GHC.Internal.IO.Encoding.Iconv #else - ( ) where +module GHC.IO.Encoding.Iconv ( ) where + +import GHC.Internal.Base () -- For build ordering #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/244a1c323e469f9b3b20ccebe6ceb58f4c6946d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/244a1c323e469f9b3b20ccebe6ceb58f4c6946d9 You're receiving 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 Mar 9 19:32:31 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 14:32:31 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/tsan/fixes-3 Message-ID: <65ecb94fb397f_1f4c8b9af11cc12175@gitlab.mail> Ben Gamari pushed new branch wip/tsan/fixes-3 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/tsan/fixes-3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Mar 9 20:17:45 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 15:17:45 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 17 commits: Error messages: Improve Error messages for Data constructors in type signatures. Message-ID: <65ecc3e9b720a_1f4c8baf7b4e41311fb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - ddffaba0 by Vladislav Zavialov at 2024-03-09T15:17:41-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/type_abstractions.rst - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - + libraries/ghc-internal/src/GHC/Internal/InfoProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv.hsc → libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - libraries/ghc-internal/src/GHC/Internal/Stack/CloneStack.hs - rts/CloneStack.c - rts/CloneStack.h - rts/IPE.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6204c3e781fd3f279eed73d6756a83a4ad7e5d78...ddffaba03ecb57b90b33ee72f3371a10bf1e1c1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6204c3e781fd3f279eed73d6756a83a4ad7e5d78...ddffaba03ecb57b90b33ee72f3371a10bf1e1c1f You're receiving 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 Mar 9 22:38:23 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 17:38:23 -0500 Subject: [Git][ghc/ghc][master] 9 commits: rts/CloneStack: Bounds check array write Message-ID: <65ece4dfd2af9_3a044c3cc1d2c1015e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - + libraries/ghc-internal/src/GHC/Internal/InfoProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv.hsc → libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - libraries/ghc-internal/src/GHC/Internal/Stack/CloneStack.hs - rts/CloneStack.c - rts/CloneStack.h - rts/IPE.c - rts/IPE.h - rts/PrimOps.cmm - rts/Trace.c - rts/include/rts/IPE.h - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/profiling/should_run/staticcallstack001.stdout - testsuite/tests/profiling/should_run/staticcallstack002.stdout - testsuite/tests/rts/ipe/T24005/t24005.stdout - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.c - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c - testsuite/tests/rts/ipe/ipe_lib.c Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3849,10 +3849,9 @@ primop ClearCCSOp "clearCCS#" GenPrimOp section "Info Table Origin" ------------------------------------------------------------------------ primop WhereFromOp "whereFrom#" GenPrimOp - a -> State# s -> (# State# s, Addr# #) - { Returns the @InfoProvEnt @ for the info table of the given object - (value is @NULL@ if the table does not exist or there is no information - about the closure).} + a -> Addr# -> State# s -> (# State# s, Int# #) + { Fills the given buffer with the @InfoProvEnt@ for the info table of the + given object. Returns @1#@ on success and @0#@ otherwise.} with out_of_line = True ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -83,9 +83,11 @@ emitIpeBufferListNode this_mod ents = do platform = stgToCmmPlatform cfg int n = mkIntCLit platform n - (cg_ipes, strtab) = flip runState emptyStringTable $ do - module_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr this_mod) - mapM (toCgIPE platform ctx module_name) ents + ((cg_ipes, unit_id, module_name), strtab) = flip runState emptyStringTable $ do + unit_id <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr $ moduleName this_mod) + module_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr $ moduleUnit this_mod) + cg_ipes <- mapM (toCgIPE platform ctx) ents + return (cg_ipes, unit_id, module_name) tables :: [CmmStatic] tables = map (CmmStaticLit . CmmLabel . ipeInfoTablePtr) cg_ipes @@ -136,6 +138,12 @@ emitIpeBufferListNode this_mod ents = do -- 'string_table_size' field (decompressed size) , int $ BS.length uncompressed_strings + + -- 'module_name' field + , CmmInt (fromIntegral module_name) W32 + + -- 'unit_id' field + , CmmInt (fromIntegral unit_id) W32 ] -- Emit the list of info table pointers @@ -173,10 +181,8 @@ toIpeBufferEntries byte_order cg_ipes = , ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe - , ipeModuleName cg_ipe , ipeSrcFile cg_ipe , ipeSrcSpan cg_ipe - , 0 -- padding ] word32Builder :: Word32 -> BSB.Builder @@ -184,8 +190,8 @@ toIpeBufferEntries byte_order cg_ipes = BigEndian -> BSB.word32BE LittleEndian -> BSB.word32LE -toCgIPE :: Platform -> SDocContext -> StrTabOffset -> InfoProvEnt -> State StringTable CgInfoProvEnt -toCgIPE platform ctx module_name ipe = do +toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt +toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe @@ -205,7 +211,6 @@ toCgIPE platform ctx module_name ipe = do , ipeClosureDesc = closure_desc , ipeTypeDesc = type_desc , ipeLabel = label - , ipeModuleName = module_name , ipeSrcFile = src_file , ipeSrcSpan = src_span } @@ -216,7 +221,6 @@ data CgInfoProvEnt = CgInfoProvEnt , ipeClosureDesc :: !StrTabOffset , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset - , ipeModuleName :: !StrTabOffset , ipeSrcFile :: !StrTabOffset , ipeSrcSpan :: !StrTabOffset } ===================================== libraries/base/changelog.md ===================================== @@ -47,6 +47,8 @@ matches a `data` or `data instance` declaration) with all of its constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) + * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ([CLC proposal #104](https://github.com/haskell/core-libraries-committee/issues/104)) * Add `sortOn` to `Data.List.NonEmpty` ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -139,7 +139,12 @@ module GHC.Base ) where import GHC.Internal.Base -import GHC.Prim hiding (dataToTagLarge#, dataToTagSmall#) +import GHC.Prim hiding (dataToTagLarge#, dataToTagSmall#, whereFrom#) + -- Hide dataToTagLarge# because it is expected to break for + -- GHC-internal reasons in the near future, and shouldn't + -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. + import GHC.Prim.Ext import GHC.Prim.PtrEq import GHC.Internal.Err ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -111,10 +111,11 @@ module GHC.Exts import GHC.Internal.Exts import GHC.Internal.ArrayArray -import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge#, whereFrom# ) -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Prim.Ext ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -197,6 +197,7 @@ Library GHC.Internal.GHCi.Helpers GHC.Internal.Generics GHC.Internal.InfoProv + GHC.Internal.InfoProv.Types GHC.Internal.IO GHC.Internal.IO.Buffer GHC.Internal.IO.BufferedIO ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -315,7 +315,7 @@ import GHC.Classes hiding ( import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#) +import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#, whereFrom#) -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -133,10 +133,11 @@ module GHC.Internal.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) - -- Hide dataToTag# ops because they are expected to break for +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge#, whereFrom# ) + -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Types hiding ( IO -- Exported from "GHC.IO" ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv.hs ===================================== @@ -0,0 +1,53 @@ +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE TypeApplications #-} + +----------------------------------------------------------------------------- +-- | +-- Module : GHC.Internal.InfoProv +-- Copyright : (c) The University of Glasgow 2011 +-- License : see libraries/base/LICENSE +-- +-- Maintainer : ghc-devs at haskell.org +-- Stability : internal +-- Portability : non-portable (GHC Extensions) +-- +-- Access to GHC's info-table provenance metadata. +-- +-- /The API of this module is unstable and not meant to be consumed by the general public./ +-- If you absolutely must depend on it, make sure to use a tight upper +-- bound, e.g., @base < 4.X@ rather than @base < 5@, because the interface can +-- change rapidly without much warning. +-- +-- @since base-4.18.0.0 +----------------------------------------------------------------------------- + +module GHC.Internal.InfoProv + ( InfoProv(..) + , ipLoc + , whereFrom + -- * Internals + , InfoProvEnt + , ipeProv + , peekInfoProv + ) where + +import GHC.Internal.Base +import GHC.Internal.InfoProv.Types + +-- | Get information about where a value originated from. +-- This information is stored statically in a binary when @-finfo-table-map@ is +-- enabled. The source positions will be greatly improved by also enabled debug +-- information with @-g3 at . Finally you can enable @-fdistinct-constructor-tables@ to +-- get more precise information about data constructor allocations. +-- +-- The information is collect by looking at the info table address of a specific closure and +-- then consulting a specially generated map (by @-finfo-table-map@) to find out where we think +-- the best source position to describe that info table arose from. +-- +-- @since base-4.16.0.0 +whereFrom :: a -> IO (Maybe InfoProv) +whereFrom obj = getIPE obj Nothing $ \p -> + Just `fmap` peekInfoProv (ipeProv p) ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv.hsc → libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -1,79 +1,80 @@ +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE TypeApplications #-} ------------------------------------------------------------------------------ --- | --- Module : GHC.Internal.InfoProv --- Copyright : (c) The University of Glasgow 2011 --- License : see libraries/base/LICENSE --- --- Maintainer : ghc-devs at haskell.org --- Stability : internal --- Portability : non-portable (GHC Extensions) --- --- Access to GHC's info-table provenance metadata. --- --- /The API of this module is unstable and not meant to be consumed by the general public./ --- If you absolutely must depend on it, make sure to use a tight upper --- bound, e.g., @base < 4.X@ rather than @base < 5@, because the interface can --- change rapidly without much warning. --- --- @since base-4.18.0.0 ------------------------------------------------------------------------------ +#include "Rts.h" -module GHC.Internal.InfoProv +module GHC.Internal.InfoProv.Types ( InfoProv(..) , ipLoc , ipeProv - , whereFrom - -- * Internals , InfoProvEnt , peekInfoProv + , getIPE + , StgInfoTable + , lookupIPE ) where -#include "Rts.h" - import GHC.Internal.Base +import GHC.Internal.Data.Maybe import GHC.Internal.Enum -import GHC.Internal.Show -import GHC.Internal.Ptr (Ptr(..), plusPtr, nullPtr) +import GHC.Internal.Show (Show) +import GHC.Internal.Ptr (Ptr(..), plusPtr) +import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString) +import GHC.Internal.Foreign.C.Types (CBool(..)) +import GHC.Internal.Foreign.Marshal.Alloc (allocaBytes) import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) -import GHC.Internal.Foreign.C.String.Encoding -import GHC.Internal.Text.Read (readMaybe) -import GHC.Internal.Data.Maybe (maybe) -import GHC.Internal.ClosureTypes ( ClosureType(..) ) +import GHC.Internal.ClosureTypes +import GHC.Internal.Text.Read +import GHC.Prim (whereFrom##) data InfoProv = InfoProv { ipName :: String, ipDesc :: ClosureType, ipTyDesc :: String, ipLabel :: String, + -- | @since base-4.20.0.0 + ipUnitId :: String, ipMod :: String, ipSrcFile :: String, ipSrcSpan :: String } deriving (Eq, Show) -data InfoProvEnt - ipLoc :: InfoProv -> String ipLoc ipe = ipSrcFile ipe ++ ":" ++ ipSrcSpan ipe -getIPE :: a -> IO (Ptr InfoProvEnt) -getIPE obj = IO $ \s -> - case whereFrom## obj s of - (## s', addr ##) -> (## s', Ptr addr ##) +data InfoProvEnt + +data StgInfoTable + +foreign import ccall "lookupIPE" c_lookupIPE :: Ptr StgInfoTable -> Ptr InfoProvEnt -> IO CBool + +lookupIPE :: Ptr StgInfoTable -> IO (Maybe InfoProv) +lookupIPE itbl = allocaBytes (#size InfoProvEnt) $ \p -> do + res <- c_lookupIPE itbl p + case res of + 1 -> Just `fmap` peekInfoProv (ipeProv p) + _ -> return Nothing + +getIPE :: a -> r -> (Ptr InfoProvEnt -> IO r) -> IO r +getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> + case whereFrom## obj (unPtr p) s of + (## s', 1## ##) -> unIO (k p) s' + (## s', _ ##) -> (## s', fail ##) + where + unPtr (Ptr p) = p ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString peekIpName p = (# peek InfoProv, table_name) p peekIpDesc p = (# peek InfoProv, closure_desc) p peekIpLabel p = (# peek InfoProv, label) p +peekIpUnitId p = (# peek InfoProv, unit_id) p peekIpModule p = (# peek InfoProv, module) p peekIpSrcFile p = (# peek InfoProv, src_file) p peekIpSrcSpan p = (# peek InfoProv, src_span) p @@ -85,6 +86,7 @@ peekInfoProv infop = do desc <- peekCString utf8 =<< peekIpDesc infop tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop + unit_id <- peekCString utf8 =<< peekIpUnitId infop mod <- peekCString utf8 =<< peekIpModule infop file <- peekCString utf8 =<< peekIpSrcFile infop span <- peekCString utf8 =<< peekIpSrcSpan infop @@ -95,31 +97,9 @@ peekInfoProv infop = do ipDesc = maybe INVALID_OBJECT toEnum . readMaybe @Int $ desc, ipTyDesc = tyDesc, ipLabel = label, + ipUnitId = unit_id, ipMod = mod, ipSrcFile = file, ipSrcSpan = span } --- | Get information about where a value originated from. --- This information is stored statically in a binary when @-finfo-table-map@ is --- enabled. The source positions will be greatly improved by also enabled debug --- information with @-g3 at . Finally you can enable @-fdistinct-constructor-tables@ to --- get more precise information about data constructor allocations. --- --- The information is collect by looking at the info table address of a specific closure and --- then consulting a specially generated map (by @-finfo-table-map@) to find out where we think --- the best source position to describe that info table arose from. --- --- @since base-4.16.0.0 -whereFrom :: a -> IO (Maybe InfoProv) -whereFrom obj = do - ipe <- getIPE obj - -- The primop returns the null pointer in two situations at the moment - -- 1. The lookup fails for whatever reason - -- 2. -finfo-table-map is not enabled. - -- It would be good to distinguish between these two cases somehow. - if ipe == nullPtr - then return Nothing - else do - infoProv <- peekInfoProv (ipeProv ipe) - return $ Just infoProv ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CloneStack.hs ===================================== @@ -25,21 +25,23 @@ module GHC.Internal.Stack.CloneStack ( import GHC.Internal.MVar import GHC.Internal.Data.Maybe (catMaybes) import GHC.Internal.Base +import GHC.Internal.Foreign.Storable import GHC.Internal.Conc.Sync -import GHC.Internal.Exts () -- (Int (I#), RealWorld, StackSnapshot#, ThreadId#, Array#, sizeofArray#, indexArray#, State#, StablePtr#) -import GHC.Internal.InfoProv (InfoProv (..), InfoProvEnt, ipLoc, ipeProv, peekInfoProv) +import GHC.Internal.IO (unsafeInterleaveIO) +import GHC.Internal.InfoProv.Types (InfoProv (..), ipLoc, lookupIPE, StgInfoTable) import GHC.Internal.Num +import GHC.Internal.Real (div) import GHC.Internal.Stable import GHC.Internal.Text.Show import GHC.Internal.Ptr -import GHC.Internal.ClosureTypes ( ClosureType(..) ) +import GHC.Internal.ClosureTypes -- | A frozen snapshot of the state of an execution stack. -- -- @since base-4.17.0.0 data StackSnapshot = StackSnapshot !StackSnapshot# -foreign import prim "stg_decodeStackzh" decodeStack# :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, Array# (Ptr InfoProvEnt) #) +foreign import prim "stg_decodeStackzh" decodeStack# :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, ByteArray# #) foreign import prim "stg_cloneMyStackzh" cloneMyStack# :: State# RealWorld -> (# State# RealWorld, StackSnapshot# #) @@ -231,39 +233,35 @@ data StackEntry = StackEntry -- -- @since base-4.17.0.0 decode :: StackSnapshot -> IO [StackEntry] -decode stackSnapshot = do - stackEntries <- getDecodedStackArray stackSnapshot - ipes <- mapM unmarshal stackEntries - return $ catMaybes ipes - - where - unmarshal :: Ptr InfoProvEnt -> IO (Maybe StackEntry) - unmarshal ipe = if ipe == nullPtr then - pure Nothing - else do - infoProv <- (peekInfoProv . ipeProv) ipe - pure $ Just (toStackEntry infoProv) - toStackEntry :: InfoProv -> StackEntry - toStackEntry infoProv = - StackEntry - { functionName = ipLabel infoProv, - moduleName = ipMod infoProv, - srcLoc = ipLoc infoProv, - closureType = ipDesc $ infoProv - } - -getDecodedStackArray :: StackSnapshot -> IO [Ptr InfoProvEnt] +decode stackSnapshot = catMaybes `fmap` getDecodedStackArray stackSnapshot + +toStackEntry :: InfoProv -> StackEntry +toStackEntry infoProv = + StackEntry + { functionName = ipLabel infoProv, + moduleName = ipMod infoProv, + srcLoc = ipLoc infoProv, + closureType = ipDesc infoProv + } + +getDecodedStackArray :: StackSnapshot -> IO [Maybe StackEntry] getDecodedStackArray (StackSnapshot s) = IO $ \s0 -> case decodeStack# s s0 of - (# s1, a #) -> (# s1, (go a ((I# (sizeofArray# a)) - 1)) #) + (# s1, arr #) -> + let n = I# (sizeofByteArray# arr) `div` wordSize - 1 + in unIO (go arr n) s1 where - go :: Array# (Ptr InfoProvEnt) -> Int -> [Ptr InfoProvEnt] - go stack 0 = [stackEntryAt stack 0] - go stack i = (stackEntryAt stack i) : go stack (i - 1) + go :: ByteArray# -> Int -> IO [Maybe StackEntry] + go _stack (-1) = return [] + go stack i = do + infoProv <- lookupIPE (stackEntryAt stack i) + rest <- unsafeInterleaveIO $ go stack (i-1) + return ((toStackEntry `fmap` infoProv) : rest) + + stackEntryAt :: ByteArray# -> Int -> Ptr StgInfoTable + stackEntryAt stack (I# i) = Ptr (indexAddrArray# stack i) - stackEntryAt :: Array# (Ptr InfoProvEnt) -> Int -> Ptr InfoProvEnt - stackEntryAt stack (I# i) = case indexArray# stack i of - (# se #) -> se + wordSize = sizeOf (nullPtr :: Ptr ()) prettyStackEntry :: StackEntry -> String prettyStackEntry (StackEntry {moduleName=mod_nm, functionName=fun_nm, srcLoc=loc}) = ===================================== rts/CloneStack.c ===================================== @@ -25,6 +25,12 @@ #include + +static StgWord getStackFrameCount(StgStack* stack); +static StgWord getStackChunkClosureCount(StgStack* stack); +static StgArrBytes* allocateByteArray(Capability *cap, StgWord bytes); +static void copyPtrsToArray(StgArrBytes* arr, StgStack* stack); + static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack) { StgWord spOffset = stack->sp - stack->stack; @@ -109,12 +115,12 @@ void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) // array is the count of stack frames. // Each InfoProvEnt* is looked up by lookupIPE(). If there's no IPE for a stack // frame it's represented by null. -StgMutArrPtrs* decodeClonedStack(Capability *cap, StgStack* stack) { +StgArrBytes* decodeClonedStack(Capability *cap, StgStack* stack) { StgWord closureCount = getStackFrameCount(stack); - StgMutArrPtrs* array = allocateMutableArray(closureCount); + StgArrBytes* array = allocateByteArray(cap, sizeof(StgInfoTable*) * closureCount); - copyPtrsToArray(cap, array, stack); + copyPtrsToArray(array, stack); return array; } @@ -150,52 +156,34 @@ StgWord getStackChunkClosureCount(StgStack* stack) { return closureCount; } -// Allocate and initialize memory for a MutableArray# (Haskell representation). -StgMutArrPtrs* allocateMutableArray(StgWord closureCount) { +// Allocate and initialize memory for a ByteArray# (Haskell representation). +StgArrBytes* allocateByteArray(Capability *cap, StgWord bytes) { // Idea stolen from PrimOps.cmm:stg_newArrayzh() - StgWord size = closureCount + mutArrPtrsCardTableSize(closureCount); - StgWord words = sizeofW(StgMutArrPtrs) + size; - - StgMutArrPtrs* array = (StgMutArrPtrs*) allocate(myTask()->cap, words); + StgWord words = sizeofW(StgArrBytes) + bytes; - SET_HDR(array, &stg_MUT_ARR_PTRS_DIRTY_info, CCS_SYSTEM); - array->ptrs = closureCount; - array->size = size; + StgArrBytes* array = (StgArrBytes*) allocate(cap, words); + SET_HDR(array, &stg_ARR_WORDS_info, CCS_SYSTEM); + array->bytes = bytes; return array; } - -void copyPtrsToArray(Capability *cap, StgMutArrPtrs* arr, StgStack* stack) { +static void copyPtrsToArray(StgArrBytes* arr, StgStack* stack) { StgWord index = 0; StgStack *last_stack = stack; + const StgInfoTable **result = (const StgInfoTable **) arr->payload; while (true) { StgPtr sp = last_stack->sp; StgPtr spBottom = last_stack->stack + last_stack->stack_size; for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { - const StgInfoTable* infoTable = get_itbl((StgClosure *)sp); - - // Add the IPE that was looked up by lookupIPE() to the MutableArray#. - // The "Info Table Provernance Entry Map" (IPE) idea is to use a pointer - // (address) to the info table to lookup entries, this is fulfilled in - // non-"Tables Next to Code" builds. - // When "Tables Next to Code" is used, the assembly label of the info table - // is between the info table and it's code. There's no other label in the - // assembly code which could be used instead, thus lookupIPE() is actually - // called with the code pointer of the info table. - // (As long as it's used consistently, this doesn't really matter - IPE uses - // the pointer only to connect an info table to it's provenance entry in the - // IPE map.) -#if defined(TABLES_NEXT_TO_CODE) - InfoProvEnt* ipe = lookupIPE((StgInfoTable*) infoTable->code); -#else - InfoProvEnt* ipe = lookupIPE(infoTable); -#endif - arr->payload[index] = createPtrClosure(cap, ipe); - + const StgInfoTable* infoTable = ((StgClosure *)sp)->header.info; + result[index] = infoTable; index++; } + // Ensure that we didn't overflow the result array + ASSERT(index-1 < arr->bytes / sizeof(StgInfoTable*)); + // check whether the stack ends in an underflow frame StgUnderflowFrame *frame = (StgUnderflowFrame *) (last_stack->stack + last_stack->stack_size - sizeofW(StgUnderflowFrame)); @@ -206,12 +194,3 @@ void copyPtrsToArray(Capability *cap, StgMutArrPtrs* arr, StgStack* stack) { } } } - -// Create a GHC.Ptr (Haskell constructor: `Ptr InfoProvEnt`) pointing to the -// IPE. -StgClosure* createPtrClosure(Capability *cap, InfoProvEnt* ipe) { - StgClosure *p = (StgClosure *) allocate(cap, CONSTR_sizeW(0,1)); - SET_HDR(p, &ghczminternal_GHCziInternalziPtr_Ptr_con_info, CCS_SYSTEM); - p->payload[0] = (StgClosure*) ipe; - return TAG_CLOSURE(1, p); -} ===================================== rts/CloneStack.h ===================================== @@ -15,7 +15,7 @@ StgStack* cloneStack(Capability* capability, const StgStack* stack); void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); -StgMutArrPtrs* decodeClonedStack(Capability *cap, StgStack* stack); +StgArrBytes* decodeClonedStack(Capability *cap, StgStack* stack); #include "BeginPrivate.h" @@ -23,10 +23,4 @@ StgMutArrPtrs* decodeClonedStack(Capability *cap, StgStack* stack); void handleCloneStackMessage(MessageCloneStack *msg); #endif -StgWord getStackFrameCount(StgStack* stack); -StgWord getStackChunkClosureCount(StgStack* stack); -void copyPtrsToArray(Capability *cap, StgMutArrPtrs* arr, StgStack* stack); -StgClosure* createPtrClosure(Capability* cap, InfoProvEnt* ipe); -StgMutArrPtrs* allocateMutableArray(StgWord size); - #include "EndPrivate.h" ===================================== rts/IPE.c ===================================== @@ -52,16 +52,23 @@ of InfoProvEnt are represented in IpeBufferEntry as 32-bit offsets into the string table. This allows us to halve the size of the buffer entries on 64-bit machines while significantly reducing the number of needed relocations, reducing linking cost. Moreover, the code generator takes care -to deduplicate strings when generating the string table. When we insert a -set of IpeBufferEntrys into the IPE hash-map we convert them to InfoProvEnts, -which contain proper string pointers. +to deduplicate strings when generating the string table. Building the hash map is done lazily, i.e. on first lookup or traversal. For this all IPE lists of all IpeBufferListNode are traversed to insert all IPEs. +This involves allocating a IpeMapEntry for each IPE entry, pointing to the +entry's containing IpeBufferListNode and its index in that node. + +When the user looks up an IPE entry, we convert it to the user-facing +InfoProvEnt representation. -After the content of a IpeBufferListNode has been inserted, it's freed. */ +typedef struct { + IpeBufferListNode *node; + uint32_t idx; +} IpeMapEntry; + #if defined(THREADED_RTS) static Mutex ipeMapLock; #endif @@ -71,6 +78,9 @@ static HashTable *ipeMap = NULL; // Accessed atomically static IpeBufferListNode *ipeBufferList = NULL; +static void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode*); +static void updateIpeMap(void); + #if defined(THREADED_RTS) void initIpe(void) { initMutex(&ipeMapLock); } @@ -85,18 +95,23 @@ void exitIpe(void) { } #endif // THREADED_RTS -static InfoProvEnt ipeBufferEntryToIpe(const char *strings, const StgInfoTable *tbl, const IpeBufferEntry ent) +static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t idx) { + CHECK(idx < node->count); + CHECK(!node->compressed); + const char *strings = node->string_table; + const IpeBufferEntry *ent = &node->entries[idx]; return (InfoProvEnt) { - .info = tbl, + .info = node->tables[idx], .prov = { - .table_name = &strings[ent.table_name], - .closure_desc = &strings[ent.closure_desc], - .ty_desc = &strings[ent.ty_desc], - .label = &strings[ent.label], - .module = &strings[ent.module_name], - .src_file = &strings[ent.src_file], - .src_span = &strings[ent.src_span] + .table_name = &strings[ent->table_name], + .closure_desc = &strings[ent->closure_desc], + .ty_desc = &strings[ent->ty_desc], + .label = &strings[ent->label], + .unit_id = &strings[node->unit_id], + .module = &strings[node->module_name], + .src_file = &strings[ent->src_file], + .src_span = &strings[ent->src_span] } }; } @@ -105,29 +120,22 @@ static InfoProvEnt ipeBufferEntryToIpe(const char *strings, const StgInfoTable * #if defined(TRACING) static void traceIPEFromHashTable(void *data STG_UNUSED, StgWord key STG_UNUSED, const void *value) { - InfoProvEnt *ipe = (InfoProvEnt *)value; - traceIPE(ipe); + const IpeMapEntry *map_ent = (const IpeMapEntry *)value; + const InfoProvEnt ipe = ipeBufferEntryToIpe(map_ent->node, map_ent->idx); + traceIPE(&ipe); } void dumpIPEToEventLog(void) { // Dump pending entries - IpeBufferListNode *cursor = RELAXED_LOAD(&ipeBufferList); - while (cursor != NULL) { - IpeBufferEntry *entries; - const char *strings; + IpeBufferListNode *node = RELAXED_LOAD(&ipeBufferList); + while (node != NULL) { + decompressIPEBufferListNodeIfCompressed(node); - // Decompress if compressed - decompressIPEBufferListNodeIfCompressed(cursor, &entries, &strings); - - for (uint32_t i = 0; i < cursor->count; i++) { - const InfoProvEnt ent = ipeBufferEntryToIpe( - strings, - cursor->tables[i], - entries[i] - ); + for (uint32_t i = 0; i < node->count; i++) { + const InfoProvEnt ent = ipeBufferEntryToIpe(node, i); traceIPE(&ent); } - cursor = cursor->next; + node = node->next; } // Dump entries already in hashmap @@ -168,9 +176,15 @@ void registerInfoProvList(IpeBufferListNode *node) { } } -InfoProvEnt *lookupIPE(const StgInfoTable *info) { +bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out) { updateIpeMap(); - return lookupHashTable(ipeMap, (StgWord)info); + IpeMapEntry *map_ent = (IpeMapEntry *) lookupHashTable(ipeMap, (StgWord)info); + if (map_ent) { + *out = ipeBufferEntryToIpe(map_ent->node, map_ent->idx); + return true; + } else { + return false; + } } void updateIpeMap(void) { @@ -188,47 +202,40 @@ void updateIpeMap(void) { } while (pending != NULL) { - IpeBufferListNode *current_node = pending; - IpeBufferEntry *entries; - const char *strings; + IpeBufferListNode *node = pending; // Decompress if compressed - decompressIPEBufferListNodeIfCompressed(current_node, &entries, &strings); - - // Convert the on-disk IPE buffer entry representation (IpeBufferEntry) - // into the runtime representation (InfoProvEnt) - InfoProvEnt *ip_ents = stgMallocBytes( - sizeof(InfoProvEnt) * current_node->count, - "updateIpeMap: ip_ents" - ); - for (uint32_t i = 0; i < current_node->count; i++) { - const IpeBufferEntry ent = entries[i]; - const StgInfoTable *tbl = current_node->tables[i]; - ip_ents[i] = ipeBufferEntryToIpe(strings, tbl, ent); - insertHashTable(ipeMap, (StgWord) tbl, &ip_ents[i]); + decompressIPEBufferListNodeIfCompressed(node); + + // Insert entries into ipeMap + IpeMapEntry *map_ents = stgMallocBytes(node->count * sizeof(IpeMapEntry), "updateIpeMap: ip_ents"); + for (uint32_t i = 0; i < node->count; i++) { + const StgInfoTable *tbl = node->tables[i]; + map_ents[i].node = node; + map_ents[i].idx = i; + insertHashTable(ipeMap, (StgWord) tbl, &map_ents[i]); } - pending = current_node->next; + pending = node->next; } RELEASE_LOCK(&ipeMapLock); } /* Decompress the IPE data and strings table referenced by an IPE buffer list -node if it is compressed. No matter whether the data is compressed, the pointers -referenced by the 'entries_dst' and 'string_table_dst' parameters will point at -the decompressed IPE data and string table for the given node, respectively, -upon return from this function. -*/ -void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node, IpeBufferEntry **entries_dst, const char **string_table_dst) { + * node if it is compressed. After returning node->compressed with be 0 and the + * string_table and entries fields will have their uncompressed values. + */ +void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node) { if (node->compressed == 1) { + node->compressed = 0; + // The IPE list buffer node indicates that the strings table and // entries list has been compressed. If zstd is not available, fail. // If zstd is available, decompress. #if HAVE_LIBZSTD == 0 barf("An IPE buffer list node has been compressed, but the " - "decompression library (zstd) is not available." -); + "decompression library (zstd) is not available."); #else size_t compressed_sz = ZSTD_findFrameCompressedSize( node->string_table, @@ -244,7 +251,7 @@ void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node, IpeBufferE node->string_table, compressed_sz ); - *string_table_dst = decompressed_strings; + node->string_table = (const char *) decompressed_strings; // Decompress the IPE data compressed_sz = ZSTD_findFrameCompressedSize( @@ -261,12 +268,8 @@ void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node, IpeBufferE node->entries, compressed_sz ); - *entries_dst = decompressed_entries; + node->entries = decompressed_entries; #endif // HAVE_LIBZSTD == 0 - } else { - // Not compressed, no need to decompress - *entries_dst = node->entries; - *string_table_dst = node->string_table; } } ===================================== rts/IPE.h ===================================== @@ -14,9 +14,7 @@ #include "BeginPrivate.h" void dumpIPEToEventLog(void); -void updateIpeMap(void); void initIpe(void); void exitIpe(void); -void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode*, IpeBufferEntry**, const char**); #include "EndPrivate.h" ===================================== rts/PrimOps.cmm ===================================== @@ -2533,13 +2533,13 @@ stg_closureSizzezh (P_ clos) return (len); } -stg_whereFromzh (P_ clos) +stg_whereFromzh (P_ clos, W_ buf) { - P_ ipe; + CBool success; W_ info; info = GET_INFO(UNTAG(clos)); - (ipe) = foreign "C" lookupIPE(info "ptr"); - return (ipe); + (success) = foreign "C" lookupIPE(info, buf); + return (TO_W_(success)); } /* ----------------------------------------------------------------------------- ===================================== rts/Trace.c ===================================== @@ -689,9 +689,10 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, - ipe->prov.label, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); + ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, + ipe->prov.src_file, ipe->prov.src_span); RELEASE_LOCK(&trace_utx); } else ===================================== rts/include/rts/IPE.h ===================================== @@ -18,6 +18,7 @@ typedef struct InfoProv_ { const char *closure_desc; const char *ty_desc; const char *label; + const char *unit_id; const char *module; const char *src_file; const char *src_span; @@ -56,10 +57,8 @@ typedef struct { StringIdx closure_desc; StringIdx ty_desc; StringIdx label; - StringIdx module_name; StringIdx src_file; StringIdx src_span; - uint32_t _padding; } IpeBufferEntry; GHC_STATIC_ASSERT(sizeof(IpeBufferEntry) % (WORD_SIZE_IN_BITS / 8) == 0, "sizeof(IpeBufferEntry) must be a multiple of the word size"); @@ -77,13 +76,18 @@ typedef struct IpeBufferListNode_ { // When TNTC is enabled, these will point to the entry code // not the info table itself. const StgInfoTable **tables; - IpeBufferEntry *entries; StgWord entries_size; // decompressed size const char *string_table; StgWord string_table_size; // decompressed size + + // Shared by all entries + StringIdx unit_id; + StringIdx module_name; } IpeBufferListNode; void registerInfoProvList(IpeBufferListNode *node); -InfoProvEnt *lookupIPE(const StgInfoTable *info); + +// Returns true on success, initializes `out`. +bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out); ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4755,7 +4755,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6857,7 +6856,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -8105,7 +8103,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Safe type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipUnitId :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Internal.Base.String @@ -12521,7 +12519,7 @@ instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.RTSFlags -- Defined in instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.TickyFlags -- Defined in ‘GHC.Internal.RTS.Flags’ instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.TraceFlags -- Defined in ‘GHC.Internal.RTS.Flags’ instance GHC.Internal.Show.Show GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Internal.Show.Show GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Internal.Show.Show GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Internal.Show.Show GHC.Internal.Stack.CloneStack.StackEntry -- Defined in ‘GHC.Internal.Stack.CloneStack’ instance GHC.Internal.Show.Show GHC.Internal.StaticPtr.StaticPtrInfo -- Defined in ‘GHC.Internal.StaticPtr’ instance GHC.Internal.Show.Show GHC.Internal.Stats.GCDetails -- Defined in ‘GHC.Internal.Stats’ @@ -12717,7 +12715,7 @@ instance GHC.Classes.Eq GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Inter instance GHC.Classes.Eq GHC.Internal.RTS.Flags.IoSubSystem -- Defined in ‘GHC.Internal.RTS.Flags’ instance forall i e. GHC.Classes.Eq (GHC.Internal.IOArray.IOArray i e) -- Defined in ‘GHC.Internal.IOArray’ instance forall a. GHC.Classes.Eq (GHC.Internal.IOPort.IOPort a) -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Classes.Eq GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Classes.Eq GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Classes.Eq GHC.Num.Integer.Integer -- Defined in ‘GHC.Num.Integer’ instance GHC.Classes.Eq GHC.Num.BigNat.BigNat -- Defined in ‘GHC.Num.BigNat’ instance GHC.Classes.Eq GHC.Num.Natural.Natural -- Defined in ‘GHC.Num.Natural’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4755,7 +4755,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6826,7 +6825,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -8074,7 +8072,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Safe type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipUnitId :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Internal.Base.String @@ -15551,7 +15549,7 @@ instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.RTSFlags -- Defined in instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.TickyFlags -- Defined in ‘GHC.Internal.RTS.Flags’ instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.TraceFlags -- Defined in ‘GHC.Internal.RTS.Flags’ instance GHC.Internal.Show.Show GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Internal.Show.Show GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Internal.Show.Show GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Internal.Show.Show GHC.Internal.JS.Prim.JSException -- Defined in ‘GHC.Internal.JS.Prim’ instance GHC.Internal.Show.Show GHC.Internal.JS.Prim.WouldBlockException -- Defined in ‘GHC.Internal.JS.Prim’ instance GHC.Internal.Show.Show GHC.Internal.Stack.CloneStack.StackEntry -- Defined in ‘GHC.Internal.Stack.CloneStack’ @@ -15743,7 +15741,7 @@ instance GHC.Classes.Eq GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Inter instance GHC.Classes.Eq GHC.Internal.RTS.Flags.IoSubSystem -- Defined in ‘GHC.Internal.RTS.Flags’ instance forall i e. GHC.Classes.Eq (GHC.Internal.IOArray.IOArray i e) -- Defined in ‘GHC.Internal.IOArray’ instance forall a. GHC.Classes.Eq (GHC.Internal.IOPort.IOPort a) -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Classes.Eq GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Classes.Eq GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Classes.Eq GHC.Num.Integer.Integer -- Defined in ‘GHC.Num.Integer’ instance GHC.Classes.Eq GHC.Internal.JS.Foreign.Callback.OnBlocked -- Defined in ‘GHC.Internal.JS.Foreign.Callback’ instance GHC.Classes.Eq GHC.Num.BigNat.BigNat -- Defined in ‘GHC.Num.BigNat’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4758,7 +4758,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -7006,7 +7005,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -8329,7 +8327,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Safe type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipUnitId :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Internal.Base.String @@ -12799,7 +12797,7 @@ instance GHC.Internal.Show.Show GHC.Internal.IO.Windows.Handle.CONSOLE_READCONSO instance GHC.Internal.Show.Show (GHC.Internal.IO.Windows.Handle.Io GHC.Internal.IO.Windows.Handle.NativeHandle) -- Defined in ‘GHC.Internal.IO.Windows.Handle’ instance GHC.Internal.Show.Show (GHC.Internal.IO.Windows.Handle.Io GHC.Internal.IO.Windows.Handle.ConsoleHandle) -- Defined in ‘GHC.Internal.IO.Windows.Handle’ instance GHC.Internal.Show.Show GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Internal.Show.Show GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Internal.Show.Show GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Internal.Show.Show GHC.Internal.Stack.CloneStack.StackEntry -- Defined in ‘GHC.Internal.Stack.CloneStack’ instance GHC.Internal.Show.Show GHC.Internal.StaticPtr.StaticPtrInfo -- Defined in ‘GHC.Internal.StaticPtr’ instance GHC.Internal.Show.Show GHC.Internal.Stats.GCDetails -- Defined in ‘GHC.Internal.Stats’ @@ -12993,7 +12991,7 @@ instance GHC.Classes.Eq GHC.Internal.RTS.Flags.IoSubSystem -- Defined in ‘GHC. instance GHC.Classes.Eq GHC.Internal.IO.Windows.Handle.TempFileOptions -- Defined in ‘GHC.Internal.IO.Windows.Handle’ instance forall i e. GHC.Classes.Eq (GHC.Internal.IOArray.IOArray i e) -- Defined in ‘GHC.Internal.IOArray’ instance forall a. GHC.Classes.Eq (GHC.Internal.IOPort.IOPort a) -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Classes.Eq GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Classes.Eq GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Classes.Eq GHC.Num.Integer.Integer -- Defined in ‘GHC.Num.Integer’ instance GHC.Classes.Eq GHC.Num.BigNat.BigNat -- Defined in ‘GHC.Num.BigNat’ instance GHC.Classes.Eq GHC.Num.Natural.Natural -- Defined in ‘GHC.Num.Natural’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4755,7 +4755,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6857,7 +6856,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -8105,7 +8103,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Safe type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Internal.Base.String, ipDesc :: GHC.Internal.ClosureTypes.ClosureType, ipTyDesc :: GHC.Internal.Base.String, ipLabel :: GHC.Internal.Base.String, ipUnitId :: GHC.Internal.Base.String, ipMod :: GHC.Internal.Base.String, ipSrcFile :: GHC.Internal.Base.String, ipSrcSpan :: GHC.Internal.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Internal.Base.String @@ -12521,7 +12519,7 @@ instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.RTSFlags -- Defined in instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.TickyFlags -- Defined in ‘GHC.Internal.RTS.Flags’ instance GHC.Internal.Show.Show GHC.Internal.RTS.Flags.TraceFlags -- Defined in ‘GHC.Internal.RTS.Flags’ instance GHC.Internal.Show.Show GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Internal.Show.Show GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Internal.Show.Show GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Internal.Show.Show GHC.Internal.Stack.CloneStack.StackEntry -- Defined in ‘GHC.Internal.Stack.CloneStack’ instance GHC.Internal.Show.Show GHC.Internal.StaticPtr.StaticPtrInfo -- Defined in ‘GHC.Internal.StaticPtr’ instance GHC.Internal.Show.Show GHC.Internal.Stats.GCDetails -- Defined in ‘GHC.Internal.Stats’ @@ -12717,7 +12715,7 @@ instance GHC.Classes.Eq GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Inter instance GHC.Classes.Eq GHC.Internal.RTS.Flags.IoSubSystem -- Defined in ‘GHC.Internal.RTS.Flags’ instance forall i e. GHC.Classes.Eq (GHC.Internal.IOArray.IOArray i e) -- Defined in ‘GHC.Internal.IOArray’ instance forall a. GHC.Classes.Eq (GHC.Internal.IOPort.IOPort a) -- Defined in ‘GHC.Internal.IOPort’ -instance GHC.Classes.Eq GHC.Internal.InfoProv.InfoProv -- Defined in ‘GHC.Internal.InfoProv’ +instance GHC.Classes.Eq GHC.Internal.InfoProv.Types.InfoProv -- Defined in ‘GHC.Internal.InfoProv.Types’ instance GHC.Classes.Eq GHC.Num.Integer.Integer -- Defined in ‘GHC.Num.Integer’ instance GHC.Classes.Eq GHC.Num.BigNat.BigNat -- Defined in ‘GHC.Num.BigNat’ instance GHC.Classes.Eq GHC.Num.Natural.Natural -- Defined in ‘GHC.Num.Natural’ ===================================== testsuite/tests/profiling/should_run/staticcallstack001.stdout ===================================== @@ -1,3 +1,3 @@ -Just (InfoProv {ipName = "D_Main_4_con_info", ipDesc = CONSTR_1_0, ipTyDesc = "D", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "16:13-27"}) -Just (InfoProv {ipName = "D_Main_2_con_info", ipDesc = CONSTR_1_0, ipTyDesc = "D", ipLabel = "caf", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "13:1-9"}) -Just (InfoProv {ipName = "sat_s11M_info", ipDesc = THUNK, ipTyDesc = "D", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "18:23-32"}) +Just (InfoProv {ipName = "D_Main_4_con_info", ipDesc = CONSTR_1_0, ipTyDesc = "D", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "16:13-27"}) +Just (InfoProv {ipName = "D_Main_2_con_info", ipDesc = CONSTR_1_0, ipTyDesc = "D", ipLabel = "caf", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "13:1-9"}) +Just (InfoProv {ipName = "sat_s23z_info", ipDesc = THUNK, ipTyDesc = "D", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "18:23-32"}) ===================================== testsuite/tests/profiling/should_run/staticcallstack002.stdout ===================================== @@ -1,4 +1,4 @@ -Just (InfoProv {ipName = "sat_s11p_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "10:23-39"}) -Just (InfoProv {ipName = "sat_s11F_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "11:23-42"}) -Just (InfoProv {ipName = "sat_s11V_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "12:23-46"}) -Just (InfoProv {ipName = "sat_s12b_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "13:23-44"}) +Just (InfoProv {ipName = "sat_s237_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "10:23-39"}) +Just (InfoProv {ipName = "sat_s23r_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "11:23-42"}) +Just (InfoProv {ipName = "sat_s23L_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "12:23-46"}) +Just (InfoProv {ipName = "sat_s245_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "13:23-44"}) ===================================== testsuite/tests/rts/ipe/T24005/t24005.stdout ===================================== @@ -1,2 +1,2 @@ -Just (InfoProv {ipName = "C:Show_Main_1_con_info", ipDesc = CONSTR, ipTyDesc = "Show", ipLabel = "$fShowA", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "25:10-15"}) -Just (InfoProv {ipName = "C:Show_Main_0_con_info", ipDesc = CONSTR, ipTyDesc = "Show", ipLabel = "$fShowB", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "29:10-29"}) +Just (InfoProv {ipName = "C:Show_Main_1_con_info", ipDesc = CONSTR, ipTyDesc = "Show", ipLabel = "$fShowA", ipUnitId = "main", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "25:10-15"}) +Just (InfoProv {ipName = "C:Show_Main_0_con_info", ipDesc = CONSTR, ipTyDesc = "Show", ipLabel = "$fShowB", ipUnitId = "main", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "29:10-29"}) ===================================== testsuite/tests/rts/ipe/ipeEventLog.stderr ===================================== @@ -1,20 +1,20 @@ -7f5278bc0740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f5278bc0740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f5278bc0740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f5278bc0740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f5278bc0740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f5278bc0740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f5278bc0740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f5278bc0740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f5278bc0740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f5278bc0740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 -7f5278bc0740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f5278bc0740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f5278bc0740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f5278bc0740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f5278bc0740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f5278bc0740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f5278bc0740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f5278bc0740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f5278bc0740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f5278bc0740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.c ===================================== @@ -19,7 +19,8 @@ int main(int argc, char *argv[]) { registerInfoProvList(list2); // Query an IPE to initialize the underlying hash map. - lookupIPE(list1->tables[0]); + InfoProvEnt ipe; + lookupIPE(list1->tables[0], &ipe); // Trace all IPE events. dumpIPEToEventLog(); ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,68 +1,20 @@ -7f86c4be8740: created capset 0 of type 2 -7f86c4be8740: created capset 1 of type 3 -7f86c4be8740: cap 0: initialised -7f86c4be8740: assigned cap 0 to capset 0 -7f86c4be8740: assigned cap 0 to capset 1 -7f86c4be8740: cap 0: created thread 1[""] -7f86c4be8740: cap 0: running thread 1[""] (ThreadRunGHC) -7f86c4be8740: cap 0: thread 1[""] stopped (stack overflow, size 109) -7f86c4be8740: cap 0: running thread 1[""] (ThreadRunGHC) -7f86c4be8740: cap 0: created thread 2[""] -7f86c4be8740: cap 0: thread 2 has label IOManager on cap 0 -7f86c4be8740: cap 0: thread 1[""] stopped (yielding) -7f86b67fc640: cap 0: running thread 2["IOManager on cap 0"] (ThreadRunGHC) -7f86b67fc640: cap 0: thread 2["IOManager on cap 0"] stopped (yielding) -7f86c4be8740: cap 0: running thread 1[""] (ThreadRunGHC) -7f86c4be8740: cap 0: created thread 3[""] -7f86c4be8740: cap 0: thread 3 has label TimerManager -7f86c4be8740: cap 0: thread 1[""] stopped (finished) -7f86c4be8740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 -7f86c4be8740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f86c4be8740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f86c4be8740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f86c4be8740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f86c4be8740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f86c4be8740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f86c4be8740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f86c4be8740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f86c4be8740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f86c4be8740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 -7f86c4be8740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f86c4be8740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f86c4be8740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f86c4be8740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f86c4be8740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f86c4be8740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f86c4be8740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f86c4be8740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f86c4be8740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f86c4be8740: cap 0: created thread 4[""] -7f86b67fc640: cap 0: running thread 2["IOManager on cap 0"] (ThreadRunGHC) -7f86b67fc640: cap 0: thread 2["IOManager on cap 0"] stopped (suspended while making a foreign call) -7f86b5ffb640: cap 0: running thread 3["TimerManager"] (ThreadRunGHC) -7f86b5ffb640: cap 0: thread 3["TimerManager"] stopped (suspended while making a foreign call) -7f86c4be8740: cap 0: running thread 4[""] (ThreadRunGHC) -7f86c4be8740: cap 0: thread 4[""] stopped (yielding) -7f86c4be8740: cap 0: running thread 4[""] (ThreadRunGHC) -7f86c4be8740: cap 0: thread 4[""] stopped (finished) -7f86b57fa640: cap 0: requesting sequential GC -7f86b57fa640: cap 0: starting GC -7f86b57fa640: cap 0: GC working -7f86b57fa640: cap 0: GC idle -7f86b57fa640: cap 0: GC done -7f86b57fa640: cap 0: GC idle -7f86b57fa640: cap 0: GC done -7f86b57fa640: cap 0: GC idle -7f86b57fa640: cap 0: GC done -7f86b57fa640: cap 0: Memory Return (Current: 6) (Needed: 8) (Returned: 0) -7f86b57fa640: cap 0: all caps stopped for GC -7f86b57fa640: cap 0: finished GC -7f86b5ffb640: cap 0: running thread 3["TimerManager"] (ThreadRunGHC) -7f86b5ffb640: cap 0: thread 3["TimerManager"] stopped (finished) -7f86b67fc640: cap 0: running thread 2["IOManager on cap 0"] (ThreadRunGHC) -7f86b67fc640: cap 0: thread 2["IOManager on cap 0"] stopped (finished) -7f86c4be8740: removed cap 0 from capset 0 -7f86c4be8740: removed cap 0 from capset 1 -7f86c4be8740: cap 0: shutting down -7f86c4be8740: deleted capset 0 -7f86c4be8740: deleted capset 1 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -28,14 +28,19 @@ int main(int argc, char *argv[]) { hs_exit(); } +static InfoProvEnt lookupIPE_(const char *where, const StgInfoTable *itbl) { + InfoProvEnt ent; + if (!lookupIPE(itbl, &ent)) { + barf("%s: Expected to find IPE entry", where); + } + return ent; +} + void shouldFindNothingInAnEmptyIPEMap(Capability *cap) { HaskellObj fortyTwo = UNTAG_CLOSURE(rts_mkInt(cap, 42)); - - InfoProvEnt *result = lookupIPE(get_itbl(fortyTwo)); - - if (result != NULL) { - errorBelch("Found entry in an empty IPE map!"); - exit(1); + InfoProvEnt ent; + if (lookupIPE(get_itbl(fortyTwo), &ent)) { + barf("Found entry in an empty IPE map!"); } } @@ -48,6 +53,9 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { StringTable st; init_string_table(&st); + node->unit_id = add_string(&st, "unit-id"); + node->module_name = add_string(&st, "TheModule"); + HaskellObj fortyTwo = UNTAG_CLOSURE(rts_mkInt(cap, 42)); node->next = NULL; node->compressed = 0; @@ -60,20 +68,16 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { registerInfoProvList(node); - InfoProvEnt *result = lookupIPE(get_itbl(fortyTwo)); + InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); - if (result == NULL) { - errorBelch("shouldFindOneIfItHasBeenRegistered: Found no entry in IPE map!"); - exit(1); - } - - assertStringsEqual(result->prov.table_name, "table_name_042"); - assertStringsEqual(result->prov.closure_desc, "closure_desc_042"); - assertStringsEqual(result->prov.ty_desc, "ty_desc_042"); - assertStringsEqual(result->prov.label, "label_042"); - assertStringsEqual(result->prov.module, "module_042"); - assertStringsEqual(result->prov.src_file, "src_file_042"); - assertStringsEqual(result->prov.src_span, "src_span_042"); + assertStringsEqual(result.prov.table_name, "table_name_042"); + assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); + assertStringsEqual(result.prov.label, "label_042"); + assertStringsEqual(result.prov.unit_id, "unit-id"); + assertStringsEqual(result.prov.module, "TheModule"); + assertStringsEqual(result.prov.src_file, "src_file_042"); + assertStringsEqual(result.prov.src_span, "src_span_042"); return fortyTwo; } @@ -88,6 +92,9 @@ void shouldFindTwoIfTwoHaveBeenRegistered(Capability *cap, StringTable st; init_string_table(&st); + node->unit_id = add_string(&st, "unit-id"); + node->module_name = add_string(&st, "TheModule"); + HaskellObj twentyThree = UNTAG_CLOSURE(rts_mkInt8(cap, 23)); node->next = NULL; node->compressed = 0; @@ -100,22 +107,11 @@ void shouldFindTwoIfTwoHaveBeenRegistered(Capability *cap, registerInfoProvList(node); - InfoProvEnt *resultFortyTwo = - lookupIPE(get_itbl(fortyTwo)); - InfoProvEnt *resultTwentyThree = - lookupIPE(get_itbl(twentyThree)); + InfoProvEnt resultFortyTwo = lookupIPE_("shouldFindTwoIfTwoHaveBeenRegistered", get_itbl(fortyTwo)); + assertStringsEqual(resultFortyTwo.prov.table_name, "table_name_042"); - if (resultFortyTwo == NULL) { - errorBelch("shouldFindTwoIfTwoHaveBeenRegistered(42): Found no entry in IPE map!"); - exit(1); - } - if (resultTwentyThree == NULL) { - errorBelch("shouldFindTwoIfTwoHaveBeenRegistered(23): Found no entry in IPE map!"); - exit(1); - } - - assertStringsEqual(resultFortyTwo->prov.table_name, "table_name_042"); - assertStringsEqual(resultTwentyThree->prov.table_name, "table_name_023"); + InfoProvEnt resultTwentyThree = lookupIPE_("shouldFindTwoIfTwoHaveBeenRegistered", get_itbl(twentyThree)); + assertStringsEqual(resultTwentyThree.prov.table_name, "table_name_023"); } void shouldFindTwoFromTheSameList(Capability *cap) { @@ -142,20 +138,11 @@ void shouldFindTwoFromTheSameList(Capability *cap) { registerInfoProvList(node); - InfoProvEnt *resultOne = lookupIPE(get_itbl(one)); - InfoProvEnt *resultTwo = lookupIPE(get_itbl(two)); - - if (resultOne == NULL) { - errorBelch("shouldFindTwoFromTheSameList(1): Found no entry in IPE map!"); - exit(1); - } - if (resultTwo == NULL) { - errorBelch("shouldFindTwoFromTheSameList(2): Found no entry in IPE map!"); - exit(1); - } + InfoProvEnt resultOne = lookupIPE_("shouldFindTwoFromTheSameList", get_itbl(one)); + assertStringsEqual(resultOne.prov.table_name, "table_name_001"); - assertStringsEqual(resultOne->prov.table_name, "table_name_001"); - assertStringsEqual(resultTwo->prov.table_name, "table_name_002"); + InfoProvEnt resultTwo = lookupIPE_("shouldFindTwoFromTheSameList", get_itbl(two)); + assertStringsEqual(resultTwo.prov.table_name, "table_name_002"); } void shouldDealWithAnEmptyList(Capability *cap, HaskellObj fortyTwo) { @@ -166,15 +153,8 @@ void shouldDealWithAnEmptyList(Capability *cap, HaskellObj fortyTwo) { registerInfoProvList(node); - InfoProvEnt *resultFortyTwo = - lookupIPE(get_itbl(fortyTwo)); - - if (resultFortyTwo == NULL) { - errorBelch("shouldDealWithAnEmptyList: Found no entry in IPE map!"); - exit(1); - } - - assertStringsEqual(resultFortyTwo->prov.table_name, "table_name_042"); + InfoProvEnt resultFortyTwo = lookupIPE_("shouldDealWithAnEmptyList", get_itbl(fortyTwo)); + assertStringsEqual(resultFortyTwo.prov.table_name, "table_name_042"); } void assertStringsEqual(const char *s1, const char *s2) { ===================================== testsuite/tests/rts/ipe/ipe_lib.c ===================================== @@ -48,11 +48,6 @@ IpeBufferEntry makeAnyProvEntry(Capability *cap, StringTable *st, int i) { snprintf(label, labelLength, "label_%03i", i); provEnt.label = add_string(st, label); - unsigned int moduleLength = strlen("module_") + 3 /* digits */ + 1 /* null character */; - char *module = malloc(sizeof(char) * moduleLength); - snprintf(module, moduleLength, "module_%03i", i); - provEnt.module_name = add_string(st, module); - unsigned int srcFileLength = strlen("src_file_") + 3 /* digits */ + 1 /* null character */; char *srcFile = malloc(sizeof(char) * srcFileLength); snprintf(srcFile, srcFileLength, "src_file_%03i", i); @@ -77,6 +72,16 @@ IpeBufferListNode *makeAnyProvEntries(Capability *cap, int start, int end) { StringTable st; init_string_table(&st); + unsigned int unitIdLength = strlen("unit_id_") + 3 /* digits */ + 1 /* null character */; + char *unitId = malloc(sizeof(char) * unitIdLength); + snprintf(unitId, unitIdLength, "unit_id_%03i", start); + node->unit_id = add_string(&st, unitId); + + unsigned int moduleLength = strlen("module_") + 3 /* digits */ + 1 /* null character */; + char *module = malloc(sizeof(char) * moduleLength); + snprintf(module, moduleLength, "module_%03i", start); + node->module_name = add_string(&st, module); + // Make the entries and fill the buffers for (int i=start; i < end; i++) { HaskellObj closure = rts_mkInt(cap, 42); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e592857b6e028fbad83712ceda6a0860191d379...ed0b69dc069a23692bff89cfcab1ad9d61999506 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e592857b6e028fbad83712ceda6a0860191d379...ed0b69dc069a23692bff89cfcab1ad9d61999506 You're receiving 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 Mar 9 22:38:54 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 09 Mar 2024 17:38:54 -0500 Subject: [Git][ghc/ghc][master] docs: Update info on TypeAbstractions Message-ID: <65ece4fe16598_3a044c3e4cc50133b5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - 2 changed files: - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/type_abstractions.rst Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -124,6 +124,20 @@ Language The extension is enabled by default, establishing the usual behavior. +- In accordance with GHC Proposal `#448 `_, + the :extension:`TypeAbstractions` extension has been extended to support + ``@``-binders in lambdas and function equations:: + + id :: forall a. a -> a + id @t x = x :: t + -- ^^ @-binder in a function equation + + e = higherRank (\ @t -> ... ) + -- ^^ @-binder in a lambda + + This feature is an experimental alternative to :extension:`ScopedTypeVariables`, + see the :ref:`type-abstractions-in-functions` section. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/type_abstractions.rst ===================================== @@ -6,7 +6,7 @@ Type abstractions :since: 9.8.1 - :status: Partially implemented + :status: Experimental Allow the use of type abstraction syntax. @@ -22,6 +22,8 @@ and `#425 From gitlab at gitlab.haskell.org Sun Mar 10 01:25:32 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sat, 09 Mar 2024 20:25:32 -0500 Subject: [Git][ghc/ghc][wip/T23942] 20 commits: base: Use strerror_r instead of strerror Message-ID: <65ed0c0c9d068_3a044c8d8b960177c3@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - c6c19071 by Matthew Craven at 2024-03-09T20:24:20-05:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - 154c54e5 by Matthew Craven at 2024-03-09T20:24:20-05:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/StgToJS/Types.hs - compiler/GHC/Tc/Errors/Hole/Plugin.hs-boot - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/LclEnv.hs-boot - compiler/GHC/Tc/Utils/Backpack.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62c6ce498cd2bd1fe0cf8e17cfc7d84fa3ae44c0...154c54e5712d6e5f55a271917b53a20545c291b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62c6ce498cd2bd1fe0cf8e17cfc7d84fa3ae44c0...154c54e5712d6e5f55a271917b53a20545c291b3 You're receiving 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 Mar 10 02:05:27 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 21:05:27 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/release-fixes Message-ID: <65ed15677ff5a_3a044c9d4af1822185@gitlab.mail> Ben Gamari pushed new branch wip/release-fixes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/release-fixes You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Mar 10 03:13:21 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 22:13:21 -0500 Subject: [Git][ghc/ghc][wip/release-fixes] 36 commits: ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65ed255152ab7_3a044cbb631bc25683@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - c8bf2af7 by Ben Gamari at 2024-03-09T22:12:56-05:00 configure: Bump GHC version to 9.11 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/exts/type_abstractions.rst - ghc/ghc-bin.cabal.in - libraries/array - 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/5fb7591d0a63b297d83c64f4f5b3c3e1e0115032...c8bf2af7739126087eafb5a7eb2854d53e62ee6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fb7591d0a63b297d83c64f4f5b3c3e1e0115032...c8bf2af7739126087eafb5a7eb2854d53e62ee6e You're receiving 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 Mar 10 03:18:44 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 09 Mar 2024 22:18:44 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.10] 26 commits: rts/CloneStack: Bounds check array write Message-ID: <65ed2694c0ccc_3a044cc06f4582593b@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - 19bca2fe by Ben Gamari at 2024-03-09T22:18:01-05:00 gitlab-ci: Allow test-primops to fail It's still a bit sensitive to warnings, unfortunately. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/exts/type_abstractions.rst - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-experimental/ghc-experimental.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-internal/ghc-internal.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5772336bad8480459a6a8fe2e7d5d9e340738bd4...19bca2fec8650034b1f9d9c3407713e69d653c73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5772336bad8480459a6a8fe2e7d5d9e340738bd4...19bca2fec8650034b1f9d9c3407713e69d653c73 You're receiving 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 Mar 10 03:59:42 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sat, 09 Mar 2024 22:59:42 -0500 Subject: [Git][ghc/ghc][wip/T23942] CorePrep: Rework lowering of BigNat# literals Message-ID: <65ed302eb8c7b_3a044cd1a6b18277c5@gitlab.mail> Matthew Craven pushed to branch wip/T23942 at Glasgow Haskell Compiler / GHC Commits: 6d8f274b by Matthew Craven at 2024-03-09T22:51:50-05:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/StgToJS/Types.hs - compiler/GHC/Tc/Errors/Hole/Plugin.hs-boot - compiler/GHC/Tc/Types/LclEnv.hs-boot - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Types/Id.hs-boot - compiler/GHC/Types/Var.hs-boot - compiler/GHC/Utils/Containers/Internal/StrictPair.hs - compiler/ghc.cabal.in - libraries/base/src/Data/Functor/Product.hs - libraries/base/src/Data/Functor/Sum.hs - libraries/base/src/Data/Kind.hs - libraries/base/src/GHC/ConsoleHandler.hs - libraries/base/src/GHC/Constants.hs - libraries/base/src/GHC/IO/Encoding/CodePage.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6d8f274b8677fcf9519d569875145f9f5434d779 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6d8f274b8677fcf9519d569875145f9f5434d779 You're receiving 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 Mar 10 12:56:18 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 10 Mar 2024 08:56:18 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] configure: Bump GHC version to 9.11 Message-ID: <65edadf2a7d26_1969874edb0bc11736@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 2 changed files: - configure.ac - utils/haddock Changes: ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.10.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.11], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 243fefaa40ddcc7c657a95e92f30cb79ec4ecb45 +Subproject commit 504d4c1842db93704b4c5e158ecc3af7050ba9fe View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc207d06e9a42bfb531cc0d24271547557b1c488 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc207d06e9a42bfb531cc0d24271547557b1c488 You're receiving 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 Mar 10 12:58:50 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 10 Mar 2024 08:58:50 -0400 Subject: [Git][ghc/ghc][master] 16 commits: ci-images: Bump Alpine image to bootstrap with 9.8.2 Message-ID: <65edae8ae0039_196987512037c166bf@gitlab.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-experimental/ghc-experimental.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-prim/ghc-prim.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - libraries/hpc - libraries/os-string - libraries/parsec The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b1faea90dff1ad743925eb5a0b552a11c514349...dc207d06e9a42bfb531cc0d24271547557b1c488 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b1faea90dff1ad743925eb5a0b552a11c514349...dc207d06e9a42bfb531cc0d24271547557b1c488 You're receiving 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 Mar 10 12:59:08 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 10 Mar 2024 08:59:08 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.11-start Message-ID: <65edae9ce765b_196987516215016869@gitlab.mail> Ben Gamari pushed new tag ghc-9.11-start at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.11-start You're receiving 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 Mar 10 13:32:53 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 10 Mar 2024 09:32:53 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] rel_eng/upload: Purge both $rel_name/ and $ver/ Message-ID: <65edb685b34b6_196987654a938192df@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: 865d7339 by Ben Gamari at 2024-03-10T09:32:46-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 1 changed file: - .gitlab/rel_eng/upload.sh Changes: ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -136,7 +136,7 @@ function upload() { } function purge_all() { - dir="$(echo $rel_name | sed s/-release//)" + local dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -150,12 +150,18 @@ function purge_all() { } function purge_file() { - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/docs/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/docs/ + dirs=( + "~ghc/$rel_name" + "ghc/$rel_name" + "~ghc/$ver" + "ghc/$ver" + ) + + for dir in ${dirs[@]}; do + curl -X PURGE http://downloads.haskell.org/$dir/$i + curl -X PURGE http://downloads.haskell.org/$dir/$i/ + curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + done } function prepare_docs() { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/865d73393d91b6f86310c9729a05a7fe871aaa6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/865d73393d91b6f86310c9729a05a7fe871aaa6f You're receiving 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 Mar 10 17:19:19 2024 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Sun, 10 Mar 2024 13:19:19 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/minor-cleanups Message-ID: <65edeb97d9153_196987c63d2182563d@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/minor-cleanups at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/minor-cleanups You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 02:39:01 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 10 Mar 2024 22:39:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24528 Message-ID: <65ee6ec56bfad_3939ed355b1b47998@gitlab.mail> Ben Gamari pushed new branch wip/T24528 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24528 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 02:39:14 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 10 Mar 2024 22:39:14 -0400 Subject: [Git][ghc/ghc][wip/T24528] Bump time submodule to 1.14 Message-ID: <65ee6ed2e33fd_3939ed35924ac814@gitlab.mail> Ben Gamari pushed to branch wip/T24528 at Glasgow Haskell Compiler / GHC Commits: 667daed5 by Ben Gamari at 2024-03-10T22:39:02-04:00 Bump time submodule to 1.14 As requested in #24528. - - - - - 1 changed file: - libraries/time Changes: ===================================== libraries/time ===================================== @@ -1 +1 @@ -Subproject commit baab563ee2ce547f7b7f7e7069ed09db2d406941 +Subproject commit e5c5d1987011efe88a21ab6ded45aaa33a16274f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/667daed5d41d1370a48bf79fc35c681eb958416e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/667daed5d41d1370a48bf79fc35c681eb958416e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 02:50:04 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 10 Mar 2024 22:50:04 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 20 commits: docs: Update info on TypeAbstractions Message-ID: <65ee715c1358f_3939ed39063a4127d1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - bf4fab85 by Ben Gamari at 2024-03-10T22:49:58-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 0dc8dcc2 by Ben Gamari at 2024-03-10T22:49:58-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 869d8867 by Ben Gamari at 2024-03-10T22:49:58-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/exts/type_abstractions.rst - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-experimental/ghc-experimental.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-prim/ghc-prim.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - libraries/hpc - libraries/os-string The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddffaba03ecb57b90b33ee72f3371a10bf1e1c1f...869d8867c758cf2587aa2990bdd73f68268c0f3d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddffaba03ecb57b90b33ee72f3371a10bf1e1c1f...869d8867c758cf2587aa2990bdd73f68268c0f3d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 05:21:21 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 11 Mar 2024 01:21:21 -0400 Subject: [Git][ghc/ghc][master] 2 commits: rts/linker: Don't unload code when profiling is enabled Message-ID: <65ee94d140a4a_3939ed7ead7cc27088@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 5 changed files: - rts/CheckUnload.c - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c Changes: ===================================== rts/CheckUnload.c ===================================== @@ -165,6 +165,18 @@ ObjectCode *loaded_objects; // map static closures to their ObjectCode. static OCSectionIndices *global_s_indices = NULL; +// Is it safe for us to unload code? +static bool safeToUnload(void) +{ + if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) { + // We mustn't unload anything as the heap census may contain + // references into static data (e.g. cost centre names). + // See #24512. + return false; + } + return true; +} + static OCSectionIndices *createOCSectionIndices(void) { // TODO (osa): Maybe initialize as empty (without allocation) and allocate @@ -457,6 +469,8 @@ void checkUnload(void) { if (global_s_indices == NULL) { return; + } else if (!safeToUnload()) { + return; } // At this point we've marked all dynamically loaded static objects @@ -478,8 +492,6 @@ void checkUnload(void) next = oc->next; ASSERT(oc->status == OBJECT_UNLOADED); - removeOCSectionIndices(s_indices, oc); - // Symbols should be removed by unloadObj_. // NB (osa): If this assertion doesn't hold then freeObjectCode below // will corrupt symhash as keys of that table live in ObjectCodes. If @@ -487,8 +499,17 @@ void checkUnload(void) // RTS) then it's probably because this assertion did not hold. ASSERT(oc->symbols == NULL); - freeObjectCode(oc); - n_unloaded_objects -= 1; + if (oc->unloadable) { + removeOCSectionIndices(s_indices, oc); + freeObjectCode(oc); + n_unloaded_objects -= 1; + } else { + // If we don't have enough information to + // accurately determine the reachability of + // the object then hold onto it. + oc->next = objects; + objects = oc; + } } old_objects = NULL; ===================================== rts/Linker.c ===================================== @@ -1385,6 +1385,8 @@ mkOc( ObjectType type, pathchar *path, char *image, int imageSize, oc->prev = NULL; oc->next_loaded_object = NULL; oc->mark = object_code_mark_bit; + /* this will get cleared by the caller if object is not safely unloadable */ + oc->unloadable = true; oc->dependencies = allocHashSet(); #if defined(NEED_M32) ===================================== rts/LinkerInternals.h ===================================== @@ -313,8 +313,14 @@ struct _ObjectCode { struct _ObjectCode *next_loaded_object; // Mark bit + // N.B. This is a full word as we CAS it. StgWord mark; + // Can this object be safely unloaded? Not true for + // dynamic objects when dlinfo is not available as + // we cannot determine liveness. + bool unloadable; + // Set of dependencies (ObjectCode*) of the object file. Traverse // dependencies using `iterHashTable`. // @@ -376,7 +382,9 @@ struct _ObjectCode { /* handle returned from dlopen */ void *dlopen_handle; - /* virtual memory ranges of loaded code */ + /* virtual memory ranges of loaded code. NULL if no range information is + * available (e.g. if dlinfo is unavailable on the current platform). + */ NativeCodeRange *nc_ranges; }; ===================================== rts/linker/Elf.c ===================================== @@ -2186,6 +2186,10 @@ void * loadNativeObj_ELF (pathchar *path, char **errmsg) copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); goto dl_iterate_phdr_fail; } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; #endif /* defined (HAVE_DLINFO) */ insertOCSectionIndices(nc); ===================================== testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c ===================================== @@ -64,7 +64,7 @@ void check_object_freed(char *obj_path) { OStatus st; st = getObjectLoadStatus(toPathchar(obj_path)); if (st != OBJECT_NOT_LOADED) { - errorBelch("object %s status != OBJECT_NOT_LOADED", obj_path); + errorBelch("object %s status != OBJECT_NOT_LOADED, is %d instead", obj_path, st); exit(1); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc207d06e9a42bfb531cc0d24271547557b1c488...7810b4c37c7d03772215102a8db5e84d29fe2221 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc207d06e9a42bfb531cc0d24271547557b1c488...7810b4c37c7d03772215102a8db5e84d29fe2221 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 05:21:42 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 11 Mar 2024 01:21:42 -0400 Subject: [Git][ghc/ghc][master] rel_eng/upload: Purge both $rel_name/ and $ver/ Message-ID: <65ee94e64db35_3939ed7edeafc2720@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 1 changed file: - .gitlab/rel_eng/upload.sh Changes: ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -136,7 +136,7 @@ function upload() { } function purge_all() { - dir="$(echo $rel_name | sed s/-release//)" + local dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -150,12 +150,18 @@ function purge_all() { } function purge_file() { - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/docs/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/docs/ + dirs=( + "~ghc/$rel_name" + "ghc/$rel_name" + "~ghc/$ver" + "ghc/$ver" + ) + + for dir in ${dirs[@]}; do + curl -X PURGE http://downloads.haskell.org/$dir/$i + curl -X PURGE http://downloads.haskell.org/$dir/$i/ + curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + done } function prepare_docs() { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0590764c73841115fc567757e370d5c9dc7e6478 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0590764c73841115fc567757e370d5c9dc7e6478 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 15:23:29 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 11 Mar 2024 11:23:29 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] 156 commits: JS: add simple optimizer Message-ID: <65ef21f1dda6e_3503b984fcac147763@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 091a113e by Apoorv Ingle at 2024-03-11T08:25:26-05:00 make applicative do work with expansions, possibly badly Fixes: #24406 - - - - - b3d90ba3 by Apoorv Ingle at 2024-03-11T08:25:26-05:00 enable the flow - - - - - 5106889a by Apoorv Ingle at 2024-03-11T08:25:26-05:00 renaming do_or_lc to doFlavour and debugging error contexts - - - - - 21 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Uniques.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f6ec2c444332b32273f9b9abedee4c92a3242d97...5106889a7948f353f83f1584aa22f822e72680ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f6ec2c444332b32273f9b9abedee4c92a3242d97...5106889a7948f353f83f1584aa22f822e72680ed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 15:32:52 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Mon, 11 Mar 2024 11:32:52 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/fix-tysyn] 52 commits: Rephrase error message to say "visible arguments" (#24318) Message-ID: <65ef2424930fe_3503b9f224581509f6@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/fix-tysyn at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 7da705c2 by Andrei Borzenkov at 2024-03-11T19:32:39+04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (24470) - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Unify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/350f84ea75f5c4ab69716ae9e42ebdcb3e5ecef1...7da705c22859db07b5a22858a68f1fc49281d577 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/350f84ea75f5c4ab69716ae9e42ebdcb3e5ecef1...7da705c22859db07b5a22858a68f1fc49281d577 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 15:34:32 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Mon, 11 Mar 2024 11:34:32 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/fix-tysyn] Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) Message-ID: <65ef2488d3e27_3503b9ffd28815118f@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/fix-tysyn at Glasgow Haskell Compiler / GHC Commits: 6c9bca43 by Andrei Borzenkov at 2024-03-11T19:34:08+04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 9 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accomodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c9bca4333c20de6aa3df9c629f40f33faccd887 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c9bca4333c20de6aa3df9c629f40f33faccd887 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 15:36:12 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Mon, 11 Mar 2024 11:36:12 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/fix-tysyn] Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) Message-ID: <65ef24ecd4bbb_3503ba0be050152959@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/fix-tysyn at Glasgow Haskell Compiler / GHC Commits: 283f257f by Andrei Borzenkov at 2024-03-11T19:35:59+04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 9 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accommodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/283f257f45b11e3824ff7d7bd3fe1ae6881c713a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/283f257f45b11e3824ff7d7bd3fe1ae6881c713a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 17:38:49 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 11 Mar 2024 13:38:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18313 Message-ID: <65ef41a9e7391_358193c3dbec67531@gitlab.mail> Apoorv Ingle pushed new branch wip/T18313 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18313 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 20:25:22 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 11 Mar 2024 16:25:22 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] 5 commits: gitlab/rel_eng: Fix name of Rocky8 artifact Message-ID: <65ef68b2cb3be_3581934f1c058751b6@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: da97c238 by Ben Gamari at 2024-03-09T20:08:12-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - d7fa9dd9 by Ben Gamari at 2024-03-09T20:08:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - 5fb7591d by Ben Gamari at 2024-03-09T20:28:41-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - 3e109143 by Ben Gamari at 2024-03-11T16:24:22-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 7c32c59b by Ben Gamari at 2024-03-11T16:24:24-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - 7 changed files: - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== .gitlab/rel_eng/default.nix ===================================== @@ -27,6 +27,15 @@ let buildCommand = '' mkdir -p $out/bin + makeWrapper ${./recompress-all} $out/bin/recompress-all \ + --prefix PATH : ${gnumake}/bin \ + --prefix PATH : ${gnutar}/bin \ + --prefix PATH : ${lzip}/bin \ + --prefix PATH : ${bzip2}/bin \ + --prefix PATH : ${gzip}/bin \ + --prefix PATH : ${xz}/bin \ + --prefix PATH : ${zip}/bin + makeWrapper ${./upload.sh} $out/bin/upload.sh \ --prefix PATH : ${moreutils}/bin \ --prefix PATH : ${lftp}/bin \ @@ -35,8 +44,8 @@ let --prefix PATH : ${s3cmd}/bin \ --prefix PATH : ${gnupg}/bin \ --prefix PATH : ${pinentry}/bin \ - --prefix PATH : ${parallel}/bin \ --prefix PATH : ${python3}/bin \ + --prefix PATH : $out/bin \ --set ENTER_FHS_ENV ${bindistPrepEnv}/bin/enter-fhs \ --set BASH ${bash}/bin/bash ===================================== .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py ===================================== @@ -18,7 +18,7 @@ def job_triple(job_name): bindists = { 'release-x86_64-windows-release': 'x86_64-unknown-mingw32', 'release-x86_64-windows-int_native-release': 'x86_64-unknown-mingw32-int_native', - 'release-x86_64-rocky8-release': 'x86_64-rocky8-linux', + 'release-x86_64-linux-rocky8-release': 'x86_64-rocky8-linux', 'release-x86_64-linux-ubuntu20_04-release': 'x86_64-ubuntu20_04-linux', 'release-x86_64-linux-ubuntu18_04-release': 'x86_64-ubuntu18_04-linux', 'release-x86_64-linux-fedora33-release+debug_info': 'x86_64-fedora33-linux-dwarf', ===================================== .gitlab/rel_eng/mk-ghcup-metadata/README.mkd ===================================== @@ -22,7 +22,7 @@ options: ``` The script also requires the `.gitlab/jobs-metadata.yaml` file which can be generated -by running `.gitlab/generate_jobs_metadata` script if you want to run it locally. +by running `.gitlab/generate-ci/generate_jobs_metadata` script if you want to run it locally. ## CI Pipelines ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -0,0 +1,29 @@ +#!/usr/bin/env -S make -f + +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-builtin-variables + +usage : + echo "recompress [dest files]" + exit 1 + +%.gz : %.xz + echo "[xz->gz] $< to $@..." + xz -c $< | gzip -c > $@ + +%.bz2 : %.xz + echo "[xz->bz2] $< to $@..." + xz -c $< | bzip2 -c > $@ + +%.lz : %.xz + echo "[xz->lz] $< to $@..." + xz -c $< | lzip -c > $@ + +%.zip : %.tar.xz + echo "[tarxz->zip] $< to $@..." + tmp="$(mktemp tmp.XXX)" && \ + tar -C "$$tmp" -xf $< && \ + cd "$$tmp" && \ + zip -9 -r $@ * && \ + rm -R "$$tmp" + ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -193,29 +193,21 @@ function prepare_docs() { function recompress() { set -Eeuo pipefail - combine <(basename -s .xz *.xz) not <(basename -s .lz *.lz) | \ - parallel 'echo "Recompressing {}.xz to {}.lz"; unxz -c {}.xz | lzip - -o {}.lz' - - for darwin_bindist in $(ls ghc-*-darwin.tar.xz); do - local dest="$(basename $darwin_bindist .xz).bz2" - if [[ ! -f "$dest" ]]; then - echo "Recompressing Darwin bindist to bzip2..." - unxz -c "$darwin_bindist" | bzip2 > "$dest" - fi + needed=() + + for i in ghc-*.tar.xz; do + needed+=( "$(basename $i .xz).gz" ) done - for windows_bindist in $(ls ghc-*-mingw32*.tar.xz); do - local tmp="$(mktemp -d tmp.XXX)" - local dest="$(realpath $(basename $windows_bindist .tar.xz).zip)" - echo $dest - if [[ ! -f "$dest" ]]; then - echo "Recompressing Windows bindist to zip..." - tar -C "$tmp" -xf "$windows_bindist" - ls $tmp - (cd "$tmp"; zip -9 -r "$dest" *) - fi - rm -R "$tmp" + for i in ghc-*-darwin.tar.xz; do + needed+=( "$(basename $i .xz).bz2" ) done + + for i in ghc-*-mingw32.tar.xz; do + needed+=( "$(basename $i .tar.xz).zip" ) + done + + recompress-all -l ${needed[@]} } function upload_docs() { ===================================== hadrian/bindist/Makefile ===================================== @@ -175,18 +175,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/865d73393d91b6f86310c9729a05a7fe871aaa6f...7c32c59b924f59ce0718f5894b7ff0ebdb85fe65 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/865d73393d91b6f86310c9729a05a7fe871aaa6f...7c32c59b924f59ce0718f5894b7ff0ebdb85fe65 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 20:35:33 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 11 Mar 2024 16:35:33 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 5 commits: configure: Bump GHC version to 9.11 Message-ID: <65ef6b15ec95d_35819354a17a877092@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - eb933212 by Ben Gamari at 2024-03-10T09:32:03-04:00 gitlab-ci: Allow test-primops to fail It's still a bit sensitive to warnings, unfortunately. - - - - - fc270d76 by Ben Gamari at 2024-03-10T09:32:03-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 570c32dd by Ben Gamari at 2024-03-11T16:33:44-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - eee314ac by Ben Gamari at 2024-03-11T16:33:47-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 6 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/upload.sh - configure.ac - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs - utils/haddock Changes: ===================================== .gitlab-ci.yml ===================================== @@ -899,6 +899,7 @@ test-primops-nightly: test-primops-release: extends: .test-primops + allow_failure: true rules: - if: '$RELEASE_JOB == "yes"' ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -136,7 +136,7 @@ function upload() { } function purge_all() { - dir="$(echo $rel_name | sed s/-release//)" + local dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -150,12 +150,18 @@ function purge_all() { } function purge_file() { - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/docs/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/docs/ + dirs=( + "~ghc/$rel_name" + "ghc/$rel_name" + "~ghc/$ver" + "ghc/$ver" + ) + + for dir in ${dirs[@]}; do + curl -X PURGE http://downloads.haskell.org/$dir/$i + curl -X PURGE http://downloads.haskell.org/$dir/$i/ + curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + done } function prepare_docs() { ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.10.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.11], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are ===================================== hadrian/bindist/Makefile ===================================== @@ -175,18 +175,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 243fefaa40ddcc7c657a95e92f30cb79ec4ecb45 +Subproject commit 504d4c1842db93704b4c5e158ecc3af7050ba9fe View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/19bca2fec8650034b1f9d9c3407713e69d653c73...eee314ac17396357c9e0520a3b389f47cd90e80b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/19bca2fec8650034b1f9d9c3407713e69d653c73...eee314ac17396357c9e0520a3b389f47cd90e80b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 21:56:04 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 11 Mar 2024 17:56:04 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] 2 commits: hadrian/bindist: Eliminate extraneous `dirname` invocation Message-ID: <65ef7df4b0ba_35819379d20b887019@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: fe9f4cda by Ben Gamari at 2024-03-11T17:55:48-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 069a38ec by Ben Gamari at 2024-03-11T17:55:57-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - 2 changed files: - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -175,18 +175,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`"; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c32c59b924f59ce0718f5894b7ff0ebdb85fe65...069a38ec2120f10fdfe40e3fa2807b93c03857d1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c32c59b924f59ce0718f5894b7ff0ebdb85fe65...069a38ec2120f10fdfe40e3fa2807b93c03857d1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 21:56:39 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 11 Mar 2024 17:56:39 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] hadrian/bindist: Eliminate extraneous `dirname` invocation Message-ID: <65ef7e1756143_3581937ad56e08746e@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 563fa0fd by Ben Gamari at 2024-03-11T17:56:26-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 1 changed file: - hadrian/bindist/Makefile Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -175,18 +175,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" ; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/563fa0fd6d25b6187e763832adaae2659fe1f52e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/563fa0fd6d25b6187e763832adaae2659fe1f52e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 21:57:11 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 11 Mar 2024 17:57:11 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] 2 commits: hadrian/bindist: Eliminate extraneous `dirname` invocation Message-ID: <65ef7e3737587_3581937b9218c88031@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: 3116d29a by Ben Gamari at 2024-03-11T17:57:04-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 7553df38 by Ben Gamari at 2024-03-11T17:57:04-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - 2 changed files: - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -175,18 +175,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" ; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/069a38ec2120f10fdfe40e3fa2807b93c03857d1...7553df3897c2170b42fbbfbc254fff85e9c0bb10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/069a38ec2120f10fdfe40e3fa2807b93c03857d1...7553df3897c2170b42fbbfbc254fff85e9c0bb10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 22:23:21 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Mon, 11 Mar 2024 18:23:21 -0400 Subject: [Git][ghc/ghc][wip/tsan/fixes-3] 33 commits: rts/CloneStack: Bounds check array write Message-ID: <65ef8459e441c_3581938c7a9049202@gitlab.mail> Cheng Shao pushed to branch wip/tsan/fixes-3 at Glasgow Haskell Compiler / GHC Commits: c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - d4a22bab by Ben Gamari at 2024-03-11T08:25:44+00:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - bc8ccc11 by Cheng Shao at 2024-03-11T22:02:02+00:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - 8c381639 by Cheng Shao at 2024-03-11T22:04:45+00:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - - - - - 917fc23e by Cheng Shao at 2024-03-11T22:12:18+00:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/exts/type_abstractions.rst - ghc/ghc-bin.cabal.in - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/deepseq - libraries/directory - libraries/exceptions - libraries/filepath - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-experimental/ghc-experimental.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/981eedbe8fbd7253c2b9f943d1a19ab33a9e40df...917fc23ec9b8ebcca3a5beead2b94dd7b8ec3975 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/981eedbe8fbd7253c2b9f943d1a19ab33a9e40df...917fc23ec9b8ebcca3a5beead2b94dd7b8ec3975 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 22:25:06 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Mon, 11 Mar 2024 18:25:06 -0400 Subject: [Git][ghc/ghc][wip/tsan/fixes-3] ci: improve TSAN CI jobs Message-ID: <65ef84c235b49_3581938def6049243@gitlab.mail> Cheng Shao pushed to branch wip/tsan/fixes-3 at Glasgow Haskell Compiler / GHC Commits: 361b2707 by Cheng Shao at 2024-03-11T22:24:14+00:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - 2 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -339,7 +339,7 @@ flavourString (Flavour base trans) = base_string base ++ concatMap (("+" ++) . f flavour_string Llvm = "llvm" flavour_string Dwarf = "debug_info" flavour_string FullyStatic = "fully_static" - flavour_string ThreadSanitiser = "thread_sanitizer" + flavour_string ThreadSanitiser = "thread_sanitizer_cmm" flavour_string NoSplitSections = "no_split_sections" flavour_string BootNonmovingGc = "boot_nonmoving_gc" @@ -969,9 +969,9 @@ job_groups = , validateBuilds Amd64 (Linux Debian10) nativeInt , validateBuilds Amd64 (Linux Debian10) unreg , fastCI (validateBuilds Amd64 (Linux Debian10) debug) - , -- Nightly allowed to fail: #22520 + , -- More work is needed to address TSAN failures: #22520 modifyNightlyJobs allowFailure - (modifyValidateJobs manual tsan_jobs) + (modifyValidateJobs (allowFailure . manual) tsan_jobs) , -- Nightly allowed to fail: #22343 modifyNightlyJobs allowFailure (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc)) @@ -1039,7 +1039,7 @@ job_groups = -- Haddock is large enough to make TSAN choke without massive quantities of -- memory. . addVariable "HADRIAN_ARGS" "--docs=none") $ - validateBuilds Amd64 (Linux Debian10) tsan + validateBuilds Amd64 (Linux Debian12) tsan make_wasm_jobs cfg = modifyJobs ===================================== .gitlab/jobs.yaml ===================================== @@ -1644,18 +1644,18 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-validate+thread_sanitizer": { + "nightly-x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1698,17 +1698,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", + "TEST_ENV": "x86_64-linux-deb10-zstd-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-zstd-validate": { + "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1719,7 +1717,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1729,14 +1727,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -1762,15 +1760,17 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate", + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1781,7 +1781,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1823,18 +1823,19 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "nightly-x86_64-linux-deb11-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1845,7 +1846,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1887,19 +1888,16 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "TEST_ENV": "x86_64-linux-deb11-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate": { + "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1910,7 +1908,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1953,15 +1951,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-validate", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "nightly-x86_64-linux-deb12-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1972,7 +1970,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1982,14 +1980,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -2015,15 +2013,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate": { + "nightly-x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -2034,7 +2032,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2077,26 +2075,26 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate+llvm": { + "nightly-x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2139,11 +2137,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm", + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", "XZ_OPT": "-9" } }, @@ -5090,7 +5090,7 @@ "TEST_ENV": "x86_64-linux-deb10-validate+debug_info" } }, - "x86_64-linux-deb10-validate+thread_sanitizer": { + "x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5101,7 +5101,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5127,9 +5127,8 @@ ], "rules": [ { - "allow_failure": true, - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "manual" + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "on_success" } ], "script": [ @@ -5145,16 +5144,14 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + "TEST_ENV": "x86_64-linux-deb10-zstd-validate" } }, - "x86_64-linux-deb10-zstd-validate": { + "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5165,7 +5162,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5175,14 +5172,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5191,7 +5188,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5208,14 +5205,16 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate" + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5226,7 +5225,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5252,7 +5251,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5268,17 +5267,18 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" } }, - "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5289,7 +5289,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5315,7 +5315,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5331,18 +5331,15 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" } }, - "x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5353,7 +5350,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5363,14 +5360,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5379,7 +5376,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5396,25 +5393,25 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm" } }, - "x86_64-linux-deb12-validate+llvm": { + "x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5440,8 +5437,9 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "on_success" + "allow_failure": true, + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "manual" } ], "script": [ @@ -5457,11 +5455,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm" + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" } }, "x86_64-linux-fedora33-release": { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/361b270730677562a1324acd6736dab564a5a947 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/361b270730677562a1324acd6736dab564a5a947 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 11 23:03:11 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Mon, 11 Mar 2024 19:03:11 -0400 Subject: [Git][ghc/ghc][wip/tsan/fixes-3] ci: improve TSAN CI jobs Message-ID: <65ef8daf45c88_3581939d820bc94564@gitlab.mail> Cheng Shao pushed to branch wip/tsan/fixes-3 at Glasgow Haskell Compiler / GHC Commits: c4128331 by Cheng Shao at 2024-03-11T23:02:43+00:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - 2 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -339,7 +339,7 @@ flavourString (Flavour base trans) = base_string base ++ concatMap (("+" ++) . f flavour_string Llvm = "llvm" flavour_string Dwarf = "debug_info" flavour_string FullyStatic = "fully_static" - flavour_string ThreadSanitiser = "thread_sanitizer" + flavour_string ThreadSanitiser = "thread_sanitizer_cmm" flavour_string NoSplitSections = "no_split_sections" flavour_string BootNonmovingGc = "boot_nonmoving_gc" @@ -969,9 +969,9 @@ job_groups = , validateBuilds Amd64 (Linux Debian10) nativeInt , validateBuilds Amd64 (Linux Debian10) unreg , fastCI (validateBuilds Amd64 (Linux Debian10) debug) - , -- Nightly allowed to fail: #22520 + , -- More work is needed to address TSAN failures: #22520 modifyNightlyJobs allowFailure - (modifyValidateJobs manual tsan_jobs) + (modifyValidateJobs (allowFailure . manual) tsan_jobs) , -- Nightly allowed to fail: #22343 modifyNightlyJobs allowFailure (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc)) @@ -1039,7 +1039,7 @@ job_groups = -- Haddock is large enough to make TSAN choke without massive quantities of -- memory. . addVariable "HADRIAN_ARGS" "--docs=none") $ - validateBuilds Amd64 (Linux Debian10) tsan + validateBuilds Amd64 (Linux Debian12) tsan make_wasm_jobs cfg = modifyJobs @@ -1083,6 +1083,7 @@ platform_mapping = Map.map go combined_result , "nightly-x86_64-linux-deb11-validate" , "nightly-x86_64-linux-deb12-validate" , "x86_64-linux-alpine3_18-wasm-cross_wasm32-wasi-release+fully_static" + , "x86_64-linux-deb12-validate+thread_sanitizer_cmm" , "nightly-aarch64-linux-deb10-validate" , "nightly-x86_64-linux-alpine3_12-validate" , "nightly-x86_64-linux-deb10-validate" ===================================== .gitlab/jobs.yaml ===================================== @@ -1644,18 +1644,18 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-validate+thread_sanitizer": { + "nightly-x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1698,17 +1698,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", + "TEST_ENV": "x86_64-linux-deb10-zstd-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-zstd-validate": { + "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1719,7 +1717,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1729,14 +1727,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -1762,15 +1760,17 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate", + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1781,7 +1781,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1823,18 +1823,19 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "nightly-x86_64-linux-deb11-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1845,7 +1846,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1887,19 +1888,16 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "TEST_ENV": "x86_64-linux-deb11-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate": { + "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1910,7 +1908,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1953,15 +1951,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-validate", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "nightly-x86_64-linux-deb12-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1972,7 +1970,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1982,14 +1980,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -2015,15 +2013,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate": { + "nightly-x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -2034,7 +2032,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2077,26 +2075,26 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate+llvm": { + "nightly-x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2139,11 +2137,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm", + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", "XZ_OPT": "-9" } }, @@ -5090,7 +5090,7 @@ "TEST_ENV": "x86_64-linux-deb10-validate+debug_info" } }, - "x86_64-linux-deb10-validate+thread_sanitizer": { + "x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5101,7 +5101,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5127,9 +5127,8 @@ ], "rules": [ { - "allow_failure": true, - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "manual" + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "on_success" } ], "script": [ @@ -5145,16 +5144,14 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + "TEST_ENV": "x86_64-linux-deb10-zstd-validate" } }, - "x86_64-linux-deb10-zstd-validate": { + "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5165,7 +5162,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5175,14 +5172,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5191,7 +5188,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5208,14 +5205,16 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate" + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5226,7 +5225,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5252,7 +5251,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5268,17 +5267,18 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" } }, - "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5289,7 +5289,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5315,7 +5315,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5331,18 +5331,15 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" } }, - "x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5353,7 +5350,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5363,14 +5360,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5379,7 +5376,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5396,25 +5393,25 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm" } }, - "x86_64-linux-deb12-validate+llvm": { + "x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5440,8 +5437,9 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "on_success" + "allow_failure": true, + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "manual" } ], "script": [ @@ -5457,11 +5455,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm" + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" } }, "x86_64-linux-fedora33-release": { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4128331d766c13b5333e14e06251ff7fc1d5e96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4128331d766c13b5333e14e06251ff7fc1d5e96 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 07:26:56 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Tue, 12 Mar 2024 03:26:56 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/sand-witch/tysyn-info-ppr Message-ID: <65f003c0287f1_25db4e8567720829be@gitlab.mail> Andrei Borzenkov pushed new branch wip/sand-witch/tysyn-info-ppr at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sand-witch/tysyn-info-ppr You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 07:28:05 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Tue, 12 Mar 2024 03:28:05 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/tysyn-info-ppr] Update GHCi :info type synonym printing (24459) Message-ID: <65f004053d06_25db4e88b8c3083186@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/tysyn-info-ppr at Glasgow Haskell Compiler / GHC Commits: 1fc7d5a7 by Andrei Borzenkov at 2024-03-12T11:27:37+04:00 Update GHCi :info type synonym printing (24459) - Do not print result's kind since we have full kind in SAKS and have arity using @-binders - Do not suppress significant invisible binders Invisible binder is considered significant when it meets at least one of two following criteria: - It visibly occurs in the RHS type - It is not followed by a visible binder, so it affects arity of type synonym - - - - - 23 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout - testsuite/tests/backpack/should_fail/T19244a.stderr - testsuite/tests/backpack/should_fail/T19244b.stderr - testsuite/tests/backpack/should_fail/bkpfail46.stderr - testsuite/tests/ghci/T18060/T18060.stdout - testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout - testsuite/tests/ghci/scripts/T15941.stdout - testsuite/tests/ghci/scripts/T19310.stdout - testsuite/tests/ghci/scripts/T21294a.stdout - + testsuite/tests/ghci/scripts/T24459.script - + testsuite/tests/ghci/scripts/T24459.stdout - testsuite/tests/ghci/scripts/T8535.stdout - testsuite/tests/ghci/scripts/T9181.stdout - testsuite/tests/ghci/scripts/all.T - testsuite/tests/ghci/scripts/ghci020.stdout - testsuite/tests/ghci/should_run/T10145.stdout - testsuite/tests/ghci/should_run/T18594.stdout - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/rep-poly/RepPolyBackpack3.stderr Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -25,7 +25,7 @@ module GHC.Core.TyCon( mkRequiredTyConBinder, mkAnonTyConBinder, mkAnonTyConBinders, tyConBinderForAllTyFlag, tyConBndrVisForAllTyFlag, isNamedTyConBinder, - isVisibleTyConBinder, isInvisibleTyConBinder, + isVisibleTyConBinder, isInvisSpecTyConBinder, isInvisibleTyConBinder, isVisibleTcbVis, isInvisSpecTcbVis, -- ** Field labels @@ -514,6 +514,10 @@ isInvisSpecTcbVis :: TyConBndrVis -> Bool isInvisSpecTcbVis (NamedTCB Specified) = True isInvisSpecTcbVis _ = False +isInvisSpecTyConBinder :: VarBndr tv TyConBndrVis -> Bool +-- Works for IfaceTyConBinder too +isInvisSpecTyConBinder (Bndr _ tcb_vis) = isInvisSpecTcbVis tcb_vis + isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool -- Works for IfaceTyConBinder too isInvisibleTyConBinder tcb = not (isVisibleTyConBinder tcb) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1033,15 +1033,14 @@ pprIfaceDecl ss (IfaceClass { ifName = clas pprIfaceDecl ss (IfaceSynonym { ifName = tc , ifBinders = binders - , ifSynRhs = mono_ty + , ifSynRhs = poly_ty , ifResKind = res_kind}) = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind) - , hang (text "type" <+> pprIfaceDeclHead suppress_bndr_sig [] ss tc binders <+> equals) - 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau - , ppUnless (isIfaceLiftedTypeKind res_kind) (dcolon <+> ppr res_kind) ]) + , hang (text "type" <+> pprIfaceDeclHeadInvis suppress_bndr_sig [] ss tc binders tau <+> equals) + 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau ]) ] where - (tvs, theta, tau) = splitIfaceSigmaTy mono_ty + (tvs, theta, tau) = splitIfaceSigmaTy poly_ty name_doc = pprPrefixIfDeclBndr (ss_how_much ss) (occName tc) -- See Note [Printing type abbreviations] in GHC.Iface.Type @@ -1232,6 +1231,18 @@ pprIfaceDeclHead suppress_sig context ss tc_occ bndrs <+> pprIfaceTyConBinders suppress_sig (suppressIfaceInvisibles (PrintExplicitKinds print_kinds) bndrs bndrs) ] +pprIfaceDeclHeadInvis :: SuppressBndrSig + -> IfaceContext -> ShowSub -> Name + -> [IfaceTyConBinder] -- of the tycon, for invisible-suppression + -> IfaceType -- RHS + -> SDoc +pprIfaceDeclHeadInvis suppress_sig context ss tc_occ bndrs rhs + = sdocOption sdocPrintExplicitKinds $ \print_kinds -> + sep [ pprIfaceContextArr context + , pprPrefixIfDeclBndr (ss_how_much ss) (occName tc_occ) + <+> pprIfaceTyConBinders suppress_sig + (suppressIfaceInsignificantInvisibles (PrintExplicitKinds print_kinds) rhs bndrs) ] + pprIfaceConDecl :: ShowSub -> Bool -> IfaceTopBndr -> [IfaceTyConBinder] ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -54,7 +54,7 @@ module GHC.Iface.Type ( pprIfaceCoTcApp, pprTyTcApp, pprIfacePrefixApp, isIfaceRhoType, - suppressIfaceInvisibles, + suppressIfaceInvisibles, suppressIfaceInsignificantInvisibles, stripIfaceInvisVars, stripInvisArgs, @@ -521,6 +521,26 @@ suppressIfaceInvisibles (PrintExplicitKinds False) tys xs = suppress tys xs | isInvisibleTyConBinder k = suppress ks xs | otherwise = x : suppress ks xs +-- Invisible binder is considered significant when it meet at least +-- one of two following criteria: +-- - It visibly occurs in the RHS type +-- - It is not followed by a visible binder, so it +-- affects arity of type synonym +suppressIfaceInsignificantInvisibles :: PrintExplicitKinds -> IfaceType -> [IfaceTyConBinder] -> [IfaceTyConBinder] +suppressIfaceInsignificantInvisibles (PrintExplicitKinds True) _rhs tys = tys +suppressIfaceInsignificantInvisibles (PrintExplicitKinds False) rhs tys = suppress [] tys + where + mentioned_var var = ifTyConBinderName var `ifTypeVarVisiblyOccurs` rhs + + mentioned_vars vars = + filter mentioned_var vars + + suppress acc [] = reverse acc + suppress acc (k:ks) = case binderFlag k of + NamedTCB Specified -> suppress (k : acc) ks + NamedTCB Inferred -> suppress acc ks + _ -> reverse (mentioned_vars acc) ++ k : suppress [] ks + stripIfaceInvisVars :: PrintExplicitKinds -> [IfaceTyConBinder] -> [IfaceTyConBinder] stripIfaceInvisVars (PrintExplicitKinds True) tyvars = tyvars stripIfaceInvisVars (PrintExplicitKinds False) tyvars @@ -561,6 +581,27 @@ ifTypeIsVarFree ty = go ty go_args IA_Nil = True go_args (IA_Arg arg _ args) = go arg && go_args args +ifTypeVarVisiblyOccurs :: IfLclName -> IfaceType -> Bool +-- Returns True if the type contains this name. Doesn't count +-- invisible application +-- Just used to control pretty printing +ifTypeVarVisiblyOccurs name ty = go ty + where + go (IfaceTyVar var) = var == name + go (IfaceFreeTyVar {}) = False + go (IfaceAppTy fun args) = go fun || go_args args + go (IfaceFunTy _ w arg res) = go w || go arg || go res + go (IfaceForAllTy bndr ty) = go (ifaceBndrType (binderVar bndr)) || go ty + go (IfaceTyConApp _ args) = go_args args + go (IfaceTupleTy _ _ args) = go_args args + go (IfaceLitTy _) = False + go (IfaceCastTy {}) = False -- Safe + go (IfaceCoercionTy {}) = False -- Safe + + go_args IA_Nil = False + go_args (IA_Arg arg Required args) = go arg || go_args args + go_args (IA_Arg _arg _ args) = go_args args + {- Note [Substitution on IfaceType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Substitutions on IfaceType are done only during pretty-printing to ===================================== testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout ===================================== @@ -1,11 +1,11 @@ -Preprocessing library 'impl' for bkpcabal08-0.1.0.0... -Building library 'impl' for bkpcabal08-0.1.0.0... Preprocessing library 'p' for bkpcabal08-0.1.0.0... Building library 'p' instantiated with A = B = for bkpcabal08-0.1.0.0... [2 of 2] Compiling B[sig] ( p/B.hsig, nothing ) +Preprocessing library 'impl' for bkpcabal08-0.1.0.0... +Building library 'impl' for bkpcabal08-0.1.0.0... Preprocessing library 'q' for bkpcabal08-0.1.0.0... Building library 'q' instantiated with A = @@ -13,13 +13,13 @@ Building library 'q' instantiated with for bkpcabal08-0.1.0.0... [2 of 4] Compiling B[sig] ( q/B.hsig, nothing ) [3 of 4] Compiling M ( q/M.hs, nothing ) [A changed] -[4 of 4] Instantiating bkpcabal08-0.1.0.0-5O1mUtZZLBeDZEqqtwJcCj-p +[4 of 4] Instantiating bkpcabal08-0.1.0.0-CoQJNXLfoYQ4TyvApzFHv-p Preprocessing library 'q' for bkpcabal08-0.1.0.0... Building library 'q' instantiated with - A = bkpcabal08-0.1.0.0-DlVb5PcmUolGCHYbfTL7EP-impl:A - B = bkpcabal08-0.1.0.0-DlVb5PcmUolGCHYbfTL7EP-impl:B + A = bkpcabal08-0.1.0.0-5HJrxUERN7CD204UZeT4Ws-impl:A + B = bkpcabal08-0.1.0.0-5HJrxUERN7CD204UZeT4Ws-impl:B for bkpcabal08-0.1.0.0... -[1 of 3] Compiling A[sig] ( q/A.hsig, dist/build/bkpcabal08-0.1.0.0-LFiTKyjPqyn9yyuysCoVKg-q+5IA1jA4bEzCFcXtraqAC38/A.o ) [Prelude package changed] -[2 of 3] Compiling B[sig] ( q/B.hsig, dist/build/bkpcabal08-0.1.0.0-LFiTKyjPqyn9yyuysCoVKg-q+5IA1jA4bEzCFcXtraqAC38/B.o ) [Prelude package changed] +[1 of 3] Compiling A[sig] ( q/A.hsig, dist/build/bkpcabal08-0.1.0.0-1DQJ9DKc4h59P07qcb0kBc-q+J5mAfRWG9IgLmFQVftCb8t/A.o ) [Prelude package changed] +[2 of 3] Compiling B[sig] ( q/B.hsig, dist/build/bkpcabal08-0.1.0.0-1DQJ9DKc4h59P07qcb0kBc-q+J5mAfRWG9IgLmFQVftCb8t/B.o ) [Prelude package changed] Preprocessing library 'r' for bkpcabal08-0.1.0.0... Building library 'r' for bkpcabal08-0.1.0.0... ===================================== testsuite/tests/backpack/should_fail/T19244a.stderr ===================================== @@ -17,7 +17,7 @@ T19244a.bkp:22:9: error: [GHC-15843] • Type constructor ‘Key’ has conflicting definitions in the module and its hsig file. Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint + type Key = GHC.Classes.Ord Hsig file: type Key :: forall {k}. k -> Constraint class Key k1 The types have different kinds. ===================================== testsuite/tests/backpack/should_fail/T19244b.stderr ===================================== @@ -1,20 +1,20 @@ [1 of 3] Processing user - [1 of 2] Compiling Map[sig] ( user\Map.hsig, nothing ) - [2 of 2] Compiling User ( user\User.hs, nothing ) + [1 of 2] Compiling Map[sig] ( user/Map.hsig, nothing ) + [2 of 2] Compiling User ( user/User.hs, nothing ) [2 of 3] Processing ordmap Instantiating ordmap - [1 of 1] Compiling Map ( ordmap\Map.hs, T19244b.out\ordmap\Map.o ) + [1 of 1] Compiling Map ( ordmap/Map.hs, T19244b.out/ordmap/Map.o ) [3 of 3] Processing main Instantiating main [1 of 1] Including user[Map=ordmap:Map] Instantiating user[Map=ordmap:Map] - [1 of 2] Compiling Map[sig] ( user\Map.hsig, T19244b.out\user\user-GzloW2NeDdA2M0V8qzN4g2\Map.o ) + [1 of 2] Compiling Map[sig] ( user/Map.hsig, T19244b.out/user/user-GzloW2NeDdA2M0V8qzN4g2/Map.o ) T19244b.bkp:11:27: error: [GHC-15843] • Type constructor ‘Key’ has conflicting definitions in the module and its hsig file. Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint + type Key = GHC.Classes.Ord Hsig file: type Key :: forall {k}. k -> Constraint class Key k1 The types have different kinds. ===================================== testsuite/tests/backpack/should_fail/bkpfail46.stderr ===================================== @@ -1,20 +1,20 @@ [1 of 3] Processing p - [1 of 2] Compiling A[sig] ( p\A.hsig, nothing ) - [2 of 2] Compiling M ( p\M.hs, nothing ) + [1 of 2] Compiling A[sig] ( p/A.hsig, nothing ) + [2 of 2] Compiling M ( p/M.hs, nothing ) [2 of 3] Processing q Instantiating q - [1 of 1] Compiling A ( q\A.hs, bkpfail46.out\q\A.o ) + [1 of 1] Compiling A ( q/A.hs, bkpfail46.out/q/A.o ) [3 of 3] Processing r Instantiating r [1 of 1] Including p[A=q:A] Instantiating p[A=q:A] - [1 of 2] Compiling A[sig] ( p\A.hsig, bkpfail46.out\p\p-HVmFlcYSefiK5n1aDP1v7x\A.o ) + [1 of 2] Compiling A[sig] ( p/A.hsig, bkpfail46.out/p/p-HVmFlcYSefiK5n1aDP1v7x/A.o ) bkpfail46.bkp:16:9: error: [GHC-15843] • Type constructor ‘K’ has conflicting definitions in the module and its hsig file. Main module: type K :: * -> Constraint - type K a = GHC.Classes.Eq a :: Constraint + type K a = GHC.Classes.Eq a Hsig file: type K :: * -> Constraint class K a Illegal parameterized type synonym in implementation of abstract data. ===================================== testsuite/tests/ghci/T18060/T18060.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout ===================================== @@ -74,13 +74,13 @@ data Tuple2# a b = (#,#) a b (# , #) :: a -> b -> Tuple2# a b (Int, Int) :: Tuple2 (*) (*) type T :: Tuple2 (*) (*) -type T = (Int, Int) :: Tuple2 (*) (*) +type T = (Int, Int) -- Defined at :18:1 type S :: Solo (*) -type S = MkSolo Int :: Solo (*) +type S = MkSolo Int -- Defined at :19:1 type L :: List (*) -type L = [Int] :: List (*) +type L = [Int] -- Defined at :20:1 f :: Int -> Tuple2 Int Int -> Int (\ (_, _) -> ()) :: Tuple2 a b -> Unit ===================================== testsuite/tests/ghci/scripts/T15941.stdout ===================================== @@ -1,4 +1,3 @@ type T :: * -> * -> * -type T = - (->) @{GHC.Types.LiftedRep} @{GHC.Types.LiftedRep} :: * -> * -> * +type T = (->) @{GHC.Types.LiftedRep} @{GHC.Types.LiftedRep} -- Defined at :2:1 ===================================== testsuite/tests/ghci/scripts/T19310.stdout ===================================== @@ -1,3 +1,3 @@ type T :: * -> * -> * -type T = (->) @{LiftedRep} @{LiftedRep} :: * -> * -> * +type T = (->) @{LiftedRep} @{LiftedRep} -- Defined at :3:1 ===================================== testsuite/tests/ghci/scripts/T21294a.stdout ===================================== @@ -1,5 +1,5 @@ type L0 :: * -> * -type L0 = [] :: * -> * +type L0 = [] -- Defined at :1:1 type L1 :: * -> * type L1 a = [a] ===================================== testsuite/tests/ghci/scripts/T24459.script ===================================== @@ -0,0 +1,36 @@ +:set -XTypeAbstractions + +:{ +import Data.Kind +import Data.Data + + +type T6 :: forall k. Type -> Type +type T6 _a = () + +type T5 :: forall a. Type -> Type +type T5 @a _b = Proxy _b + +type T4 :: forall a. Type -> Type +type T4 @a _b = Proxy a + +type T3 :: forall k. k -> Type +type T3 a = Proxy a + +type T2 :: forall k. k -> Type +type T2 @k = Proxy + +type T1 :: forall k. k -> Type +type T1 = Proxy + +type T0 :: forall k. k -> Type +type T0 = Proxy :: forall k. k -> Type +:} + +:i T0 +:i T1 +:i T2 +:i T3 +:i T4 +:i T5 +:i T6 ===================================== testsuite/tests/ghci/scripts/T24459.stdout ===================================== @@ -0,0 +1,21 @@ +type T0 :: forall k. k -> * +type T0 = Proxy + -- Defined at :27:1 +type T1 :: forall k. k -> * +type T1 = Proxy + -- Defined at :24:1 +type T2 :: forall k. k -> * +type T2 @k = Proxy + -- Defined at :21:1 +type T3 :: forall k. k -> * +type T3 a = Proxy a + -- Defined at :18:1 +type T4 :: forall {k} (a :: k). * -> * +type T4 @a _b = Proxy a + -- Defined at :15:1 +type T5 :: forall {k} (a :: k). * -> * +type T5 _b = Proxy _b + -- Defined at :12:1 +type T6 :: forall {k} (k1 :: k). * -> * +type T6 _a = () + -- Defined at :9:1 ===================================== testsuite/tests/ghci/scripts/T8535.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/scripts/T9181.stdout ===================================== @@ -13,12 +13,10 @@ type (GHC.Internal.Data.Type.Ord.<=) x y = GHC.Internal.TypeError.Assert (x GHC.Internal.Data.Type.Ord.<=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) - :: Constraint type (GHC.Internal.Data.Type.Ord.<=?) :: forall k. k -> k -> Bool type (GHC.Internal.Data.Type.Ord.<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) True True False - :: Bool type GHC.Internal.TypeLits.AppendSymbol :: GHC.Types.Symbol -> GHC.Types.Symbol -> GHC.Types.Symbol type family GHC.Internal.TypeLits.AppendSymbol a b ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -384,3 +384,4 @@ test('T23686', normal, ghci_script, ['T23686.script']) test('T13869', extra_files(['T13869a.hs', 'T13869b.hs']), ghci_script, ['T13869.script']) test('ListTuplePunsPpr', normal, ghci_script, ['ListTuplePunsPpr.script']) test('ListTuplePunsPprNoAbbrevTuple', [expect_broken(23135), limit_stdout_lines(13)], ghci_script, ['ListTuplePunsPprNoAbbrevTuple.script']) +test('T24459', normal, ghci_script, ['T24459.script']) ===================================== testsuite/tests/ghci/scripts/ghci020.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/should_run/T10145.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/should_run/T18594.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1760,27 +1760,27 @@ module Data.Type.Equality where module Data.Type.Ord where -- Safety: Safe type (<) :: forall {t}. t -> t -> Constraint - type (<) x y = GHC.Internal.TypeError.Assert (x t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = OrdCond (Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = OrdCond (Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type ( k -> GHC.Types.Bool - type () :: forall {t}. t -> t -> Constraint - type (>) x y = GHC.Internal.TypeError.Assert (x >? y) (GHC.Internal.Data.Type.Ord.GtErrMsg x y) :: Constraint + type (>) x y = GHC.Internal.TypeError.Assert (x >? y) (GHC.Internal.Data.Type.Ord.GtErrMsg x y) type (>=) :: forall {t}. t -> t -> Constraint - type (>=) x y = GHC.Internal.TypeError.Assert (x >=? y) (GHC.Internal.Data.Type.Ord.GeErrMsg x y) :: Constraint + type (>=) x y = GHC.Internal.TypeError.Assert (x >=? y) (GHC.Internal.Data.Type.Ord.GeErrMsg x y) type (>=?) :: forall k. k -> k -> GHC.Types.Bool - type (>=?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.True GHC.Types.True :: GHC.Types.Bool + type (>=?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.True GHC.Types.True type (>?) :: forall k. k -> k -> GHC.Types.Bool - type (>?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.False GHC.Types.True :: GHC.Types.Bool + type (>?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.False GHC.Types.True type Compare :: forall k. k -> k -> GHC.Types.Ordering type family Compare a b type Max :: forall k. k -> k -> k - type Max m n = OrdCond (Compare m n) n n m :: k + type Max m n = OrdCond (Compare m n) n n m type Min :: forall k. k -> k -> k - type Min m n = OrdCond (Compare m n) m m n :: k + type Min m n = OrdCond (Compare m n) m m n type OrdCond :: forall k. GHC.Types.Ordering -> k -> k -> k -> k type family OrdCond o lt eq gt where forall k (lt :: k) (eq :: k) (gt :: k). OrdCond GHC.Types.LT lt eq gt = lt @@ -3315,7 +3315,7 @@ module GHC.Base where type Levity :: * data Levity = Lifted | Unlifted type LiftedRep :: RuntimeRep - type LiftedRep = BoxedRep Lifted :: RuntimeRep + type LiftedRep = BoxedRep Lifted type List :: * -> * data List a = ... type role MVar# nominal representational @@ -3428,7 +3428,7 @@ module GHC.Base where type TypeLitSort :: * data TypeLitSort = TypeLitSymbol | TypeLitNat | TypeLitChar type UnliftedRep :: RuntimeRep - type UnliftedRep = BoxedRep Unlifted :: RuntimeRep + type UnliftedRep = BoxedRep Unlifted type UnliftedType :: * type UnliftedType = TYPE UnliftedRep type VecCount :: * @@ -3438,7 +3438,7 @@ module GHC.Base where type Void :: * data Void type Void# :: ZeroBitType - type Void# = (# #) :: ZeroBitType + type Void# = (# #) type Weak# :: forall {l :: Levity}. TYPE (BoxedRep l) -> UnliftedType data Weak# a type WithDict :: Constraint -> * -> Constraint @@ -3484,7 +3484,7 @@ module GHC.Base where type WordBox :: TYPE WordRep -> * data WordBox a = MkWordBox a type ZeroBitRep :: RuntimeRep - type ZeroBitRep = TupleRep '[] :: RuntimeRep + type ZeroBitRep = TupleRep '[] type ZeroBitType :: * type ZeroBitType = TYPE ZeroBitRep absentErr :: forall a. a @@ -5513,7 +5513,7 @@ module GHC.Exts where type Levity :: * data Levity = Lifted | Unlifted type LiftedRep :: RuntimeRep - type LiftedRep = BoxedRep Lifted :: RuntimeRep + type LiftedRep = BoxedRep Lifted type List :: * -> * data List a = ... type role MVar# nominal representational @@ -5588,7 +5588,7 @@ module GHC.Exts where TypeLitNat :: GHC.Types.TypeLitSort TypeLitSymbol :: GHC.Types.TypeLitSort type UnliftedRep :: RuntimeRep - type UnliftedRep = BoxedRep Unlifted :: RuntimeRep + type UnliftedRep = BoxedRep Unlifted type UnliftedType :: * type UnliftedType = TYPE UnliftedRep type VecCount :: * @@ -5596,7 +5596,7 @@ module GHC.Exts where type VecElem :: * data VecElem = Int8ElemRep | Int16ElemRep | Int32ElemRep | Int64ElemRep | Word8ElemRep | Word16ElemRep | Word32ElemRep | Word64ElemRep | FloatElemRep | DoubleElemRep type Void# :: ZeroBitType - type Void# = (# #) :: ZeroBitType + type Void# = (# #) type Weak# :: forall {l :: Levity}. TYPE (BoxedRep l) -> UnliftedType data Weak# a type WithDict :: Constraint -> * -> Constraint @@ -5642,7 +5642,7 @@ module GHC.Exts where type WordBox :: TYPE WordRep -> * data WordBox a = MkWordBox a type ZeroBitRep :: RuntimeRep - type ZeroBitRep = TupleRep '[] :: RuntimeRep + type ZeroBitRep = TupleRep '[] type ZeroBitType :: * type ZeroBitType = TYPE ZeroBitRep acosDouble# :: Double# -> Double# @@ -7377,7 +7377,7 @@ module GHC.Generics where type C :: * data C type C1 :: forall {k}. Meta -> (k -> *) -> k -> * - type C1 = M1 C :: Meta -> (k -> *) -> k -> * + type C1 = M1 C type Constructor :: forall {k}. k -> Constraint class Constructor c where conName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t c f a -> [GHC.Types.Char] @@ -7387,7 +7387,7 @@ module GHC.Generics where type D :: * data D type D1 :: forall {k}. Meta -> (k -> *) -> k -> * - type D1 = M1 D :: Meta -> (k -> *) -> k -> * + type D1 = M1 D type Datatype :: forall {k}. k -> Constraint class Datatype d where datatypeName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t d f a -> [GHC.Types.Char] @@ -7434,14 +7434,14 @@ module GHC.Generics where type R :: * data R type Rec0 :: forall {k}. * -> k -> * - type Rec0 = K1 R :: * -> k -> * + type Rec0 = K1 R type role Rec1 representational nominal type Rec1 :: forall k. (k -> *) -> k -> * newtype Rec1 f p = Rec1 {unRec1 :: f p} type S :: * data S type S1 :: forall {k}. Meta -> (k -> *) -> k -> * - type S1 = M1 S :: Meta -> (k -> *) -> k -> * + type S1 = M1 S type Selector :: forall {k}. k -> Constraint class Selector s where selName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t s f a -> [GHC.Types.Char] @@ -7458,24 +7458,24 @@ module GHC.Generics where data U1 p = U1 UAddr :: forall k (p :: k). GHC.Prim.Addr# -> URec (GHC.Internal.Ptr.Ptr ()) p type UAddr :: forall {k}. k -> * - type UAddr = URec (GHC.Internal.Ptr.Ptr ()) :: k -> * + type UAddr = URec (GHC.Internal.Ptr.Ptr ()) UChar :: forall k (p :: k). GHC.Prim.Char# -> URec GHC.Types.Char p type UChar :: forall {k}. k -> * - type UChar = URec GHC.Types.Char :: k -> * + type UChar = URec GHC.Types.Char UDouble :: forall k (p :: k). GHC.Prim.Double# -> URec GHC.Types.Double p type UDouble :: forall {k}. k -> * - type UDouble = URec GHC.Types.Double :: k -> * + type UDouble = URec GHC.Types.Double UFloat :: forall k (p :: k). GHC.Prim.Float# -> URec GHC.Types.Float p type UFloat :: forall {k}. k -> * - type UFloat = URec GHC.Types.Float :: k -> * + type UFloat = URec GHC.Types.Float UInt :: forall k (p :: k). GHC.Prim.Int# -> URec GHC.Types.Int p type UInt :: forall {k}. k -> * - type UInt = URec GHC.Types.Int :: k -> * + type UInt = URec GHC.Types.Int type URec :: forall k. * -> k -> * data family URec a p UWord :: forall k (p :: k). GHC.Prim.Word# -> URec GHC.Types.Word p type UWord :: forall {k}. k -> * - type UWord = URec GHC.Types.Word :: k -> * + type UWord = URec GHC.Types.Word type role V1 phantom type V1 :: forall k. k -> * data V1 p @@ -8563,7 +8563,7 @@ module GHC.Num.BigNat where type BigNat :: * data BigNat = BN# {unBigNat :: BigNat#} type BigNat# :: GHC.Types.UnliftedType - type BigNat# = GHC.Num.WordArray.WordArray# :: GHC.Types.UnliftedType + type BigNat# = GHC.Num.WordArray.WordArray# bigNatAdd :: BigNat# -> BigNat# -> BigNat# bigNatAddWord :: BigNat# -> GHC.Types.Word -> BigNat# bigNatAddWord# :: BigNat# -> GHC.Prim.Word# -> BigNat# @@ -9345,7 +9345,7 @@ module GHC.Stack where type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint - type HasCallStack = ?callStack::CallStack :: Constraint + type HasCallStack = ?callStack::CallStack type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack @@ -9406,7 +9406,7 @@ module GHC.Stack.Types where type CallStack :: * data CallStack = EmptyCallStack | PushCallStack [GHC.Types.Char] SrcLoc CallStack | FreezeCallStack CallStack type HasCallStack :: Constraint - type HasCallStack = ?callStack::CallStack :: Constraint + type HasCallStack = ?callStack::CallStack type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} emptyCallStack :: CallStack @@ -9561,9 +9561,9 @@ module GHC.TypeLits where type (-) :: Natural -> Natural -> Natural type family (-) a b type (<=) :: forall {t}. t -> t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type AppendSymbol :: Symbol -> Symbol -> Symbol type family AppendSymbol a b type CharToNat :: GHC.Types.Char -> Natural @@ -9680,9 +9680,9 @@ module GHC.TypeNats where type (-) :: Natural -> Natural -> Natural type family (-) a b type (<=) :: forall {t}. t -> t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type CmpNat :: Natural -> Natural -> GHC.Types.Ordering type family CmpNat a b type Div :: Natural -> Natural -> Natural ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -1480,9 +1480,9 @@ module Data.Tuple.Experimental where class a => CSolo a {-# MINIMAL #-} type CTuple0 :: Constraint - type CTuple0 = () :: Constraint :: Constraint + type CTuple0 = () :: Constraint type CTuple1 :: Constraint -> Constraint - type CTuple1 = CSolo :: Constraint -> Constraint + type CTuple1 = CSolo type CTuple10 :: Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint class (a, b, c, d, e, f, g, h, i, j) => CTuple10 a b c d e f g h i j {-# MINIMAL #-} @@ -2637,11 +2637,11 @@ module Data.Tuple.Experimental where type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType - type Tuple0# = (# #) :: GHC.Types.ZeroBitType + type Tuple0# = (# #) type Tuple1 :: * -> * - type Tuple1 = Solo :: * -> * + type Tuple1 = Solo type Tuple1# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) - type Tuple1# = Solo# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) + type Tuple1# = Solo# type Tuple10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * data Tuple10 a b c d e f g h i j = ... type Tuple10# :: forall (k0 :: GHC.Types.RuntimeRep) (k1 :: GHC.Types.RuntimeRep) (k2 :: GHC.Types.RuntimeRep) (k3 :: GHC.Types.RuntimeRep) (k4 :: GHC.Types.RuntimeRep) (k5 :: GHC.Types.RuntimeRep) (k6 :: GHC.Types.RuntimeRep) (k7 :: GHC.Types.RuntimeRep) (k8 :: GHC.Types.RuntimeRep) (k9 :: GHC.Types.RuntimeRep). TYPE k0 -> TYPE k1 -> TYPE k2 -> TYPE k3 -> TYPE k4 -> TYPE k5 -> TYPE k6 -> TYPE k7 -> TYPE k8 -> TYPE k9 -> TYPE (GHC.Types.TupleRep [k0, k1, k2, k3, k4, k5, k6, k7, k8, k9]) @@ -4328,9 +4328,9 @@ module Prelude.Experimental where class a => CSolo a {-# MINIMAL #-} type CTuple0 :: Constraint - type CTuple0 = () :: Constraint :: Constraint + type CTuple0 = () :: Constraint type CTuple1 :: Constraint -> Constraint - type CTuple1 = CSolo :: Constraint -> Constraint + type CTuple1 = CSolo type CTuple10 :: Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint class (a, b, c, d, e, f, g, h, i, j) => CTuple10 a b c d e f g h i j {-# MINIMAL #-} @@ -6959,11 +6959,11 @@ module Prelude.Experimental where type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType - type Tuple0# = (# #) :: GHC.Types.ZeroBitType + type Tuple0# = (# #) type Tuple1 :: * -> * - type Tuple1 = Solo :: * -> * + type Tuple1 = Solo type Tuple1# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) - type Tuple1# = Solo# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) + type Tuple1# = Solo# type Tuple10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * data Tuple10 a b c d e f g h i j = ... type Tuple10# :: forall (k0 :: GHC.Types.RuntimeRep) (k1 :: GHC.Types.RuntimeRep) (k2 :: GHC.Types.RuntimeRep) (k3 :: GHC.Types.RuntimeRep) (k4 :: GHC.Types.RuntimeRep) (k5 :: GHC.Types.RuntimeRep) (k6 :: GHC.Types.RuntimeRep) (k7 :: GHC.Types.RuntimeRep) (k8 :: GHC.Types.RuntimeRep) (k9 :: GHC.Types.RuntimeRep). TYPE k0 -> TYPE k1 -> TYPE k2 -> TYPE k3 -> TYPE k4 -> TYPE k5 -> TYPE k6 -> TYPE k7 -> TYPE k8 -> TYPE k9 -> TYPE (GHC.Types.TupleRep [k0, k1, k2, k3, k4, k5, k6, k7, k8, k9]) ===================================== testsuite/tests/rep-poly/RepPolyBackpack3.stderr ===================================== @@ -1,19 +1,19 @@ [1 of 3] Processing sig - [1 of 1] Compiling Sig[sig] ( sig\Sig.hsig, nothing ) + [1 of 1] Compiling Sig[sig] ( sig/Sig.hsig, nothing ) [2 of 3] Processing impl Instantiating impl - [1 of 1] Compiling Impl ( impl\Impl.hs, RepPolyBackpack3.out\impl\Impl.o ) + [1 of 1] Compiling Impl ( impl/Impl.hs, RepPolyBackpack3.out/impl/Impl.o ) [3 of 3] Processing main Instantiating main [1 of 1] Including sig[Sig=impl:Impl] Instantiating sig[Sig=impl:Impl] - [1 of 1] Compiling Sig[sig] ( sig\Sig.hsig, RepPolyBackpack3.out\sig\sig-Absk5cIXTXe6UYhGMYGber\Sig.o ) + [1 of 1] Compiling Sig[sig] ( sig/Sig.hsig, RepPolyBackpack3.out/sig/sig-Absk5cIXTXe6UYhGMYGber/Sig.o ) RepPolyBackpack3.bkp:17:5: error: [GHC-15843] • Type constructor ‘Rep’ has conflicting definitions in the module and its hsig file. Main module: type Rep :: GHC.Types.RuntimeRep - type Rep = T :: GHC.Types.RuntimeRep + type Rep = T Hsig file: type Rep :: GHC.Types.RuntimeRep data Rep Illegal implementation of abstract data: Invalid type family ‘T’. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1fc7d5a7a281fffcdc83600eefe705f050b5b273 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1fc7d5a7a281fffcdc83600eefe705f050b5b273 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 07:29:25 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Tue, 12 Mar 2024 03:29:25 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/tysyn-info-ppr] Update GHCi :info type synonym printing (24459) Message-ID: <65f0045593890_25db4e8996d1483312@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/tysyn-info-ppr at Glasgow Haskell Compiler / GHC Commits: 6227a9ce by Andrei Borzenkov at 2024-03-12T11:29:03+04:00 Update GHCi :info type synonym printing (24459) - Do not print result's kind since we have full kind in SAKS and we display invisible arity using @-binders - Do not suppress significant invisible binders Invisible binder is considered significant when it meets at least one of two following criteria: - It visibly occurs in the RHS type - It is not followed by a visible binder, so it affects arity of type synonym - - - - - 23 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout - testsuite/tests/backpack/should_fail/T19244a.stderr - testsuite/tests/backpack/should_fail/T19244b.stderr - testsuite/tests/backpack/should_fail/bkpfail46.stderr - testsuite/tests/ghci/T18060/T18060.stdout - testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout - testsuite/tests/ghci/scripts/T15941.stdout - testsuite/tests/ghci/scripts/T19310.stdout - testsuite/tests/ghci/scripts/T21294a.stdout - + testsuite/tests/ghci/scripts/T24459.script - + testsuite/tests/ghci/scripts/T24459.stdout - testsuite/tests/ghci/scripts/T8535.stdout - testsuite/tests/ghci/scripts/T9181.stdout - testsuite/tests/ghci/scripts/all.T - testsuite/tests/ghci/scripts/ghci020.stdout - testsuite/tests/ghci/should_run/T10145.stdout - testsuite/tests/ghci/should_run/T18594.stdout - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/rep-poly/RepPolyBackpack3.stderr Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -25,7 +25,7 @@ module GHC.Core.TyCon( mkRequiredTyConBinder, mkAnonTyConBinder, mkAnonTyConBinders, tyConBinderForAllTyFlag, tyConBndrVisForAllTyFlag, isNamedTyConBinder, - isVisibleTyConBinder, isInvisibleTyConBinder, + isVisibleTyConBinder, isInvisSpecTyConBinder, isInvisibleTyConBinder, isVisibleTcbVis, isInvisSpecTcbVis, -- ** Field labels @@ -514,6 +514,10 @@ isInvisSpecTcbVis :: TyConBndrVis -> Bool isInvisSpecTcbVis (NamedTCB Specified) = True isInvisSpecTcbVis _ = False +isInvisSpecTyConBinder :: VarBndr tv TyConBndrVis -> Bool +-- Works for IfaceTyConBinder too +isInvisSpecTyConBinder (Bndr _ tcb_vis) = isInvisSpecTcbVis tcb_vis + isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool -- Works for IfaceTyConBinder too isInvisibleTyConBinder tcb = not (isVisibleTyConBinder tcb) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1033,15 +1033,14 @@ pprIfaceDecl ss (IfaceClass { ifName = clas pprIfaceDecl ss (IfaceSynonym { ifName = tc , ifBinders = binders - , ifSynRhs = mono_ty + , ifSynRhs = poly_ty , ifResKind = res_kind}) = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind) - , hang (text "type" <+> pprIfaceDeclHead suppress_bndr_sig [] ss tc binders <+> equals) - 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau - , ppUnless (isIfaceLiftedTypeKind res_kind) (dcolon <+> ppr res_kind) ]) + , hang (text "type" <+> pprIfaceDeclHeadInvis suppress_bndr_sig [] ss tc binders tau <+> equals) + 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau ]) ] where - (tvs, theta, tau) = splitIfaceSigmaTy mono_ty + (tvs, theta, tau) = splitIfaceSigmaTy poly_ty name_doc = pprPrefixIfDeclBndr (ss_how_much ss) (occName tc) -- See Note [Printing type abbreviations] in GHC.Iface.Type @@ -1232,6 +1231,18 @@ pprIfaceDeclHead suppress_sig context ss tc_occ bndrs <+> pprIfaceTyConBinders suppress_sig (suppressIfaceInvisibles (PrintExplicitKinds print_kinds) bndrs bndrs) ] +pprIfaceDeclHeadInvis :: SuppressBndrSig + -> IfaceContext -> ShowSub -> Name + -> [IfaceTyConBinder] -- of the tycon, for invisible-suppression + -> IfaceType -- RHS + -> SDoc +pprIfaceDeclHeadInvis suppress_sig context ss tc_occ bndrs rhs + = sdocOption sdocPrintExplicitKinds $ \print_kinds -> + sep [ pprIfaceContextArr context + , pprPrefixIfDeclBndr (ss_how_much ss) (occName tc_occ) + <+> pprIfaceTyConBinders suppress_sig + (suppressIfaceInsignificantInvisibles (PrintExplicitKinds print_kinds) rhs bndrs) ] + pprIfaceConDecl :: ShowSub -> Bool -> IfaceTopBndr -> [IfaceTyConBinder] ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -54,7 +54,7 @@ module GHC.Iface.Type ( pprIfaceCoTcApp, pprTyTcApp, pprIfacePrefixApp, isIfaceRhoType, - suppressIfaceInvisibles, + suppressIfaceInvisibles, suppressIfaceInsignificantInvisibles, stripIfaceInvisVars, stripInvisArgs, @@ -521,6 +521,26 @@ suppressIfaceInvisibles (PrintExplicitKinds False) tys xs = suppress tys xs | isInvisibleTyConBinder k = suppress ks xs | otherwise = x : suppress ks xs +-- Invisible binder is considered significant when it meet at least +-- one of two following criteria: +-- - It visibly occurs in the RHS type +-- - It is not followed by a visible binder, so it +-- affects arity of type synonym +suppressIfaceInsignificantInvisibles :: PrintExplicitKinds -> IfaceType -> [IfaceTyConBinder] -> [IfaceTyConBinder] +suppressIfaceInsignificantInvisibles (PrintExplicitKinds True) _rhs tys = tys +suppressIfaceInsignificantInvisibles (PrintExplicitKinds False) rhs tys = suppress [] tys + where + mentioned_var var = ifTyConBinderName var `ifTypeVarVisiblyOccurs` rhs + + mentioned_vars vars = + filter mentioned_var vars + + suppress acc [] = reverse acc + suppress acc (k:ks) = case binderFlag k of + NamedTCB Specified -> suppress (k : acc) ks + NamedTCB Inferred -> suppress acc ks + _ -> reverse (mentioned_vars acc) ++ k : suppress [] ks + stripIfaceInvisVars :: PrintExplicitKinds -> [IfaceTyConBinder] -> [IfaceTyConBinder] stripIfaceInvisVars (PrintExplicitKinds True) tyvars = tyvars stripIfaceInvisVars (PrintExplicitKinds False) tyvars @@ -561,6 +581,27 @@ ifTypeIsVarFree ty = go ty go_args IA_Nil = True go_args (IA_Arg arg _ args) = go arg && go_args args +ifTypeVarVisiblyOccurs :: IfLclName -> IfaceType -> Bool +-- Returns True if the type contains this name. Doesn't count +-- invisible application +-- Just used to control pretty printing +ifTypeVarVisiblyOccurs name ty = go ty + where + go (IfaceTyVar var) = var == name + go (IfaceFreeTyVar {}) = False + go (IfaceAppTy fun args) = go fun || go_args args + go (IfaceFunTy _ w arg res) = go w || go arg || go res + go (IfaceForAllTy bndr ty) = go (ifaceBndrType (binderVar bndr)) || go ty + go (IfaceTyConApp _ args) = go_args args + go (IfaceTupleTy _ _ args) = go_args args + go (IfaceLitTy _) = False + go (IfaceCastTy {}) = False -- Safe + go (IfaceCoercionTy {}) = False -- Safe + + go_args IA_Nil = False + go_args (IA_Arg arg Required args) = go arg || go_args args + go_args (IA_Arg _arg _ args) = go_args args + {- Note [Substitution on IfaceType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Substitutions on IfaceType are done only during pretty-printing to ===================================== testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout ===================================== @@ -1,11 +1,11 @@ -Preprocessing library 'impl' for bkpcabal08-0.1.0.0... -Building library 'impl' for bkpcabal08-0.1.0.0... Preprocessing library 'p' for bkpcabal08-0.1.0.0... Building library 'p' instantiated with A = B = for bkpcabal08-0.1.0.0... [2 of 2] Compiling B[sig] ( p/B.hsig, nothing ) +Preprocessing library 'impl' for bkpcabal08-0.1.0.0... +Building library 'impl' for bkpcabal08-0.1.0.0... Preprocessing library 'q' for bkpcabal08-0.1.0.0... Building library 'q' instantiated with A = @@ -13,13 +13,13 @@ Building library 'q' instantiated with for bkpcabal08-0.1.0.0... [2 of 4] Compiling B[sig] ( q/B.hsig, nothing ) [3 of 4] Compiling M ( q/M.hs, nothing ) [A changed] -[4 of 4] Instantiating bkpcabal08-0.1.0.0-5O1mUtZZLBeDZEqqtwJcCj-p +[4 of 4] Instantiating bkpcabal08-0.1.0.0-CoQJNXLfoYQ4TyvApzFHv-p Preprocessing library 'q' for bkpcabal08-0.1.0.0... Building library 'q' instantiated with - A = bkpcabal08-0.1.0.0-DlVb5PcmUolGCHYbfTL7EP-impl:A - B = bkpcabal08-0.1.0.0-DlVb5PcmUolGCHYbfTL7EP-impl:B + A = bkpcabal08-0.1.0.0-5HJrxUERN7CD204UZeT4Ws-impl:A + B = bkpcabal08-0.1.0.0-5HJrxUERN7CD204UZeT4Ws-impl:B for bkpcabal08-0.1.0.0... -[1 of 3] Compiling A[sig] ( q/A.hsig, dist/build/bkpcabal08-0.1.0.0-LFiTKyjPqyn9yyuysCoVKg-q+5IA1jA4bEzCFcXtraqAC38/A.o ) [Prelude package changed] -[2 of 3] Compiling B[sig] ( q/B.hsig, dist/build/bkpcabal08-0.1.0.0-LFiTKyjPqyn9yyuysCoVKg-q+5IA1jA4bEzCFcXtraqAC38/B.o ) [Prelude package changed] +[1 of 3] Compiling A[sig] ( q/A.hsig, dist/build/bkpcabal08-0.1.0.0-1DQJ9DKc4h59P07qcb0kBc-q+J5mAfRWG9IgLmFQVftCb8t/A.o ) [Prelude package changed] +[2 of 3] Compiling B[sig] ( q/B.hsig, dist/build/bkpcabal08-0.1.0.0-1DQJ9DKc4h59P07qcb0kBc-q+J5mAfRWG9IgLmFQVftCb8t/B.o ) [Prelude package changed] Preprocessing library 'r' for bkpcabal08-0.1.0.0... Building library 'r' for bkpcabal08-0.1.0.0... ===================================== testsuite/tests/backpack/should_fail/T19244a.stderr ===================================== @@ -17,7 +17,7 @@ T19244a.bkp:22:9: error: [GHC-15843] • Type constructor ‘Key’ has conflicting definitions in the module and its hsig file. Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint + type Key = GHC.Classes.Ord Hsig file: type Key :: forall {k}. k -> Constraint class Key k1 The types have different kinds. ===================================== testsuite/tests/backpack/should_fail/T19244b.stderr ===================================== @@ -1,20 +1,20 @@ [1 of 3] Processing user - [1 of 2] Compiling Map[sig] ( user\Map.hsig, nothing ) - [2 of 2] Compiling User ( user\User.hs, nothing ) + [1 of 2] Compiling Map[sig] ( user/Map.hsig, nothing ) + [2 of 2] Compiling User ( user/User.hs, nothing ) [2 of 3] Processing ordmap Instantiating ordmap - [1 of 1] Compiling Map ( ordmap\Map.hs, T19244b.out\ordmap\Map.o ) + [1 of 1] Compiling Map ( ordmap/Map.hs, T19244b.out/ordmap/Map.o ) [3 of 3] Processing main Instantiating main [1 of 1] Including user[Map=ordmap:Map] Instantiating user[Map=ordmap:Map] - [1 of 2] Compiling Map[sig] ( user\Map.hsig, T19244b.out\user\user-GzloW2NeDdA2M0V8qzN4g2\Map.o ) + [1 of 2] Compiling Map[sig] ( user/Map.hsig, T19244b.out/user/user-GzloW2NeDdA2M0V8qzN4g2/Map.o ) T19244b.bkp:11:27: error: [GHC-15843] • Type constructor ‘Key’ has conflicting definitions in the module and its hsig file. Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint + type Key = GHC.Classes.Ord Hsig file: type Key :: forall {k}. k -> Constraint class Key k1 The types have different kinds. ===================================== testsuite/tests/backpack/should_fail/bkpfail46.stderr ===================================== @@ -1,20 +1,20 @@ [1 of 3] Processing p - [1 of 2] Compiling A[sig] ( p\A.hsig, nothing ) - [2 of 2] Compiling M ( p\M.hs, nothing ) + [1 of 2] Compiling A[sig] ( p/A.hsig, nothing ) + [2 of 2] Compiling M ( p/M.hs, nothing ) [2 of 3] Processing q Instantiating q - [1 of 1] Compiling A ( q\A.hs, bkpfail46.out\q\A.o ) + [1 of 1] Compiling A ( q/A.hs, bkpfail46.out/q/A.o ) [3 of 3] Processing r Instantiating r [1 of 1] Including p[A=q:A] Instantiating p[A=q:A] - [1 of 2] Compiling A[sig] ( p\A.hsig, bkpfail46.out\p\p-HVmFlcYSefiK5n1aDP1v7x\A.o ) + [1 of 2] Compiling A[sig] ( p/A.hsig, bkpfail46.out/p/p-HVmFlcYSefiK5n1aDP1v7x/A.o ) bkpfail46.bkp:16:9: error: [GHC-15843] • Type constructor ‘K’ has conflicting definitions in the module and its hsig file. Main module: type K :: * -> Constraint - type K a = GHC.Classes.Eq a :: Constraint + type K a = GHC.Classes.Eq a Hsig file: type K :: * -> Constraint class K a Illegal parameterized type synonym in implementation of abstract data. ===================================== testsuite/tests/ghci/T18060/T18060.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout ===================================== @@ -74,13 +74,13 @@ data Tuple2# a b = (#,#) a b (# , #) :: a -> b -> Tuple2# a b (Int, Int) :: Tuple2 (*) (*) type T :: Tuple2 (*) (*) -type T = (Int, Int) :: Tuple2 (*) (*) +type T = (Int, Int) -- Defined at :18:1 type S :: Solo (*) -type S = MkSolo Int :: Solo (*) +type S = MkSolo Int -- Defined at :19:1 type L :: List (*) -type L = [Int] :: List (*) +type L = [Int] -- Defined at :20:1 f :: Int -> Tuple2 Int Int -> Int (\ (_, _) -> ()) :: Tuple2 a b -> Unit ===================================== testsuite/tests/ghci/scripts/T15941.stdout ===================================== @@ -1,4 +1,3 @@ type T :: * -> * -> * -type T = - (->) @{GHC.Types.LiftedRep} @{GHC.Types.LiftedRep} :: * -> * -> * +type T = (->) @{GHC.Types.LiftedRep} @{GHC.Types.LiftedRep} -- Defined at :2:1 ===================================== testsuite/tests/ghci/scripts/T19310.stdout ===================================== @@ -1,3 +1,3 @@ type T :: * -> * -> * -type T = (->) @{LiftedRep} @{LiftedRep} :: * -> * -> * +type T = (->) @{LiftedRep} @{LiftedRep} -- Defined at :3:1 ===================================== testsuite/tests/ghci/scripts/T21294a.stdout ===================================== @@ -1,5 +1,5 @@ type L0 :: * -> * -type L0 = [] :: * -> * +type L0 = [] -- Defined at :1:1 type L1 :: * -> * type L1 a = [a] ===================================== testsuite/tests/ghci/scripts/T24459.script ===================================== @@ -0,0 +1,36 @@ +:set -XTypeAbstractions + +:{ +import Data.Kind +import Data.Data + + +type T6 :: forall k. Type -> Type +type T6 _a = () + +type T5 :: forall a. Type -> Type +type T5 @a _b = Proxy _b + +type T4 :: forall a. Type -> Type +type T4 @a _b = Proxy a + +type T3 :: forall k. k -> Type +type T3 a = Proxy a + +type T2 :: forall k. k -> Type +type T2 @k = Proxy + +type T1 :: forall k. k -> Type +type T1 = Proxy + +type T0 :: forall k. k -> Type +type T0 = Proxy :: forall k. k -> Type +:} + +:i T0 +:i T1 +:i T2 +:i T3 +:i T4 +:i T5 +:i T6 ===================================== testsuite/tests/ghci/scripts/T24459.stdout ===================================== @@ -0,0 +1,21 @@ +type T0 :: forall k. k -> * +type T0 = Proxy + -- Defined at :27:1 +type T1 :: forall k. k -> * +type T1 = Proxy + -- Defined at :24:1 +type T2 :: forall k. k -> * +type T2 @k = Proxy + -- Defined at :21:1 +type T3 :: forall k. k -> * +type T3 a = Proxy a + -- Defined at :18:1 +type T4 :: forall {k} (a :: k). * -> * +type T4 @a _b = Proxy a + -- Defined at :15:1 +type T5 :: forall {k} (a :: k). * -> * +type T5 _b = Proxy _b + -- Defined at :12:1 +type T6 :: forall {k} (k1 :: k). * -> * +type T6 _a = () + -- Defined at :9:1 ===================================== testsuite/tests/ghci/scripts/T8535.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/scripts/T9181.stdout ===================================== @@ -13,12 +13,10 @@ type (GHC.Internal.Data.Type.Ord.<=) x y = GHC.Internal.TypeError.Assert (x GHC.Internal.Data.Type.Ord.<=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) - :: Constraint type (GHC.Internal.Data.Type.Ord.<=?) :: forall k. k -> k -> Bool type (GHC.Internal.Data.Type.Ord.<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) True True False - :: Bool type GHC.Internal.TypeLits.AppendSymbol :: GHC.Types.Symbol -> GHC.Types.Symbol -> GHC.Types.Symbol type family GHC.Internal.TypeLits.AppendSymbol a b ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -384,3 +384,4 @@ test('T23686', normal, ghci_script, ['T23686.script']) test('T13869', extra_files(['T13869a.hs', 'T13869b.hs']), ghci_script, ['T13869.script']) test('ListTuplePunsPpr', normal, ghci_script, ['ListTuplePunsPpr.script']) test('ListTuplePunsPprNoAbbrevTuple', [expect_broken(23135), limit_stdout_lines(13)], ghci_script, ['ListTuplePunsPprNoAbbrevTuple.script']) +test('T24459', normal, ghci_script, ['T24459.script']) ===================================== testsuite/tests/ghci/scripts/ghci020.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/should_run/T10145.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/should_run/T18594.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1760,27 +1760,27 @@ module Data.Type.Equality where module Data.Type.Ord where -- Safety: Safe type (<) :: forall {t}. t -> t -> Constraint - type (<) x y = GHC.Internal.TypeError.Assert (x t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = OrdCond (Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = OrdCond (Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type ( k -> GHC.Types.Bool - type () :: forall {t}. t -> t -> Constraint - type (>) x y = GHC.Internal.TypeError.Assert (x >? y) (GHC.Internal.Data.Type.Ord.GtErrMsg x y) :: Constraint + type (>) x y = GHC.Internal.TypeError.Assert (x >? y) (GHC.Internal.Data.Type.Ord.GtErrMsg x y) type (>=) :: forall {t}. t -> t -> Constraint - type (>=) x y = GHC.Internal.TypeError.Assert (x >=? y) (GHC.Internal.Data.Type.Ord.GeErrMsg x y) :: Constraint + type (>=) x y = GHC.Internal.TypeError.Assert (x >=? y) (GHC.Internal.Data.Type.Ord.GeErrMsg x y) type (>=?) :: forall k. k -> k -> GHC.Types.Bool - type (>=?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.True GHC.Types.True :: GHC.Types.Bool + type (>=?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.True GHC.Types.True type (>?) :: forall k. k -> k -> GHC.Types.Bool - type (>?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.False GHC.Types.True :: GHC.Types.Bool + type (>?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.False GHC.Types.True type Compare :: forall k. k -> k -> GHC.Types.Ordering type family Compare a b type Max :: forall k. k -> k -> k - type Max m n = OrdCond (Compare m n) n n m :: k + type Max m n = OrdCond (Compare m n) n n m type Min :: forall k. k -> k -> k - type Min m n = OrdCond (Compare m n) m m n :: k + type Min m n = OrdCond (Compare m n) m m n type OrdCond :: forall k. GHC.Types.Ordering -> k -> k -> k -> k type family OrdCond o lt eq gt where forall k (lt :: k) (eq :: k) (gt :: k). OrdCond GHC.Types.LT lt eq gt = lt @@ -3315,7 +3315,7 @@ module GHC.Base where type Levity :: * data Levity = Lifted | Unlifted type LiftedRep :: RuntimeRep - type LiftedRep = BoxedRep Lifted :: RuntimeRep + type LiftedRep = BoxedRep Lifted type List :: * -> * data List a = ... type role MVar# nominal representational @@ -3428,7 +3428,7 @@ module GHC.Base where type TypeLitSort :: * data TypeLitSort = TypeLitSymbol | TypeLitNat | TypeLitChar type UnliftedRep :: RuntimeRep - type UnliftedRep = BoxedRep Unlifted :: RuntimeRep + type UnliftedRep = BoxedRep Unlifted type UnliftedType :: * type UnliftedType = TYPE UnliftedRep type VecCount :: * @@ -3438,7 +3438,7 @@ module GHC.Base where type Void :: * data Void type Void# :: ZeroBitType - type Void# = (# #) :: ZeroBitType + type Void# = (# #) type Weak# :: forall {l :: Levity}. TYPE (BoxedRep l) -> UnliftedType data Weak# a type WithDict :: Constraint -> * -> Constraint @@ -3484,7 +3484,7 @@ module GHC.Base where type WordBox :: TYPE WordRep -> * data WordBox a = MkWordBox a type ZeroBitRep :: RuntimeRep - type ZeroBitRep = TupleRep '[] :: RuntimeRep + type ZeroBitRep = TupleRep '[] type ZeroBitType :: * type ZeroBitType = TYPE ZeroBitRep absentErr :: forall a. a @@ -5513,7 +5513,7 @@ module GHC.Exts where type Levity :: * data Levity = Lifted | Unlifted type LiftedRep :: RuntimeRep - type LiftedRep = BoxedRep Lifted :: RuntimeRep + type LiftedRep = BoxedRep Lifted type List :: * -> * data List a = ... type role MVar# nominal representational @@ -5588,7 +5588,7 @@ module GHC.Exts where TypeLitNat :: GHC.Types.TypeLitSort TypeLitSymbol :: GHC.Types.TypeLitSort type UnliftedRep :: RuntimeRep - type UnliftedRep = BoxedRep Unlifted :: RuntimeRep + type UnliftedRep = BoxedRep Unlifted type UnliftedType :: * type UnliftedType = TYPE UnliftedRep type VecCount :: * @@ -5596,7 +5596,7 @@ module GHC.Exts where type VecElem :: * data VecElem = Int8ElemRep | Int16ElemRep | Int32ElemRep | Int64ElemRep | Word8ElemRep | Word16ElemRep | Word32ElemRep | Word64ElemRep | FloatElemRep | DoubleElemRep type Void# :: ZeroBitType - type Void# = (# #) :: ZeroBitType + type Void# = (# #) type Weak# :: forall {l :: Levity}. TYPE (BoxedRep l) -> UnliftedType data Weak# a type WithDict :: Constraint -> * -> Constraint @@ -5642,7 +5642,7 @@ module GHC.Exts where type WordBox :: TYPE WordRep -> * data WordBox a = MkWordBox a type ZeroBitRep :: RuntimeRep - type ZeroBitRep = TupleRep '[] :: RuntimeRep + type ZeroBitRep = TupleRep '[] type ZeroBitType :: * type ZeroBitType = TYPE ZeroBitRep acosDouble# :: Double# -> Double# @@ -7377,7 +7377,7 @@ module GHC.Generics where type C :: * data C type C1 :: forall {k}. Meta -> (k -> *) -> k -> * - type C1 = M1 C :: Meta -> (k -> *) -> k -> * + type C1 = M1 C type Constructor :: forall {k}. k -> Constraint class Constructor c where conName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t c f a -> [GHC.Types.Char] @@ -7387,7 +7387,7 @@ module GHC.Generics where type D :: * data D type D1 :: forall {k}. Meta -> (k -> *) -> k -> * - type D1 = M1 D :: Meta -> (k -> *) -> k -> * + type D1 = M1 D type Datatype :: forall {k}. k -> Constraint class Datatype d where datatypeName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t d f a -> [GHC.Types.Char] @@ -7434,14 +7434,14 @@ module GHC.Generics where type R :: * data R type Rec0 :: forall {k}. * -> k -> * - type Rec0 = K1 R :: * -> k -> * + type Rec0 = K1 R type role Rec1 representational nominal type Rec1 :: forall k. (k -> *) -> k -> * newtype Rec1 f p = Rec1 {unRec1 :: f p} type S :: * data S type S1 :: forall {k}. Meta -> (k -> *) -> k -> * - type S1 = M1 S :: Meta -> (k -> *) -> k -> * + type S1 = M1 S type Selector :: forall {k}. k -> Constraint class Selector s where selName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t s f a -> [GHC.Types.Char] @@ -7458,24 +7458,24 @@ module GHC.Generics where data U1 p = U1 UAddr :: forall k (p :: k). GHC.Prim.Addr# -> URec (GHC.Internal.Ptr.Ptr ()) p type UAddr :: forall {k}. k -> * - type UAddr = URec (GHC.Internal.Ptr.Ptr ()) :: k -> * + type UAddr = URec (GHC.Internal.Ptr.Ptr ()) UChar :: forall k (p :: k). GHC.Prim.Char# -> URec GHC.Types.Char p type UChar :: forall {k}. k -> * - type UChar = URec GHC.Types.Char :: k -> * + type UChar = URec GHC.Types.Char UDouble :: forall k (p :: k). GHC.Prim.Double# -> URec GHC.Types.Double p type UDouble :: forall {k}. k -> * - type UDouble = URec GHC.Types.Double :: k -> * + type UDouble = URec GHC.Types.Double UFloat :: forall k (p :: k). GHC.Prim.Float# -> URec GHC.Types.Float p type UFloat :: forall {k}. k -> * - type UFloat = URec GHC.Types.Float :: k -> * + type UFloat = URec GHC.Types.Float UInt :: forall k (p :: k). GHC.Prim.Int# -> URec GHC.Types.Int p type UInt :: forall {k}. k -> * - type UInt = URec GHC.Types.Int :: k -> * + type UInt = URec GHC.Types.Int type URec :: forall k. * -> k -> * data family URec a p UWord :: forall k (p :: k). GHC.Prim.Word# -> URec GHC.Types.Word p type UWord :: forall {k}. k -> * - type UWord = URec GHC.Types.Word :: k -> * + type UWord = URec GHC.Types.Word type role V1 phantom type V1 :: forall k. k -> * data V1 p @@ -8563,7 +8563,7 @@ module GHC.Num.BigNat where type BigNat :: * data BigNat = BN# {unBigNat :: BigNat#} type BigNat# :: GHC.Types.UnliftedType - type BigNat# = GHC.Num.WordArray.WordArray# :: GHC.Types.UnliftedType + type BigNat# = GHC.Num.WordArray.WordArray# bigNatAdd :: BigNat# -> BigNat# -> BigNat# bigNatAddWord :: BigNat# -> GHC.Types.Word -> BigNat# bigNatAddWord# :: BigNat# -> GHC.Prim.Word# -> BigNat# @@ -9345,7 +9345,7 @@ module GHC.Stack where type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint - type HasCallStack = ?callStack::CallStack :: Constraint + type HasCallStack = ?callStack::CallStack type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack @@ -9406,7 +9406,7 @@ module GHC.Stack.Types where type CallStack :: * data CallStack = EmptyCallStack | PushCallStack [GHC.Types.Char] SrcLoc CallStack | FreezeCallStack CallStack type HasCallStack :: Constraint - type HasCallStack = ?callStack::CallStack :: Constraint + type HasCallStack = ?callStack::CallStack type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} emptyCallStack :: CallStack @@ -9561,9 +9561,9 @@ module GHC.TypeLits where type (-) :: Natural -> Natural -> Natural type family (-) a b type (<=) :: forall {t}. t -> t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type AppendSymbol :: Symbol -> Symbol -> Symbol type family AppendSymbol a b type CharToNat :: GHC.Types.Char -> Natural @@ -9680,9 +9680,9 @@ module GHC.TypeNats where type (-) :: Natural -> Natural -> Natural type family (-) a b type (<=) :: forall {t}. t -> t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type CmpNat :: Natural -> Natural -> GHC.Types.Ordering type family CmpNat a b type Div :: Natural -> Natural -> Natural ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -1480,9 +1480,9 @@ module Data.Tuple.Experimental where class a => CSolo a {-# MINIMAL #-} type CTuple0 :: Constraint - type CTuple0 = () :: Constraint :: Constraint + type CTuple0 = () :: Constraint type CTuple1 :: Constraint -> Constraint - type CTuple1 = CSolo :: Constraint -> Constraint + type CTuple1 = CSolo type CTuple10 :: Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint class (a, b, c, d, e, f, g, h, i, j) => CTuple10 a b c d e f g h i j {-# MINIMAL #-} @@ -2637,11 +2637,11 @@ module Data.Tuple.Experimental where type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType - type Tuple0# = (# #) :: GHC.Types.ZeroBitType + type Tuple0# = (# #) type Tuple1 :: * -> * - type Tuple1 = Solo :: * -> * + type Tuple1 = Solo type Tuple1# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) - type Tuple1# = Solo# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) + type Tuple1# = Solo# type Tuple10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * data Tuple10 a b c d e f g h i j = ... type Tuple10# :: forall (k0 :: GHC.Types.RuntimeRep) (k1 :: GHC.Types.RuntimeRep) (k2 :: GHC.Types.RuntimeRep) (k3 :: GHC.Types.RuntimeRep) (k4 :: GHC.Types.RuntimeRep) (k5 :: GHC.Types.RuntimeRep) (k6 :: GHC.Types.RuntimeRep) (k7 :: GHC.Types.RuntimeRep) (k8 :: GHC.Types.RuntimeRep) (k9 :: GHC.Types.RuntimeRep). TYPE k0 -> TYPE k1 -> TYPE k2 -> TYPE k3 -> TYPE k4 -> TYPE k5 -> TYPE k6 -> TYPE k7 -> TYPE k8 -> TYPE k9 -> TYPE (GHC.Types.TupleRep [k0, k1, k2, k3, k4, k5, k6, k7, k8, k9]) @@ -4328,9 +4328,9 @@ module Prelude.Experimental where class a => CSolo a {-# MINIMAL #-} type CTuple0 :: Constraint - type CTuple0 = () :: Constraint :: Constraint + type CTuple0 = () :: Constraint type CTuple1 :: Constraint -> Constraint - type CTuple1 = CSolo :: Constraint -> Constraint + type CTuple1 = CSolo type CTuple10 :: Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint class (a, b, c, d, e, f, g, h, i, j) => CTuple10 a b c d e f g h i j {-# MINIMAL #-} @@ -6959,11 +6959,11 @@ module Prelude.Experimental where type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType - type Tuple0# = (# #) :: GHC.Types.ZeroBitType + type Tuple0# = (# #) type Tuple1 :: * -> * - type Tuple1 = Solo :: * -> * + type Tuple1 = Solo type Tuple1# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) - type Tuple1# = Solo# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) + type Tuple1# = Solo# type Tuple10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * data Tuple10 a b c d e f g h i j = ... type Tuple10# :: forall (k0 :: GHC.Types.RuntimeRep) (k1 :: GHC.Types.RuntimeRep) (k2 :: GHC.Types.RuntimeRep) (k3 :: GHC.Types.RuntimeRep) (k4 :: GHC.Types.RuntimeRep) (k5 :: GHC.Types.RuntimeRep) (k6 :: GHC.Types.RuntimeRep) (k7 :: GHC.Types.RuntimeRep) (k8 :: GHC.Types.RuntimeRep) (k9 :: GHC.Types.RuntimeRep). TYPE k0 -> TYPE k1 -> TYPE k2 -> TYPE k3 -> TYPE k4 -> TYPE k5 -> TYPE k6 -> TYPE k7 -> TYPE k8 -> TYPE k9 -> TYPE (GHC.Types.TupleRep [k0, k1, k2, k3, k4, k5, k6, k7, k8, k9]) ===================================== testsuite/tests/rep-poly/RepPolyBackpack3.stderr ===================================== @@ -1,19 +1,19 @@ [1 of 3] Processing sig - [1 of 1] Compiling Sig[sig] ( sig\Sig.hsig, nothing ) + [1 of 1] Compiling Sig[sig] ( sig/Sig.hsig, nothing ) [2 of 3] Processing impl Instantiating impl - [1 of 1] Compiling Impl ( impl\Impl.hs, RepPolyBackpack3.out\impl\Impl.o ) + [1 of 1] Compiling Impl ( impl/Impl.hs, RepPolyBackpack3.out/impl/Impl.o ) [3 of 3] Processing main Instantiating main [1 of 1] Including sig[Sig=impl:Impl] Instantiating sig[Sig=impl:Impl] - [1 of 1] Compiling Sig[sig] ( sig\Sig.hsig, RepPolyBackpack3.out\sig\sig-Absk5cIXTXe6UYhGMYGber\Sig.o ) + [1 of 1] Compiling Sig[sig] ( sig/Sig.hsig, RepPolyBackpack3.out/sig/sig-Absk5cIXTXe6UYhGMYGber/Sig.o ) RepPolyBackpack3.bkp:17:5: error: [GHC-15843] • Type constructor ‘Rep’ has conflicting definitions in the module and its hsig file. Main module: type Rep :: GHC.Types.RuntimeRep - type Rep = T :: GHC.Types.RuntimeRep + type Rep = T Hsig file: type Rep :: GHC.Types.RuntimeRep data Rep Illegal implementation of abstract data: Invalid type family ‘T’. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6227a9ce164538d2df0526d76420c45a695e5f03 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6227a9ce164538d2df0526d76420c45a695e5f03 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 14:07:21 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 12 Mar 2024 10:07:21 -0400 Subject: [Git][ghc/ghc][wip/andreask/stm] STM: Be more optimistic when validating in-flight transactions. Message-ID: <65f06199a5f9f_2824f561403b010898@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stm at Glasgow Haskell Compiler / GHC Commits: 4bd1875d by Andreas Klebinger at 2024-03-12T14:47:16+01:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 3 changed files: - rts/STM.c - rts/STM.h - rts/Schedule.c Changes: ===================================== rts/STM.c ===================================== @@ -681,6 +681,42 @@ static void revert_ownership(Capability *cap STG_UNUSED, /*......................................................................*/ +// validate_optimistic() +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec); + +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec) { + StgBool result; + TRACE("cap %d, trec %p : validate_trec_optimistic", + cap->no, trec); + + if (shake()) { + TRACE("%p : shake, pretending trec is invalid when it may not be", trec); + return false; + } + + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + result = !((trec -> state) == TREC_CONDEMNED); + if (result) { + FOR_EACH_ENTRY(trec, e, { + StgTVar *s; + s = e -> tvar; + StgClosure *current = RELAXED_LOAD(&s->current_value); + if(current != e->expected_value && (GET_INFO(UNTAG_CLOSURE(current)) != &stg_TREC_HEADER_info)) + { TRACE("%p : failed optimistic validate %p", trec, s); + result = false; + BREAK_FOR_EACH; + } + }); + } + + + TRACE("%p : validate_trec_optimistic, result: %d", trec, result); + return result; +} + + // validate_and_acquire_ownership : this performs the twin functions // of checking that the TVars referred to by entries in trec hold the // expected values and: @@ -751,7 +787,7 @@ static StgBool validate_and_acquire_ownership (Capability *cap, revert_ownership(cap, trec, acquire_all); } - // TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); + TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); return result; } @@ -973,6 +1009,30 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { return result; } +StgBool stmValidateNestOfTransactionsOptimistic(Capability *cap, StgTRecHeader *trec) { + StgTRecHeader *t; + + TRACE("%p : stmValidateNestOfTransactionsOptimistic", trec); + ASSERT(trec != NO_TREC); + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + + t = trec; + StgBool result = true; + while (t != NO_TREC) { + // TODO: I don't think there is a need to lock any tvars here, all even less so. + result &= validate_trec_optimistic(cap, t); + t = t -> enclosing_trec; + } + + if (!result && trec -> state != TREC_WAITING) { + trec -> state = TREC_CONDEMNED; + } + + TRACE("%p : stmValidateNestOfTransactions()=%d", trec, result); + return result; +} /*......................................................................*/ static TRecEntry *get_entry_for(StgTRecHeader *trec, StgTVar *tvar, StgTRecHeader **in) { ===================================== rts/STM.h ===================================== @@ -95,6 +95,8 @@ void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec); StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); +StgBool stmValidateNestOfTransactionsOptimistic(Capability *cap, StgTRecHeader *trec); + /*---------------------------------------------------------------------- Commit/wait/rewait operations ===================================== rts/Schedule.c ===================================== @@ -1099,7 +1099,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // and a is never equal to b given a consistent view of memory. // if (t -> trec != NO_TREC && t -> why_blocked == NotBlocked) { - if (!stmValidateNestOfTransactions(cap, t -> trec)) { + if (!stmValidateNestOfTransactionsOptimistic(cap, t -> trec)) { debugTrace(DEBUG_sched | DEBUG_stm, "trec %p found wasting its time", t); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bd1875d1fd9c06c21fa28ae0dc6c64a84732f9d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bd1875d1fd9c06c21fa28ae0dc6c64a84732f9d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 14:16:55 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 12 Mar 2024 10:16:55 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 6 commits: rts/linker: Don't unload code when profiling is enabled Message-ID: <65f063d729345_2824f56859f481117f0@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 09d92280 by Ben Gamari at 2024-03-12T10:14:28-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - a27a477d by Ben Gamari at 2024-03-12T10:14:28-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 63928aeb by Ben Gamari at 2024-03-12T10:14:28-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 2e713fdb by Ben Gamari at 2024-03-12T10:14:28-04:00 gitlab-ci: Allow test-primops to fail It's still a bit sensitive to warnings, unfortunately. - - - - - 66c51e75 by Ben Gamari at 2024-03-12T10:14:28-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - d574a10d by Ben Gamari at 2024-03-12T10:14:28-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 9 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/upload.sh - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs - rts/CheckUnload.c - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c Changes: ===================================== .gitlab-ci.yml ===================================== @@ -899,6 +899,7 @@ test-primops-nightly: test-primops-release: extends: .test-primops + allow_failure: true rules: - if: '$RELEASE_JOB == "yes"' ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -136,7 +136,7 @@ function upload() { } function purge_all() { - dir="$(echo $rel_name | sed s/-release//)" + local dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -150,12 +150,18 @@ function purge_all() { } function purge_file() { - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/docs/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/docs/ + dirs=( + "~ghc/$rel_name" + "ghc/$rel_name" + "~ghc/$ver" + "ghc/$ver" + ) + + for dir in ${dirs[@]}; do + curl -X PURGE http://downloads.haskell.org/$dir/$i + curl -X PURGE http://downloads.haskell.org/$dir/$i/ + curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + done } function prepare_docs() { ===================================== hadrian/bindist/Makefile ===================================== @@ -175,18 +175,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" ; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" ===================================== rts/CheckUnload.c ===================================== @@ -165,6 +165,18 @@ ObjectCode *loaded_objects; // map static closures to their ObjectCode. static OCSectionIndices *global_s_indices = NULL; +// Is it safe for us to unload code? +static bool safeToUnload(void) +{ + if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) { + // We mustn't unload anything as the heap census may contain + // references into static data (e.g. cost centre names). + // See #24512. + return false; + } + return true; +} + static OCSectionIndices *createOCSectionIndices(void) { // TODO (osa): Maybe initialize as empty (without allocation) and allocate @@ -457,6 +469,8 @@ void checkUnload(void) { if (global_s_indices == NULL) { return; + } else if (!safeToUnload()) { + return; } // At this point we've marked all dynamically loaded static objects @@ -478,8 +492,6 @@ void checkUnload(void) next = oc->next; ASSERT(oc->status == OBJECT_UNLOADED); - removeOCSectionIndices(s_indices, oc); - // Symbols should be removed by unloadObj_. // NB (osa): If this assertion doesn't hold then freeObjectCode below // will corrupt symhash as keys of that table live in ObjectCodes. If @@ -487,8 +499,17 @@ void checkUnload(void) // RTS) then it's probably because this assertion did not hold. ASSERT(oc->symbols == NULL); - freeObjectCode(oc); - n_unloaded_objects -= 1; + if (oc->unloadable) { + removeOCSectionIndices(s_indices, oc); + freeObjectCode(oc); + n_unloaded_objects -= 1; + } else { + // If we don't have enough information to + // accurately determine the reachability of + // the object then hold onto it. + oc->next = objects; + objects = oc; + } } old_objects = NULL; ===================================== rts/Linker.c ===================================== @@ -1385,6 +1385,8 @@ mkOc( ObjectType type, pathchar *path, char *image, int imageSize, oc->prev = NULL; oc->next_loaded_object = NULL; oc->mark = object_code_mark_bit; + /* this will get cleared by the caller if object is not safely unloadable */ + oc->unloadable = true; oc->dependencies = allocHashSet(); #if defined(NEED_M32) ===================================== rts/LinkerInternals.h ===================================== @@ -313,8 +313,14 @@ struct _ObjectCode { struct _ObjectCode *next_loaded_object; // Mark bit + // N.B. This is a full word as we CAS it. StgWord mark; + // Can this object be safely unloaded? Not true for + // dynamic objects when dlinfo is not available as + // we cannot determine liveness. + bool unloadable; + // Set of dependencies (ObjectCode*) of the object file. Traverse // dependencies using `iterHashTable`. // @@ -376,7 +382,9 @@ struct _ObjectCode { /* handle returned from dlopen */ void *dlopen_handle; - /* virtual memory ranges of loaded code */ + /* virtual memory ranges of loaded code. NULL if no range information is + * available (e.g. if dlinfo is unavailable on the current platform). + */ NativeCodeRange *nc_ranges; }; ===================================== rts/linker/Elf.c ===================================== @@ -2186,6 +2186,10 @@ void * loadNativeObj_ELF (pathchar *path, char **errmsg) copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); goto dl_iterate_phdr_fail; } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; #endif /* defined (HAVE_DLINFO) */ insertOCSectionIndices(nc); ===================================== testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c ===================================== @@ -64,7 +64,7 @@ void check_object_freed(char *obj_path) { OStatus st; st = getObjectLoadStatus(toPathchar(obj_path)); if (st != OBJECT_NOT_LOADED) { - errorBelch("object %s status != OBJECT_NOT_LOADED", obj_path); + errorBelch("object %s status != OBJECT_NOT_LOADED, is %d instead", obj_path, st); exit(1); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/563fa0fd6d25b6187e763832adaae2659fe1f52e...d574a10dc96681f0aecccbbb218b9a4e11f511b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/563fa0fd6d25b6187e763832adaae2659fe1f52e...d574a10dc96681f0aecccbbb218b9a4e11f511b8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 15:01:24 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Tue, 12 Mar 2024 11:01:24 -0400 Subject: [Git][ghc/ghc][wip/tsan/fixes-3] 2 commits: rts: fix clang-specific errors when compiling with TSAN Message-ID: <65f06e44e469f_2824f57c9d4c8145972@gitlab.mail> Cheng Shao pushed to branch wip/tsan/fixes-3 at Glasgow Haskell Compiler / GHC Commits: da8998c6 by Cheng Shao at 2024-03-12T14:57:17+00:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 657d2870 by Cheng Shao at 2024-03-12T15:00:01+00:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - 6 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - rts/TSANUtils.c - rts/include/rts/TSANUtils.h - rts/include/stg/SMP.h - rts/rts.cabal Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -339,7 +339,7 @@ flavourString (Flavour base trans) = base_string base ++ concatMap (("+" ++) . f flavour_string Llvm = "llvm" flavour_string Dwarf = "debug_info" flavour_string FullyStatic = "fully_static" - flavour_string ThreadSanitiser = "thread_sanitizer" + flavour_string ThreadSanitiser = "thread_sanitizer_cmm" flavour_string NoSplitSections = "no_split_sections" flavour_string BootNonmovingGc = "boot_nonmoving_gc" @@ -969,9 +969,9 @@ job_groups = , validateBuilds Amd64 (Linux Debian10) nativeInt , validateBuilds Amd64 (Linux Debian10) unreg , fastCI (validateBuilds Amd64 (Linux Debian10) debug) - , -- Nightly allowed to fail: #22520 + , -- More work is needed to address TSAN failures: #22520 modifyNightlyJobs allowFailure - (modifyValidateJobs manual tsan_jobs) + (modifyValidateJobs (allowFailure . manual) tsan_jobs) , -- Nightly allowed to fail: #22343 modifyNightlyJobs allowFailure (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc)) @@ -1039,7 +1039,7 @@ job_groups = -- Haddock is large enough to make TSAN choke without massive quantities of -- memory. . addVariable "HADRIAN_ARGS" "--docs=none") $ - validateBuilds Amd64 (Linux Debian10) tsan + validateBuilds Amd64 (Linux Debian12) tsan make_wasm_jobs cfg = modifyJobs @@ -1083,6 +1083,7 @@ platform_mapping = Map.map go combined_result , "nightly-x86_64-linux-deb11-validate" , "nightly-x86_64-linux-deb12-validate" , "x86_64-linux-alpine3_18-wasm-cross_wasm32-wasi-release+fully_static" + , "x86_64-linux-deb12-validate+thread_sanitizer_cmm" , "nightly-aarch64-linux-deb10-validate" , "nightly-x86_64-linux-alpine3_12-validate" , "nightly-x86_64-linux-deb10-validate" ===================================== .gitlab/jobs.yaml ===================================== @@ -1644,18 +1644,18 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-validate+thread_sanitizer": { + "nightly-x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1698,17 +1698,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", + "TEST_ENV": "x86_64-linux-deb10-zstd-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-zstd-validate": { + "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1719,7 +1717,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1729,14 +1727,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -1762,15 +1760,17 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate", + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1781,7 +1781,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1823,18 +1823,19 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "nightly-x86_64-linux-deb11-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1845,7 +1846,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1887,19 +1888,16 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "TEST_ENV": "x86_64-linux-deb11-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate": { + "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1910,7 +1908,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1953,15 +1951,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-validate", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "nightly-x86_64-linux-deb12-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1972,7 +1970,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1982,14 +1980,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -2015,15 +2013,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate": { + "nightly-x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -2034,7 +2032,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2077,26 +2075,26 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate+llvm": { + "nightly-x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2139,11 +2137,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm", + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", "XZ_OPT": "-9" } }, @@ -5090,7 +5090,7 @@ "TEST_ENV": "x86_64-linux-deb10-validate+debug_info" } }, - "x86_64-linux-deb10-validate+thread_sanitizer": { + "x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5101,7 +5101,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5127,9 +5127,8 @@ ], "rules": [ { - "allow_failure": true, - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "manual" + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "on_success" } ], "script": [ @@ -5145,16 +5144,14 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + "TEST_ENV": "x86_64-linux-deb10-zstd-validate" } }, - "x86_64-linux-deb10-zstd-validate": { + "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5165,7 +5162,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5175,14 +5172,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5191,7 +5188,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5208,14 +5205,16 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate" + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5226,7 +5225,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5252,7 +5251,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5268,17 +5267,18 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" } }, - "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5289,7 +5289,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5315,7 +5315,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5331,18 +5331,15 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" } }, - "x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5353,7 +5350,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5363,14 +5360,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5379,7 +5376,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5396,25 +5393,25 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm" } }, - "x86_64-linux-deb12-validate+llvm": { + "x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5440,8 +5437,9 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "on_success" + "allow_failure": true, + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "manual" } ], "script": [ @@ -5457,11 +5455,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm" + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" } }, "x86_64-linux-fedora33-release": { ===================================== rts/TSANUtils.c ===================================== @@ -2,7 +2,7 @@ #if defined(TSAN_ENABLED) -uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic64 ghc_tsan_atomic64_compare_exchange(volatile __tsan_atomic64 *ptr, __tsan_atomic64 expected, __tsan_atomic64 new_value, int success_memorder, int failure_memorder) { __tsan_atomic64_compare_exchange_strong( ptr, &expected, new_value, @@ -10,7 +10,7 @@ uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, ui return expected; } -uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic32 ghc_tsan_atomic32_compare_exchange(volatile __tsan_atomic32 *ptr, __tsan_atomic32 expected, __tsan_atomic32 new_value, int success_memorder, int failure_memorder) { __tsan_atomic32_compare_exchange_strong( ptr, &expected, new_value, @@ -18,7 +18,7 @@ uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, ui return expected; } -uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic16 ghc_tsan_atomic16_compare_exchange(volatile __tsan_atomic16 *ptr, __tsan_atomic16 expected, __tsan_atomic16 new_value, int success_memorder, int failure_memorder) { __tsan_atomic16_compare_exchange_strong( ptr, &expected, new_value, @@ -26,7 +26,7 @@ uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, ui return expected; } -uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic8 ghc_tsan_atomic8_compare_exchange(volatile __tsan_atomic8 *ptr, __tsan_atomic8 expected, __tsan_atomic8 new_value, int success_memorder, int failure_memorder) { __tsan_atomic8_compare_exchange_strong( ptr, &expected, new_value, ===================================== rts/include/rts/TSANUtils.h ===================================== @@ -98,10 +98,18 @@ void AnnotateBenignRaceSized(const char *file, #define TSAN_ANNOTATE_BENIGN_RACE(addr,desc) \ TSAN_ANNOTATE_BENIGN_RACE_SIZED((void*)(addr), sizeof(*addr), desc) +#if defined(__clang__) +#include +#else +typedef char __tsan_atomic8; +typedef short __tsan_atomic16; +typedef int __tsan_atomic32; +typedef long __tsan_atomic64; +#endif -uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder); -uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder); -uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder); -uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder); +__tsan_atomic64 ghc_tsan_atomic64_compare_exchange(volatile __tsan_atomic64 *ptr, __tsan_atomic64 expected, __tsan_atomic64 new_value, int success_memorder, int failure_memorder); +__tsan_atomic32 ghc_tsan_atomic32_compare_exchange(volatile __tsan_atomic32 *ptr, __tsan_atomic32 expected, __tsan_atomic32 new_value, int success_memorder, int failure_memorder); +__tsan_atomic16 ghc_tsan_atomic16_compare_exchange(volatile __tsan_atomic16 *ptr, __tsan_atomic16 expected, __tsan_atomic16 new_value, int success_memorder, int failure_memorder); +__tsan_atomic8 ghc_tsan_atomic8_compare_exchange(volatile __tsan_atomic8 *ptr, __tsan_atomic8 expected, __tsan_atomic8 new_value, int success_memorder, int failure_memorder); #endif ===================================== rts/include/stg/SMP.h ===================================== @@ -549,12 +549,14 @@ busy_wait_nop(void) #define SEQ_CST_FENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST) #if defined(TSAN_ENABLED) +#if !defined(__clang__) #undef ACQUIRE_FENCE #undef RELEASE_FENCE #undef SEQ_CST_FENCE #define ACQUIRE_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_ACQUIRE);) #define RELEASE_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_RELEASE);) #define SEQ_CST_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_SEQ_CST);) +#endif #define ACQUIRE_FENCE_ON(x) (void)ACQUIRE_LOAD(x) #else #define ACQUIRE_FENCE_ON(x) __atomic_thread_fence(__ATOMIC_ACQUIRE) ===================================== rts/rts.cabal ===================================== @@ -184,7 +184,6 @@ library if flag(thread-sanitizer) cc-options: -fsanitize=thread ld-options: -fsanitize=thread - extra-libraries: tsan if os(linux) -- the RTS depends upon libc. while this dependency is generally View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4128331d766c13b5333e14e06251ff7fc1d5e96...657d2870457ffff6fbac82588c0ac603cdc0f8e6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4128331d766c13b5333e14e06251ff7fc1d5e96...657d2870457ffff6fbac82588c0ac603cdc0f8e6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 17:05:33 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 12 Mar 2024 13:05:33 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: rts/linker: Don't unload code when profiling is enabled Message-ID: <65f08b5d3128d_16f2141a9049c1472@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 32ab851b by Brandon Chinn at 2024-03-12T13:05:05-04:00 Remove duplicate code normalising slashes - - - - - 268bcbc5 by Brandon Chinn at 2024-03-12T13:05:06-04:00 Simplify regexes with raw strings - - - - - 56113578 by Brandon Chinn at 2024-03-12T13:05:06-04:00 Don't normalize backslashes in characters - - - - - 83d82da6 by Andrei Borzenkov at 2024-03-12T13:05:06-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 22 changed files: - .gitlab/rel_eng/upload.sh - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - rts/CheckUnload.c - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - testsuite/driver/testlib.py - testsuite/tests/parser/should_fail/T21843a.stderr - testsuite/tests/parser/should_fail/T21843b.stderr - testsuite/tests/parser/should_fail/T21843c.stderr - testsuite/tests/parser/should_fail/T21843d.stderr - testsuite/tests/parser/should_fail/T21843e.stderr - testsuite/tests/parser/should_fail/T21843f.stderr - testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -136,7 +136,7 @@ function upload() { } function purge_all() { - dir="$(echo $rel_name | sed s/-release//)" + local dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -150,12 +150,18 @@ function purge_all() { } function purge_file() { - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/~ghc/$rel_name/$i/docs/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/ - curl -X PURGE http://downloads.haskell.org/ghc/$rel_name/$i/docs/ + dirs=( + "~ghc/$rel_name" + "ghc/$rel_name" + "~ghc/$ver" + "ghc/$ver" + ) + + for dir in ${dirs[@]}; do + curl -X PURGE http://downloads.haskell.org/$dir/$i + curl -X PURGE http://downloads.haskell.org/$dir/$i/ + curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + done } function prepare_docs() { ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== rts/CheckUnload.c ===================================== @@ -165,6 +165,18 @@ ObjectCode *loaded_objects; // map static closures to their ObjectCode. static OCSectionIndices *global_s_indices = NULL; +// Is it safe for us to unload code? +static bool safeToUnload(void) +{ + if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) { + // We mustn't unload anything as the heap census may contain + // references into static data (e.g. cost centre names). + // See #24512. + return false; + } + return true; +} + static OCSectionIndices *createOCSectionIndices(void) { // TODO (osa): Maybe initialize as empty (without allocation) and allocate @@ -457,6 +469,8 @@ void checkUnload(void) { if (global_s_indices == NULL) { return; + } else if (!safeToUnload()) { + return; } // At this point we've marked all dynamically loaded static objects @@ -478,8 +492,6 @@ void checkUnload(void) next = oc->next; ASSERT(oc->status == OBJECT_UNLOADED); - removeOCSectionIndices(s_indices, oc); - // Symbols should be removed by unloadObj_. // NB (osa): If this assertion doesn't hold then freeObjectCode below // will corrupt symhash as keys of that table live in ObjectCodes. If @@ -487,8 +499,17 @@ void checkUnload(void) // RTS) then it's probably because this assertion did not hold. ASSERT(oc->symbols == NULL); - freeObjectCode(oc); - n_unloaded_objects -= 1; + if (oc->unloadable) { + removeOCSectionIndices(s_indices, oc); + freeObjectCode(oc); + n_unloaded_objects -= 1; + } else { + // If we don't have enough information to + // accurately determine the reachability of + // the object then hold onto it. + oc->next = objects; + objects = oc; + } } old_objects = NULL; ===================================== rts/Linker.c ===================================== @@ -1385,6 +1385,8 @@ mkOc( ObjectType type, pathchar *path, char *image, int imageSize, oc->prev = NULL; oc->next_loaded_object = NULL; oc->mark = object_code_mark_bit; + /* this will get cleared by the caller if object is not safely unloadable */ + oc->unloadable = true; oc->dependencies = allocHashSet(); #if defined(NEED_M32) ===================================== rts/LinkerInternals.h ===================================== @@ -313,8 +313,14 @@ struct _ObjectCode { struct _ObjectCode *next_loaded_object; // Mark bit + // N.B. This is a full word as we CAS it. StgWord mark; + // Can this object be safely unloaded? Not true for + // dynamic objects when dlinfo is not available as + // we cannot determine liveness. + bool unloadable; + // Set of dependencies (ObjectCode*) of the object file. Traverse // dependencies using `iterHashTable`. // @@ -376,7 +382,9 @@ struct _ObjectCode { /* handle returned from dlopen */ void *dlopen_handle; - /* virtual memory ranges of loaded code */ + /* virtual memory ranges of loaded code. NULL if no range information is + * available (e.g. if dlinfo is unavailable on the current platform). + */ NativeCodeRange *nc_ranges; }; ===================================== rts/linker/Elf.c ===================================== @@ -2186,6 +2186,10 @@ void * loadNativeObj_ELF (pathchar *path, char **errmsg) copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); goto dl_iterate_phdr_fail; } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; #endif /* defined (HAVE_DLINFO) */ insertOCSectionIndices(nc); ===================================== testsuite/driver/testlib.py ===================================== @@ -1119,8 +1119,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): @@ -1491,7 +1491,7 @@ async def do_test(name: TestName, if opts.expect not in ['pass', 'fail', 'missing-lib']: framework_fail(name, way, 'bad expected ' + opts.expect) - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) if way in opts.fragile_ways: if_verbose(1, '*** fragile test %s resulted in %s' % (full_name, 'pass' if result.passed else 'fail')) @@ -1538,7 +1538,7 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') @@ -1549,7 +1549,7 @@ def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str def framework_warn(name: TestName, way: WayName, reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = name + '(' + way + ')' if_verbose(1, '*** framework warning for %s %s ' % (full_name, reason)) t.framework_warnings.append(TestResult(directory, name, reason, way)) @@ -2598,8 +2598,9 @@ def normalise_errmsg(s: str) -> str: s = normalise_callstacks(s) s = normalise_type_reps(s) - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + # normalise slashes to minimise Windows/Unix filename differences, + # but don't normalize backslashes in chars + s = re.sub(r"(?!')\\", '/', s) # Normalize the name of the GHC executable. Specifically, # this catches the cases that: @@ -2614,14 +2615,11 @@ def normalise_errmsg(s: str) -> str: # the colon is there because it appears in error messages; this # hacky solution is used in place of more sophisticated filename # mangling - s = re.sub('([^\\s])\\.exe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) # Same thing for .wasm modules generated by the Wasm backend - s = re.sub('([^\\s])\\.wasm', '\\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) # Same thing for .jsexe directories generated by the JS backend - s = re.sub('([^\\s])\\.jsexe', '\\1', s) - - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) # hpc executable is given ghc suffix s = re.sub('hpc-ghc', 'hpc', s) @@ -2631,8 +2629,8 @@ def normalise_errmsg(s: str) -> str: s = re.sub('ghc-stage[123]', 'ghc', s) # Remove platform prefix (e.g. javascript-unknown-ghcjs) for cross-compiled tools # (ghc, ghc-pkg, unlit, etc.) - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) - s = re.sub('\\w+(-\\w+)*-unlit', 'unlit', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-unlit', 'unlit', s) # On windows error messages can mention versioned executables s = re.sub('ghc-[0-9.]+', 'ghc', s) @@ -2735,8 +2733,8 @@ def normalise_prof (s: str) -> str: return s def normalise_slashes_( s: str ) -> str: - s = re.sub('\\\\', '/', s) - s = re.sub('//', '/', s) + s = re.sub(r'\\', '/', s) + s = re.sub(r'//', '/', s) return s def normalise_exe_( s: str ) -> str: @@ -2754,9 +2752,9 @@ def normalise_output( s: str ) -> str: # and .wasm extension (for the Wasm backend) # 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])\\.wasm', '\\1', s) - s = re.sub('([^\\s])\\.jsexe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is @@ -2776,7 +2774,7 @@ def normalise_output( s: str ) -> str: s = re.sub('.*warning: argument unused during compilation:.*\n', '', s) # strip the cross prefix if any - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) return s ===================================== testsuite/tests/parser/should_fail/T21843a.stderr ===================================== @@ -1,4 +1,4 @@ T21843a.hs:3:13: [GHC-31623] - Unicode character '“' ('/8220') looks like '"' (Quotation Mark), but it is not + Unicode character '“' ('\8220') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843b.stderr ===================================== @@ -1,3 +1,3 @@ T21843b.hs:3:11: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843c.stderr ===================================== @@ -1,6 +1,6 @@ T21843c.hs:3:19: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not T21843c.hs:3:20: [GHC-21231] - lexical error in string/character literal at character '/n' + lexical error in string/character literal at character '\n' ===================================== testsuite/tests/parser/should_fail/T21843d.stderr ===================================== @@ -1,3 +1,3 @@ T21843d.hs:3:13: [GHC-31623] - Unicode character '’' ('/8217') looks like ''' (Single Quote), but it is not + Unicode character '’' ('\8217') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843e.stderr ===================================== @@ -1,3 +1,3 @@ T21843e.hs:3:15: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843f.stderr ===================================== @@ -1,3 +1,3 @@ T21843f.hs:3:13: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/rts/linker/unload_multiple_objs/linker_unload_multiple_objs.c ===================================== @@ -64,7 +64,7 @@ void check_object_freed(char *obj_path) { OStatus st; st = getObjectLoadStatus(toPathchar(obj_path)); if (st != OBJECT_NOT_LOADED) { - errorBelch("object %s status != OBJECT_NOT_LOADED", obj_path); + errorBelch("object %s status != OBJECT_NOT_LOADED, is %d instead", obj_path, st); exit(1); } } ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accommodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/869d8867c758cf2587aa2990bdd73f68268c0f3d...83d82da64b304381e856bb43e2d453501ca9d908 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/869d8867c758cf2587aa2990bdd73f68268c0f3d...83d82da64b304381e856bb43e2d453501ca9d908 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 17:38:54 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Tue, 12 Mar 2024 13:38:54 -0400 Subject: [Git][ghc/ghc][wip/tsan/fixes-3] 3 commits: rts: fix clang-specific errors when compiling with TSAN Message-ID: <65f0932e9f543_16f2142a0687c3077e@gitlab.mail> Cheng Shao pushed to branch wip/tsan/fixes-3 at Glasgow Haskell Compiler / GHC Commits: 157c28bc by Cheng Shao at 2024-03-12T17:37:55+00:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 9b8dad42 by Cheng Shao at 2024-03-12T17:38:01+00:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - ca80d93d by Cheng Shao at 2024-03-12T17:38:33+00:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - 7 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Cmm/ThreadSanitizer.hs - rts/TSANUtils.c - rts/include/rts/TSANUtils.h - rts/include/stg/SMP.h - rts/rts.cabal Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -339,7 +339,7 @@ flavourString (Flavour base trans) = base_string base ++ concatMap (("+" ++) . f flavour_string Llvm = "llvm" flavour_string Dwarf = "debug_info" flavour_string FullyStatic = "fully_static" - flavour_string ThreadSanitiser = "thread_sanitizer" + flavour_string ThreadSanitiser = "thread_sanitizer_cmm" flavour_string NoSplitSections = "no_split_sections" flavour_string BootNonmovingGc = "boot_nonmoving_gc" @@ -969,9 +969,9 @@ job_groups = , validateBuilds Amd64 (Linux Debian10) nativeInt , validateBuilds Amd64 (Linux Debian10) unreg , fastCI (validateBuilds Amd64 (Linux Debian10) debug) - , -- Nightly allowed to fail: #22520 + , -- More work is needed to address TSAN failures: #22520 modifyNightlyJobs allowFailure - (modifyValidateJobs manual tsan_jobs) + (modifyValidateJobs (allowFailure . manual) tsan_jobs) , -- Nightly allowed to fail: #22343 modifyNightlyJobs allowFailure (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc)) @@ -1039,7 +1039,7 @@ job_groups = -- Haddock is large enough to make TSAN choke without massive quantities of -- memory. . addVariable "HADRIAN_ARGS" "--docs=none") $ - validateBuilds Amd64 (Linux Debian10) tsan + validateBuilds Amd64 (Linux Debian12) tsan make_wasm_jobs cfg = modifyJobs @@ -1083,6 +1083,7 @@ platform_mapping = Map.map go combined_result , "nightly-x86_64-linux-deb11-validate" , "nightly-x86_64-linux-deb12-validate" , "x86_64-linux-alpine3_18-wasm-cross_wasm32-wasi-release+fully_static" + , "x86_64-linux-deb12-validate+thread_sanitizer_cmm" , "nightly-aarch64-linux-deb10-validate" , "nightly-x86_64-linux-alpine3_12-validate" , "nightly-x86_64-linux-deb10-validate" ===================================== .gitlab/jobs.yaml ===================================== @@ -1644,18 +1644,18 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-validate+thread_sanitizer": { + "nightly-x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1698,17 +1698,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", + "TEST_ENV": "x86_64-linux-deb10-zstd-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-zstd-validate": { + "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1719,7 +1717,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1729,14 +1727,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -1762,15 +1760,17 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate", + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1781,7 +1781,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1823,18 +1823,19 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "nightly-x86_64-linux-deb11-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1845,7 +1846,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1887,19 +1888,16 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "TEST_ENV": "x86_64-linux-deb11-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate": { + "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1910,7 +1908,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1953,15 +1951,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-validate", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "nightly-x86_64-linux-deb12-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1972,7 +1970,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1982,14 +1980,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -2015,15 +2013,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate": { + "nightly-x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -2034,7 +2032,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2077,26 +2075,26 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate+llvm": { + "nightly-x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2139,11 +2137,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm", + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", "XZ_OPT": "-9" } }, @@ -5090,7 +5090,7 @@ "TEST_ENV": "x86_64-linux-deb10-validate+debug_info" } }, - "x86_64-linux-deb10-validate+thread_sanitizer": { + "x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5101,7 +5101,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5127,9 +5127,8 @@ ], "rules": [ { - "allow_failure": true, - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "manual" + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "on_success" } ], "script": [ @@ -5145,16 +5144,14 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + "TEST_ENV": "x86_64-linux-deb10-zstd-validate" } }, - "x86_64-linux-deb10-zstd-validate": { + "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5165,7 +5162,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5175,14 +5172,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5191,7 +5188,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5208,14 +5205,16 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate" + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5226,7 +5225,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5252,7 +5251,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5268,17 +5267,18 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" } }, - "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5289,7 +5289,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5315,7 +5315,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5331,18 +5331,15 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" } }, - "x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5353,7 +5350,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5363,14 +5360,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5379,7 +5376,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5396,25 +5393,25 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm" } }, - "x86_64-linux-deb12-validate+llvm": { + "x86_64-linux-deb12-validate+thread_sanitizer_cmm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5440,8 +5437,9 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "on_success" + "allow_failure": true, + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "manual" } ], "script": [ @@ -5457,11 +5455,13 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "BUILD_FLAVOUR": "validate+thread_sanitizer_cmm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate+llvm" + "TEST_ENV": "x86_64-linux-deb12-validate+thread_sanitizer_cmm", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" } }, "x86_64-linux-fedora33-release": { ===================================== compiler/GHC/Cmm/ThreadSanitizer.hs ===================================== @@ -184,7 +184,7 @@ saveRestoreCallerRegs us platform = restore = blockFromList restore_nodes -- | Mirrors __tsan_memory_order --- +-- memoryOrderToTsanMemoryOrder :: Env -> MemoryOrdering -> CmmExpr memoryOrderToTsanMemoryOrder env mord = mkIntExpr (platform env) n @@ -294,4 +294,3 @@ tsanAtomicRMW env mord op w addr val dest = AMO_Or -> "fetch_or" AMO_Xor -> "fetch_xor" fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_" ++ op' - ===================================== rts/TSANUtils.c ===================================== @@ -2,7 +2,7 @@ #if defined(TSAN_ENABLED) -uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic64 ghc_tsan_atomic64_compare_exchange(volatile __tsan_atomic64 *ptr, __tsan_atomic64 expected, __tsan_atomic64 new_value, int success_memorder, int failure_memorder) { __tsan_atomic64_compare_exchange_strong( ptr, &expected, new_value, @@ -10,7 +10,7 @@ uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, ui return expected; } -uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic32 ghc_tsan_atomic32_compare_exchange(volatile __tsan_atomic32 *ptr, __tsan_atomic32 expected, __tsan_atomic32 new_value, int success_memorder, int failure_memorder) { __tsan_atomic32_compare_exchange_strong( ptr, &expected, new_value, @@ -18,7 +18,7 @@ uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, ui return expected; } -uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic16 ghc_tsan_atomic16_compare_exchange(volatile __tsan_atomic16 *ptr, __tsan_atomic16 expected, __tsan_atomic16 new_value, int success_memorder, int failure_memorder) { __tsan_atomic16_compare_exchange_strong( ptr, &expected, new_value, @@ -26,7 +26,7 @@ uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, ui return expected; } -uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder) +__tsan_atomic8 ghc_tsan_atomic8_compare_exchange(volatile __tsan_atomic8 *ptr, __tsan_atomic8 expected, __tsan_atomic8 new_value, int success_memorder, int failure_memorder) { __tsan_atomic8_compare_exchange_strong( ptr, &expected, new_value, ===================================== rts/include/rts/TSANUtils.h ===================================== @@ -98,10 +98,18 @@ void AnnotateBenignRaceSized(const char *file, #define TSAN_ANNOTATE_BENIGN_RACE(addr,desc) \ TSAN_ANNOTATE_BENIGN_RACE_SIZED((void*)(addr), sizeof(*addr), desc) +#if defined(TSAN_ENABLED) && defined(__clang__) +#include +#else +typedef char __tsan_atomic8; +typedef short __tsan_atomic16; +typedef int __tsan_atomic32; +typedef long __tsan_atomic64; +#endif -uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder); -uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder); -uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder); -uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder); +__tsan_atomic64 ghc_tsan_atomic64_compare_exchange(volatile __tsan_atomic64 *ptr, __tsan_atomic64 expected, __tsan_atomic64 new_value, int success_memorder, int failure_memorder); +__tsan_atomic32 ghc_tsan_atomic32_compare_exchange(volatile __tsan_atomic32 *ptr, __tsan_atomic32 expected, __tsan_atomic32 new_value, int success_memorder, int failure_memorder); +__tsan_atomic16 ghc_tsan_atomic16_compare_exchange(volatile __tsan_atomic16 *ptr, __tsan_atomic16 expected, __tsan_atomic16 new_value, int success_memorder, int failure_memorder); +__tsan_atomic8 ghc_tsan_atomic8_compare_exchange(volatile __tsan_atomic8 *ptr, __tsan_atomic8 expected, __tsan_atomic8 new_value, int success_memorder, int failure_memorder); #endif ===================================== rts/include/stg/SMP.h ===================================== @@ -549,12 +549,14 @@ busy_wait_nop(void) #define SEQ_CST_FENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST) #if defined(TSAN_ENABLED) +#if !defined(__clang__) #undef ACQUIRE_FENCE #undef RELEASE_FENCE #undef SEQ_CST_FENCE #define ACQUIRE_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_ACQUIRE);) #define RELEASE_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_RELEASE);) #define SEQ_CST_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_SEQ_CST);) +#endif #define ACQUIRE_FENCE_ON(x) (void)ACQUIRE_LOAD(x) #else #define ACQUIRE_FENCE_ON(x) __atomic_thread_fence(__ATOMIC_ACQUIRE) ===================================== rts/rts.cabal ===================================== @@ -184,7 +184,6 @@ library if flag(thread-sanitizer) cc-options: -fsanitize=thread ld-options: -fsanitize=thread - extra-libraries: tsan if os(linux) -- the RTS depends upon libc. while this dependency is generally View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/657d2870457ffff6fbac82588c0ac603cdc0f8e6...ca80d93d9cec0d6d423cbf1ba1e21b67516a1490 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/657d2870457ffff6fbac82588c0ac603cdc0f8e6...ca80d93d9cec0d6d423cbf1ba1e21b67516a1490 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 18:59:18 2024 From: gitlab at gitlab.haskell.org (Ben Orchard (@raehik)) Date: Tue, 12 Mar 2024 14:59:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/raehik/primop-array-mutability-docs Message-ID: <65f0a6064f215_16f2144e0c1a442016@gitlab.mail> Ben Orchard pushed new branch wip/raehik/primop-array-mutability-docs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/raehik/primop-array-mutability-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 Tue Mar 12 20:36:04 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 12 Mar 2024 16:36:04 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Remove duplicate code normalising slashes Message-ID: <65f0bcb4fabd_16f214773f60c500d7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8a39431d by Brandon Chinn at 2024-03-12T16:35:47-04:00 Remove duplicate code normalising slashes - - - - - 607b493f by Brandon Chinn at 2024-03-12T16:35:47-04:00 Simplify regexes with raw strings - - - - - 7aab64a3 by Brandon Chinn at 2024-03-12T16:35:47-04:00 Don't normalize backslashes in characters - - - - - 56dbd6c9 by Andrei Borzenkov at 2024-03-12T16:35:48-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 3d6fecd6 by Cheng Shao at 2024-03-12T16:35:50-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - 5a999d85 by Cheng Shao at 2024-03-12T16:35:50-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 18 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c - testsuite/driver/testlib.py - testsuite/tests/parser/should_fail/T21843a.stderr - testsuite/tests/parser/should_fail/T21843b.stderr - testsuite/tests/parser/should_fail/T21843c.stderr - testsuite/tests/parser/should_fail/T21843d.stderr - testsuite/tests/parser/should_fail/T21843e.stderr - testsuite/tests/parser/should_fail/T21843f.stderr - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== compiler/GHC/Types/Unique/Supply.hs ===================================== @@ -7,7 +7,6 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE UnliftedFFITypes #-} module GHC.Types.Unique.Supply ( -- * Main data type @@ -49,16 +48,16 @@ import Foreign.Storable #define NO_FETCH_ADD #endif -#if defined(javascript_HOST_ARCH) -import GHC.Exts ( atomicCasWord64Addr#, eqWord64# ) -#elif !defined(NO_FETCH_ADD) -import GHC.Exts( fetchAddWordAddr#, word64ToWord#, wordToWord64# ) +#if defined(NO_FETCH_ADD) +import GHC.Exts ( atomicCasWord64Addr#, eqWord64#, readWord64OffAddr# ) +#else +import GHC.Exts( fetchAddWordAddr#, word64ToWord# ) #endif import GHC.Exts ( Addr#, State#, Word64#, RealWorld ) - +import GHC.Int ( Int(..) ) import GHC.Word( Word64(..) ) -import GHC.Exts( plusWord64#, readWord64OffAddr# ) +import GHC.Exts( plusWord64#, int2Word#, wordToWord64# ) {- ************************************************************************ @@ -233,8 +232,9 @@ mkSplitUniqSupply c (# s4, MkSplitUniqSupply (tag .|. u) x y #) }}}} -#if defined(javascript_HOST_ARCH) --- CAS-based pure Haskell implementation +#if defined(NO_FETCH_ADD) +-- GHC currently does not provide this operation on 32-bit platforms, +-- hence the CAS-based implementation. fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# = go @@ -246,35 +246,7 @@ fetchAddWord64Addr# = go (# s2, res #) | 1# <- res `eqWord64#` n0 -> (# s2, n0 #) | otherwise -> go ptr inc s2 - -#elif defined(NO_FETCH_ADD) - --- atomic_inc64 is defined in compiler/cbits/genSym.c. This is of --- course not ideal, but we need to live with it for now given the --- current situation: --- 1. There's no Haskell primop fetchAddWord64Addr# on 32-bit --- platforms yet --- 2. The Cmm %fetch_add64 primop syntax is only present in ghc 9.8 --- but we currently bootstrap from older ghc in our CI --- 3. The Cmm MO_AtomicRMW operation with 64-bit width is well --- supported on 32-bit platforms already, but the plumbing from --- either Haskell or Cmm doesn't work yet because of 1 or 2 --- 4. There's hs_atomic_add64 in ghc-prim cbits that we ought to use, --- but it's only available on 32-bit starting from ghc 9.8 --- 5. The pure Haskell implementation causes mysterious i386 --- regression in unrelated ghc work that can only be fixed by the C --- version here - -foreign import ccall unsafe "atomic_inc64" atomic_inc64 :: Addr# -> Word64# -> IO Word64 - -fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld - -> (# State# RealWorld, Word64# #) -fetchAddWord64Addr# addr inc s0 = - case unIO (atomic_inc64 addr inc) s0 of - (# s1, W64# res #) -> (# s1, res #) - #else - fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# addr inc s0 = @@ -286,9 +258,9 @@ genSym :: IO Word64 genSym = do let !mask = (1 `unsafeShiftL` uNIQUE_BITS) - 1 let !(Ptr counter) = ghc_unique_counter64 - let !(Ptr inc_ptr) = ghc_unique_inc - u <- IO $ \s0 -> case readWord64OffAddr# inc_ptr 0# s0 of - (# s1, inc #) -> case fetchAddWord64Addr# counter inc s1 of + I# inc# <- peek ghc_unique_inc + let !inc = wordToWord64# (int2Word# inc#) + u <- IO $ \s1 -> case fetchAddWord64Addr# counter inc s1 of (# s2, val #) -> let !u = W64# (val `plusWord64#` inc) .&. mask in (# s2, u #) ===================================== compiler/cbits/genSym.c ===================================== @@ -15,11 +15,3 @@ HsWord64 ghc_unique_counter64 = 0; #if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) HsInt ghc_unique_inc = 1; #endif - -// Only used on 32-bit non-JS platforms -#if WORD_SIZE_IN_BITS != 64 -StgWord64 atomic_inc64(StgWord64 volatile* p, StgWord64 incr) -{ - return __atomic_fetch_add(p, incr, __ATOMIC_SEQ_CST); -} -#endif ===================================== testsuite/driver/testlib.py ===================================== @@ -1119,8 +1119,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): @@ -1491,7 +1491,7 @@ async def do_test(name: TestName, if opts.expect not in ['pass', 'fail', 'missing-lib']: framework_fail(name, way, 'bad expected ' + opts.expect) - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) if way in opts.fragile_ways: if_verbose(1, '*** fragile test %s resulted in %s' % (full_name, 'pass' if result.passed else 'fail')) @@ -1538,7 +1538,7 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') @@ -1549,7 +1549,7 @@ def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str def framework_warn(name: TestName, way: WayName, reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = name + '(' + way + ')' if_verbose(1, '*** framework warning for %s %s ' % (full_name, reason)) t.framework_warnings.append(TestResult(directory, name, reason, way)) @@ -2598,8 +2598,9 @@ def normalise_errmsg(s: str) -> str: s = normalise_callstacks(s) s = normalise_type_reps(s) - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + # normalise slashes to minimise Windows/Unix filename differences, + # but don't normalize backslashes in chars + s = re.sub(r"(?!')\\", '/', s) # Normalize the name of the GHC executable. Specifically, # this catches the cases that: @@ -2614,14 +2615,11 @@ def normalise_errmsg(s: str) -> str: # the colon is there because it appears in error messages; this # hacky solution is used in place of more sophisticated filename # mangling - s = re.sub('([^\\s])\\.exe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) # Same thing for .wasm modules generated by the Wasm backend - s = re.sub('([^\\s])\\.wasm', '\\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) # Same thing for .jsexe directories generated by the JS backend - s = re.sub('([^\\s])\\.jsexe', '\\1', s) - - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) # hpc executable is given ghc suffix s = re.sub('hpc-ghc', 'hpc', s) @@ -2631,8 +2629,8 @@ def normalise_errmsg(s: str) -> str: s = re.sub('ghc-stage[123]', 'ghc', s) # Remove platform prefix (e.g. javascript-unknown-ghcjs) for cross-compiled tools # (ghc, ghc-pkg, unlit, etc.) - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) - s = re.sub('\\w+(-\\w+)*-unlit', 'unlit', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-unlit', 'unlit', s) # On windows error messages can mention versioned executables s = re.sub('ghc-[0-9.]+', 'ghc', s) @@ -2735,8 +2733,8 @@ def normalise_prof (s: str) -> str: return s def normalise_slashes_( s: str ) -> str: - s = re.sub('\\\\', '/', s) - s = re.sub('//', '/', s) + s = re.sub(r'\\', '/', s) + s = re.sub(r'//', '/', s) return s def normalise_exe_( s: str ) -> str: @@ -2754,9 +2752,9 @@ def normalise_output( s: str ) -> str: # and .wasm extension (for the Wasm backend) # 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])\\.wasm', '\\1', s) - s = re.sub('([^\\s])\\.jsexe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is @@ -2776,7 +2774,7 @@ def normalise_output( s: str ) -> str: s = re.sub('.*warning: argument unused during compilation:.*\n', '', s) # strip the cross prefix if any - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) return s ===================================== testsuite/tests/parser/should_fail/T21843a.stderr ===================================== @@ -1,4 +1,4 @@ T21843a.hs:3:13: [GHC-31623] - Unicode character '“' ('/8220') looks like '"' (Quotation Mark), but it is not + Unicode character '“' ('\8220') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843b.stderr ===================================== @@ -1,3 +1,3 @@ T21843b.hs:3:11: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843c.stderr ===================================== @@ -1,6 +1,6 @@ T21843c.hs:3:19: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not T21843c.hs:3:20: [GHC-21231] - lexical error in string/character literal at character '/n' + lexical error in string/character literal at character '\n' ===================================== testsuite/tests/parser/should_fail/T21843d.stderr ===================================== @@ -1,3 +1,3 @@ T21843d.hs:3:13: [GHC-31623] - Unicode character '’' ('/8217') looks like ''' (Single Quote), but it is not + Unicode character '’' ('\8217') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843e.stderr ===================================== @@ -1,3 +1,3 @@ T21843e.hs:3:15: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843f.stderr ===================================== @@ -1,3 +1,3 @@ T21843f.hs:3:13: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accommodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/83d82da64b304381e856bb43e2d453501ca9d908...5a999d85560752ad7d66159a70ef1b9e7cff4c41 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/83d82da64b304381e856bb43e2d453501ca9d908...5a999d85560752ad7d66159a70ef1b9e7cff4c41 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 22:01:29 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 12 Mar 2024 18:01:29 -0400 Subject: [Git][ghc/ghc][wip/or-pats] 491 commits: Teach tag-inference about SeqOp/seq# Message-ID: <65f0d0b95a0b8_16f2149e718c45949@gitlab.mail> Sebastian Graf pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - eccba6d1 by Sebastian Graf at 2024-03-12T20:26:16+01:00 Parser: Remove unused `apats` rule - - - - - 3b25a96d by David Knothe at 2024-03-12T23:00:07+01:00 Implement Or Patterns (#22596) This commit introduces a new language extension, `-XOrPatterns`, as described in GHC Proposal 522. An or-pattern `pat1; ...; patk` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. See also the summary `Note [Implmentation of OrPatterns]`. Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> - - - - - 68160db0 by Sebastian Graf at 2024-03-12T23:00:59+01:00 Undo PgNoPat stuff - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/merge_request_templates/Default.md - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/438218fe2555c066d51e1a5bb009e4f8edaa7aaa...68160db0a7c09d07c292c87d530897537adbb3d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/438218fe2555c066d51e1a5bb009e4f8edaa7aaa...68160db0a7c09d07c292c87d530897537adbb3d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 23:26:25 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 12 Mar 2024 19:26:25 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Remove duplicate code normalising slashes Message-ID: <65f0e4a135e96_16f214c4d491c6779b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7 changed files: - testsuite/driver/testlib.py - testsuite/tests/parser/should_fail/T21843a.stderr - testsuite/tests/parser/should_fail/T21843b.stderr - testsuite/tests/parser/should_fail/T21843c.stderr - testsuite/tests/parser/should_fail/T21843d.stderr - testsuite/tests/parser/should_fail/T21843e.stderr - testsuite/tests/parser/should_fail/T21843f.stderr Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1119,8 +1119,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): @@ -1491,7 +1491,7 @@ async def do_test(name: TestName, if opts.expect not in ['pass', 'fail', 'missing-lib']: framework_fail(name, way, 'bad expected ' + opts.expect) - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) if way in opts.fragile_ways: if_verbose(1, '*** fragile test %s resulted in %s' % (full_name, 'pass' if result.passed else 'fail')) @@ -1538,7 +1538,7 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') @@ -1549,7 +1549,7 @@ def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str def framework_warn(name: TestName, way: WayName, reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = name + '(' + way + ')' if_verbose(1, '*** framework warning for %s %s ' % (full_name, reason)) t.framework_warnings.append(TestResult(directory, name, reason, way)) @@ -2598,8 +2598,9 @@ def normalise_errmsg(s: str) -> str: s = normalise_callstacks(s) s = normalise_type_reps(s) - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + # normalise slashes to minimise Windows/Unix filename differences, + # but don't normalize backslashes in chars + s = re.sub(r"(?!')\\", '/', s) # Normalize the name of the GHC executable. Specifically, # this catches the cases that: @@ -2614,14 +2615,11 @@ def normalise_errmsg(s: str) -> str: # the colon is there because it appears in error messages; this # hacky solution is used in place of more sophisticated filename # mangling - s = re.sub('([^\\s])\\.exe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) # Same thing for .wasm modules generated by the Wasm backend - s = re.sub('([^\\s])\\.wasm', '\\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) # Same thing for .jsexe directories generated by the JS backend - s = re.sub('([^\\s])\\.jsexe', '\\1', s) - - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) # hpc executable is given ghc suffix s = re.sub('hpc-ghc', 'hpc', s) @@ -2631,8 +2629,8 @@ def normalise_errmsg(s: str) -> str: s = re.sub('ghc-stage[123]', 'ghc', s) # Remove platform prefix (e.g. javascript-unknown-ghcjs) for cross-compiled tools # (ghc, ghc-pkg, unlit, etc.) - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) - s = re.sub('\\w+(-\\w+)*-unlit', 'unlit', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-unlit', 'unlit', s) # On windows error messages can mention versioned executables s = re.sub('ghc-[0-9.]+', 'ghc', s) @@ -2735,8 +2733,8 @@ def normalise_prof (s: str) -> str: return s def normalise_slashes_( s: str ) -> str: - s = re.sub('\\\\', '/', s) - s = re.sub('//', '/', s) + s = re.sub(r'\\', '/', s) + s = re.sub(r'//', '/', s) return s def normalise_exe_( s: str ) -> str: @@ -2754,9 +2752,9 @@ def normalise_output( s: str ) -> str: # and .wasm extension (for the Wasm backend) # 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])\\.wasm', '\\1', s) - s = re.sub('([^\\s])\\.jsexe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is @@ -2776,7 +2774,7 @@ def normalise_output( s: str ) -> str: s = re.sub('.*warning: argument unused during compilation:.*\n', '', s) # strip the cross prefix if any - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) return s ===================================== testsuite/tests/parser/should_fail/T21843a.stderr ===================================== @@ -1,4 +1,4 @@ T21843a.hs:3:13: [GHC-31623] - Unicode character '“' ('/8220') looks like '"' (Quotation Mark), but it is not + Unicode character '“' ('\8220') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843b.stderr ===================================== @@ -1,3 +1,3 @@ T21843b.hs:3:11: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843c.stderr ===================================== @@ -1,6 +1,6 @@ T21843c.hs:3:19: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not T21843c.hs:3:20: [GHC-21231] - lexical error in string/character literal at character '/n' + lexical error in string/character literal at character '\n' ===================================== testsuite/tests/parser/should_fail/T21843d.stderr ===================================== @@ -1,3 +1,3 @@ T21843d.hs:3:13: [GHC-31623] - Unicode character '’' ('/8217') looks like ''' (Single Quote), but it is not + Unicode character '’' ('\8217') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843e.stderr ===================================== @@ -1,3 +1,3 @@ T21843e.hs:3:15: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843f.stderr ===================================== @@ -1,3 +1,3 @@ T21843f.hs:3:13: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0590764c73841115fc567757e370d5c9dc7e6478...1a5f53c6d4f3812835b8b72f36d9d23004b38f1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0590764c73841115fc567757e370d5c9dc7e6478...1a5f53c6d4f3812835b8b72f36d9d23004b38f1f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 23:27:04 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 12 Mar 2024 19:27:04 -0400 Subject: [Git][ghc/ghc][master] Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) Message-ID: <65f0e4c8bcc07_16f214c5e30d870862@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 9 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accommodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ea971d314c4eba59e12e94bf3eb8edb95fbfac5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ea971d314c4eba59e12e94bf3eb8edb95fbfac5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 12 23:27:47 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 12 Mar 2024 19:27:47 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" Message-ID: <65f0e4f3a6be6_16f214c835afc7394c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 2 changed files: - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c Changes: ===================================== compiler/GHC/Types/Unique/Supply.hs ===================================== @@ -7,7 +7,6 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE UnliftedFFITypes #-} module GHC.Types.Unique.Supply ( -- * Main data type @@ -49,16 +48,16 @@ import Foreign.Storable #define NO_FETCH_ADD #endif -#if defined(javascript_HOST_ARCH) -import GHC.Exts ( atomicCasWord64Addr#, eqWord64# ) -#elif !defined(NO_FETCH_ADD) -import GHC.Exts( fetchAddWordAddr#, word64ToWord#, wordToWord64# ) +#if defined(NO_FETCH_ADD) +import GHC.Exts ( atomicCasWord64Addr#, eqWord64#, readWord64OffAddr# ) +#else +import GHC.Exts( fetchAddWordAddr#, word64ToWord# ) #endif import GHC.Exts ( Addr#, State#, Word64#, RealWorld ) - +import GHC.Int ( Int(..) ) import GHC.Word( Word64(..) ) -import GHC.Exts( plusWord64#, readWord64OffAddr# ) +import GHC.Exts( plusWord64#, int2Word#, wordToWord64# ) {- ************************************************************************ @@ -233,8 +232,9 @@ mkSplitUniqSupply c (# s4, MkSplitUniqSupply (tag .|. u) x y #) }}}} -#if defined(javascript_HOST_ARCH) --- CAS-based pure Haskell implementation +#if defined(NO_FETCH_ADD) +-- GHC currently does not provide this operation on 32-bit platforms, +-- hence the CAS-based implementation. fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# = go @@ -246,35 +246,7 @@ fetchAddWord64Addr# = go (# s2, res #) | 1# <- res `eqWord64#` n0 -> (# s2, n0 #) | otherwise -> go ptr inc s2 - -#elif defined(NO_FETCH_ADD) - --- atomic_inc64 is defined in compiler/cbits/genSym.c. This is of --- course not ideal, but we need to live with it for now given the --- current situation: --- 1. There's no Haskell primop fetchAddWord64Addr# on 32-bit --- platforms yet --- 2. The Cmm %fetch_add64 primop syntax is only present in ghc 9.8 --- but we currently bootstrap from older ghc in our CI --- 3. The Cmm MO_AtomicRMW operation with 64-bit width is well --- supported on 32-bit platforms already, but the plumbing from --- either Haskell or Cmm doesn't work yet because of 1 or 2 --- 4. There's hs_atomic_add64 in ghc-prim cbits that we ought to use, --- but it's only available on 32-bit starting from ghc 9.8 --- 5. The pure Haskell implementation causes mysterious i386 --- regression in unrelated ghc work that can only be fixed by the C --- version here - -foreign import ccall unsafe "atomic_inc64" atomic_inc64 :: Addr# -> Word64# -> IO Word64 - -fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld - -> (# State# RealWorld, Word64# #) -fetchAddWord64Addr# addr inc s0 = - case unIO (atomic_inc64 addr inc) s0 of - (# s1, W64# res #) -> (# s1, res #) - #else - fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# addr inc s0 = @@ -286,9 +258,9 @@ genSym :: IO Word64 genSym = do let !mask = (1 `unsafeShiftL` uNIQUE_BITS) - 1 let !(Ptr counter) = ghc_unique_counter64 - let !(Ptr inc_ptr) = ghc_unique_inc - u <- IO $ \s0 -> case readWord64OffAddr# inc_ptr 0# s0 of - (# s1, inc #) -> case fetchAddWord64Addr# counter inc s1 of + I# inc# <- peek ghc_unique_inc + let !inc = wordToWord64# (int2Word# inc#) + u <- IO $ \s1 -> case fetchAddWord64Addr# counter inc s1 of (# s2, val #) -> let !u = W64# (val `plusWord64#` inc) .&. mask in (# s2, u #) ===================================== compiler/cbits/genSym.c ===================================== @@ -15,11 +15,3 @@ HsWord64 ghc_unique_counter64 = 0; #if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) HsInt ghc_unique_inc = 1; #endif - -// Only used on 32-bit non-JS platforms -#if WORD_SIZE_IN_BITS != 64 -StgWord64 atomic_inc64(StgWord64 volatile* p, StgWord64 incr) -{ - return __atomic_fetch_add(p, incr, __ATOMIC_SEQ_CST); -} -#endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ea971d314c4eba59e12e94bf3eb8edb95fbfac5...e6bfb85c842edca36754bb8914e725fbaa1a83a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ea971d314c4eba59e12e94bf3eb8edb95fbfac5...e6bfb85c842edca36754bb8914e725fbaa1a83a6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 00:39:46 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 12 Mar 2024 20:39:46 -0400 Subject: [Git][ghc/ghc][wip/andreask/stm] STM: Be more optimistic when validating in-flight transactions. Message-ID: <65f0f5d289cfc_67be2cb3cc08217f@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stm at Glasgow Haskell Compiler / GHC Commits: c50cc783 by Andreas Klebinger at 2024-03-13T01:21:50+01:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 5 changed files: - rts/Exception.cmm - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h Changes: ===================================== rts/Exception.cmm ===================================== @@ -495,7 +495,7 @@ retry_pop_stack: W_ trec, outer; W_ r; trec = StgTSO_trec(CurrentTSO); - (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr"); + (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr", 0); outer = StgTRecHeader_enclosing_trec(trec); ccall stmAbortTransaction(MyCapability() "ptr", trec "ptr"); ccall stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr"); ===================================== rts/STM.c ===================================== @@ -359,6 +359,8 @@ static StgTRecHeader *new_stg_trec_header(Capability *cap, // Allocation / deallocation functions that retain per-capability lists // of closures that can be re-used +//TODO: I think some of these lack write barriers required by the non-moving gc. + static StgTVarWatchQueue *alloc_stg_tvar_watch_queue(Capability *cap, StgClosure *closure) { StgTVarWatchQueue *result = NULL; @@ -681,6 +683,44 @@ static void revert_ownership(Capability *cap STG_UNUSED, /*......................................................................*/ +// validate_optimistic() +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec); + +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec) { + StgBool result; + TRACE("cap %d, trec %p : validate_trec_optimistic", + cap->no, trec); + + if (shake()) { + TRACE("%p : shake, pretending trec is invalid when it may not be", trec); + return false; + } + + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + result = !((trec -> state) == TREC_CONDEMNED); + if (result) { + FOR_EACH_ENTRY(trec, e, { + StgTVar *s; + s = e -> tvar; + StgClosure *current = RELAXED_LOAD(&s->current_value); + if(current != e->expected_value && + //If the trec is locked we optimistically assume our trec will still be valid after it's unlocked. + (GET_INFO(UNTAG_CLOSURE(current)) != &stg_TREC_HEADER_info)) + { TRACE("%p : failed optimistic validate %p", trec, s); + result = false; + BREAK_FOR_EACH; + } + }); + } + + + TRACE("%p : validate_trec_optimistic, result: %d", trec, result); + return result; +} + + // validate_and_acquire_ownership : this performs the twin functions // of checking that the TVars referred to by entries in trec hold the // expected values and: @@ -751,7 +791,7 @@ static StgBool validate_and_acquire_ownership (Capability *cap, revert_ownership(cap, trec, acquire_all); } - // TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); + TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); return result; } @@ -941,17 +981,124 @@ void stmCondemnTransaction(Capability *cap, TRACE("%p : stmCondemnTransaction done", trec); } -/*......................................................................*/ - -// Check if a transaction is known to be invalid by this point. -// Currently we use this to: -// * Eagerly abort invalid transactions from the scheduler. -// * If an exception occured inside a transaction, decide weither or not to -// abort by checking if the transaction was valid. -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { +/*...................................................................... + +Note [STM Validation] +~~~~~~~~~~~~~~~~~~~~~ +We validate STM transactions for two purposes: +* Ensure the trec (transaction log) is valid *after* execution. Either during + commit or after an exception has occured. Potentially locking the tvars in + the process. This is done by validate_and_acquire_ownership. +* Terminate transactions early after their trec became invalid. + This is done by validate_trec_optimistic, + +Note that the second point is not merely a optimization. Consider transactions +that are in an infinite loop as a result of seeing an inconsistent view of +memory, e.g. + + atomically $ do + [a,b] <- mapM readTVar [ta,tb] + -- a is never equal to b given a consistent view of memory. + when (a == b) loop + +We want to to always get a precise result for both checks. And indeed for the +non-threaded runtime this is reasonably (see STM paper "Composable Memory Transactions"). +However for SMP things are more difficult. + +The easiest way to avoid false positives is to lock all relevant tvars during +validation. And indeed that is what we still use for post-run validation. +While this can lead to validation spuriously failing in edge cases when multiple +threads perform validation in parallel the relevant transactions will simply be +restarted and as long as the false-negative rate is reasonably low this is not +problematic. + +However compared to post-run validation in-flight validation can happen multiple +times per transaction. This means even a fairly low rate of spurious validation +failures will result in a large performance hit. In the worst case preventing +progress alltogether (See #24446). + +We don't want to reduce validation frequency too much to detect invalid +transactions early. So we simply stick with the frequency "on return to scheduler" +that's described in the stm paper. + +However we can improve the behaviour of in-flight validations by taking advantage +of the fact that we can allow false positives for these. + +The biggest overhead we can reduce for in-flight validation is locking. We simply +won't take any locks for in-flight validation. If the tvar is already locked we +simply assume the value in our trec is still valid. + +This has the following effects: + +Benefits: +* No lock contention between post-run and in-flight validations operating on the + same tvars. This reduces the false negative rate significantly for both. +* Concurrent in-flight validations won't cause each other to fail spuriously + through lock contention. +* No cas operations for in-flight validation reduces it's overhead significantly. + +Drawbacks: +* We will sometimes fail to recognize invalid trecs as such by assuming locked + tvars contain valid values. + +Why can we simply not lock tvars for in-flight validations? Unlike with post-run +validation if we miss part of an update which would invalidate the trec it will +be either seen by a later validation (at the latest in the post-run validation +which still locks). However there is one exception: Looping transactions. + +If a transaction loops it will *only* be validated optimistically. I think this +is not an issue. The only way for in-flight validation to constantly +result in false-positives is for the conflicting tvar(s) to get constantly locked +for updates by post-run validations. Which seems impossibly unlikely over a long +period of time. At at least not any more likely than some of the other similarly +unlikely live-lock scenarious for the STM implementation. + +Alternatives: + +All of these primarily revolve around ways to ensure that we can recognize invalid +looping transactions. However without proof this is a real problem implementing +those seems not worthwhile. + + +A1: +Take locks for in-flight validation opportunistically to improve things. +While this would solve lock contention/false positives caused +by concurrent in-flight validations. It would still result in in-flight validation +potentially triggering false-negatives during post-run validation by holding a +lock a post-run validation is trying to take. Neither is it guaranteed to +recognize a looping transaction as invalid, so this does not seem like an +improvement to the lock-free inflight validation. + +A2: +Perform occasional locking in-flight validation for long running transactions. +This would solve the theoretical looping transaction recognition issue at the +cost of some performance and complexity. This could done by adding a counter to +the trec, counting the number of validations it has endured. + +A2.1: +Like A2, but instead of counting the number of validations count the number of +potentially false-positives by keeping track of how often we couldn't validate +locked tvars. Could be done fine grained on a trec-entry bases or for the trec +overall. + +A3: +When encountering a locked tvar, validate the trec based on the value of the +tvar before it was locked. This could be done by either adding another field +to the tvar, or by looking for the expected value in the trec that holds the +lock of the tvar. But neither option sounds great. + + +*/ + +// Check if a transaction is possibly invalid by this point. +// Pessimistically - Currently we use this if an exception occured inside a transaction. +// To decide weither or not to abort by checking if the transaction was valid. +// Optimistically - Currently we use this to eagerly abort invalid transactions from the scheduler. +// See Note [STM Validation] +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically) { StgTRecHeader *t; - TRACE("%p : stmValidateNestOfTransactions", trec); + TRACE("%p : stmValidateNestOfTransactions, %b", trec, optimistically); ASSERT(trec != NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_WAITING) || @@ -960,8 +1107,13 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { t = trec; StgBool result = true; while (t != NO_TREC) { - // TODO: I don't think there is a need to lock any tvars here, all even less so. - result &= validate_and_acquire_ownership(cap, t, true, false); + if(optimistically) { + result &= validate_trec_optimistic(cap, t); + + } else { + // TODO: I don't think there is a need to lock all tvars here. + result &= validate_and_acquire_ownership(cap, t, true, false); + } t = t -> enclosing_trec; } @@ -972,7 +1124,6 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmValidateNestOfTransactions()=%d", trec, result); return result; } - /*......................................................................*/ static TRecEntry *get_entry_for(StgTRecHeader *trec, StgTVar *tvar, StgTRecHeader **in) { ===================================== rts/STM.h ===================================== @@ -84,16 +84,22 @@ void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec); Validation ---------- - Test whether the specified transaction record, and all those within which - it is nested, are still valid. + Test whether the specified transaction record, and all those within which + it is nested, are still valid. + + stmValidateNestOfTransactions - optimistically + - Can return false positives when tvars are locked. + - Faster + - Does not take any locks + + stmValidateNestOfTransactions - pessimistic + - Can return false negatives. + - Slower + - Takes locks, negatively affecting performance of other threads. - Note: the caller can assume that once stmValidateTransaction has - returned false for a given trec then that transaction will never - again be valid -- we rely on this in Schedule.c when kicking invalid - threads at GC (in case they are stuck looping) */ -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically); /*---------------------------------------------------------------------- @@ -110,7 +116,7 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); Note that, for nested operations, validity here is solely in terms of the specified trec: it does not say whether those that it may be nested are themselves valid. Callers can check this with - stmValidateNestOfTransactions. + stmValidateNestOfTransactionsPessimistic. The user of the STM should ensure that it is always safe to assume that a transaction context is not valid when in fact it is (i.e. to return false in ===================================== rts/Schedule.c ===================================== @@ -1099,7 +1099,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // and a is never equal to b given a consistent view of memory. // if (t -> trec != NO_TREC && t -> why_blocked == NotBlocked) { - if (!stmValidateNestOfTransactions(cap, t -> trec)) { + if (!stmValidateNestOfTransactions(cap, t -> trec, true)) { debugTrace(DEBUG_sched | DEBUG_stm, "trec %p found wasting its time", t); ===================================== rts/include/stg/SMP.h ===================================== @@ -201,14 +201,15 @@ EXTERN_INLINE void busy_wait_nop(void); * - StgWeak: finalizer * - StgMVar: head, tail, value * - StgMVarTSOQueue: link - * - StgTVar: current_value, first_watch_queue_entry - * - StgTVarWatchQueue: {next,prev}_queue_entry - * - StgTRecChunk: TODO * - StgMutArrPtrs: payload * - StgSmallMutArrPtrs: payload * - StgThunk although this is a somewhat special case; see below * - StgInd: indirectee * - StgTSO: block_info + + * - StgTVar: current_value, first_watch_queue_entry + * - StgTVarWatchQueue: {next,prev}_queue_entry + * - StgTRecChunk: TODO * * Finally, non-pointer fields can be safely mutated without barriers as * they do not refer to other memory locations. Technically, concurrent View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c50cc783e9bc67a6ece9a5c4ae57baaa775687ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c50cc783e9bc67a6ece9a5c4ae57baaa775687ea You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 00:57:14 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 12 Mar 2024 20:57:14 -0400 Subject: [Git][ghc/ghc][wip/andreask/stm] STM: Be more optimistic when validating in-flight transactions. Message-ID: <65f0f9e9ede04_67be2148e8a083923@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stm at Glasgow Haskell Compiler / GHC Commits: 896dbb54 by Andreas Klebinger at 2024-03-13T01:42:49+01:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 7 changed files: - rts/Exception.cmm - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h - + testsuite/tests/rts/T24142.hs - testsuite/tests/rts/all.T Changes: ===================================== rts/Exception.cmm ===================================== @@ -495,7 +495,7 @@ retry_pop_stack: W_ trec, outer; W_ r; trec = StgTSO_trec(CurrentTSO); - (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr"); + (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr", 0); outer = StgTRecHeader_enclosing_trec(trec); ccall stmAbortTransaction(MyCapability() "ptr", trec "ptr"); ccall stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr"); ===================================== rts/STM.c ===================================== @@ -359,6 +359,8 @@ static StgTRecHeader *new_stg_trec_header(Capability *cap, // Allocation / deallocation functions that retain per-capability lists // of closures that can be re-used +//TODO: I think some of these lack write barriers required by the non-moving gc. + static StgTVarWatchQueue *alloc_stg_tvar_watch_queue(Capability *cap, StgClosure *closure) { StgTVarWatchQueue *result = NULL; @@ -681,6 +683,44 @@ static void revert_ownership(Capability *cap STG_UNUSED, /*......................................................................*/ +// validate_optimistic() +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec); + +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec) { + StgBool result; + TRACE("cap %d, trec %p : validate_trec_optimistic", + cap->no, trec); + + if (shake()) { + TRACE("%p : shake, pretending trec is invalid when it may not be", trec); + return false; + } + + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + result = !((trec -> state) == TREC_CONDEMNED); + if (result) { + FOR_EACH_ENTRY(trec, e, { + StgTVar *s; + s = e -> tvar; + StgClosure *current = RELAXED_LOAD(&s->current_value); + if(current != e->expected_value && + //If the trec is locked we optimistically assume our trec will still be valid after it's unlocked. + (GET_INFO(UNTAG_CLOSURE(current)) != &stg_TREC_HEADER_info)) + { TRACE("%p : failed optimistic validate %p", trec, s); + result = false; + BREAK_FOR_EACH; + } + }); + } + + + TRACE("%p : validate_trec_optimistic, result: %d", trec, result); + return result; +} + + // validate_and_acquire_ownership : this performs the twin functions // of checking that the TVars referred to by entries in trec hold the // expected values and: @@ -751,7 +791,7 @@ static StgBool validate_and_acquire_ownership (Capability *cap, revert_ownership(cap, trec, acquire_all); } - // TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); + TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); return result; } @@ -941,17 +981,124 @@ void stmCondemnTransaction(Capability *cap, TRACE("%p : stmCondemnTransaction done", trec); } -/*......................................................................*/ - -// Check if a transaction is known to be invalid by this point. -// Currently we use this to: -// * Eagerly abort invalid transactions from the scheduler. -// * If an exception occured inside a transaction, decide weither or not to -// abort by checking if the transaction was valid. -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { +/*...................................................................... + +Note [STM Validation] +~~~~~~~~~~~~~~~~~~~~~ +We validate STM transactions for two purposes: +* Ensure the trec (transaction log) is valid *after* execution. Either during + commit or after an exception has occured. Potentially locking the tvars in + the process. This is done by validate_and_acquire_ownership. +* Terminate transactions early after their trec became invalid. + This is done by validate_trec_optimistic, + +Note that the second point is not merely a optimization. Consider transactions +that are in an infinite loop as a result of seeing an inconsistent view of +memory, e.g. + + atomically $ do + [a,b] <- mapM readTVar [ta,tb] + -- a is never equal to b given a consistent view of memory. + when (a == b) loop + +We want to to always get a precise result for both checks. And indeed for the +non-threaded runtime this is reasonably (see STM paper "Composable Memory Transactions"). +However for SMP things are more difficult. + +The easiest way to avoid false positives is to lock all relevant tvars during +validation. And indeed that is what we still use for post-run validation. +While this can lead to validation spuriously failing in edge cases when multiple +threads perform validation in parallel the relevant transactions will simply be +restarted and as long as the false-negative rate is reasonably low this is not +problematic. + +However compared to post-run validation in-flight validation can happen multiple +times per transaction. This means even a fairly low rate of spurious validation +failures will result in a large performance hit. In the worst case preventing +progress alltogether (See #24446). + +We don't want to reduce validation frequency too much to detect invalid +transactions early. So we simply stick with the frequency "on return to scheduler" +that's described in the stm paper. + +However we can improve the behaviour of in-flight validations by taking advantage +of the fact that we can allow false positives for these. + +The biggest overhead we can reduce for in-flight validation is locking. We simply +won't take any locks for in-flight validation. If the tvar is already locked we +simply assume the value in our trec is still valid. + +This has the following effects: + +Benefits: +* No lock contention between post-run and in-flight validations operating on the + same tvars. This reduces the false negative rate significantly for both. +* Concurrent in-flight validations won't cause each other to fail spuriously + through lock contention. +* No cas operations for in-flight validation reduces it's overhead significantly. + +Drawbacks: +* We will sometimes fail to recognize invalid trecs as such by assuming locked + tvars contain valid values. + +Why can we simply not lock tvars for in-flight validations? Unlike with post-run +validation if we miss part of an update which would invalidate the trec it will +be either seen by a later validation (at the latest in the post-run validation +which still locks). However there is one exception: Looping transactions. + +If a transaction loops it will *only* be validated optimistically. I think this +is not an issue. The only way for in-flight validation to constantly +result in false-positives is for the conflicting tvar(s) to get constantly locked +for updates by post-run validations. Which seems impossibly unlikely over a long +period of time. At at least not any more likely than some of the other similarly +unlikely live-lock scenarious for the STM implementation. + +Alternatives: + +All of these primarily revolve around ways to ensure that we can recognize invalid +looping transactions. However without proof this is a real problem implementing +those seems not worthwhile. + + +A1: +Take locks for in-flight validation opportunistically to improve things. +While this would solve lock contention/false positives caused +by concurrent in-flight validations. It would still result in in-flight validation +potentially triggering false-negatives during post-run validation by holding a +lock a post-run validation is trying to take. Neither is it guaranteed to +recognize a looping transaction as invalid, so this does not seem like an +improvement to the lock-free inflight validation. + +A2: +Perform occasional locking in-flight validation for long running transactions. +This would solve the theoretical looping transaction recognition issue at the +cost of some performance and complexity. This could done by adding a counter to +the trec, counting the number of validations it has endured. + +A2.1: +Like A2, but instead of counting the number of validations count the number of +potentially false-positives by keeping track of how often we couldn't validate +locked tvars. Could be done fine grained on a trec-entry bases or for the trec +overall. + +A3: +When encountering a locked tvar, validate the trec based on the value of the +tvar before it was locked. This could be done by either adding another field +to the tvar, or by looking for the expected value in the trec that holds the +lock of the tvar. But neither option sounds great. + + +*/ + +// Check if a transaction is possibly invalid by this point. +// Pessimistically - Currently we use this if an exception occured inside a transaction. +// To decide weither or not to abort by checking if the transaction was valid. +// Optimistically - Currently we use this to eagerly abort invalid transactions from the scheduler. +// See Note [STM Validation] +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically) { StgTRecHeader *t; - TRACE("%p : stmValidateNestOfTransactions", trec); + TRACE("%p : stmValidateNestOfTransactions, %b", trec, optimistically); ASSERT(trec != NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_WAITING) || @@ -960,8 +1107,13 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { t = trec; StgBool result = true; while (t != NO_TREC) { - // TODO: I don't think there is a need to lock any tvars here, all even less so. - result &= validate_and_acquire_ownership(cap, t, true, false); + if(optimistically) { + result &= validate_trec_optimistic(cap, t); + + } else { + // TODO: I don't think there is a need to lock all tvars here. + result &= validate_and_acquire_ownership(cap, t, true, false); + } t = t -> enclosing_trec; } @@ -972,7 +1124,6 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmValidateNestOfTransactions()=%d", trec, result); return result; } - /*......................................................................*/ static TRecEntry *get_entry_for(StgTRecHeader *trec, StgTVar *tvar, StgTRecHeader **in) { ===================================== rts/STM.h ===================================== @@ -84,16 +84,22 @@ void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec); Validation ---------- - Test whether the specified transaction record, and all those within which - it is nested, are still valid. + Test whether the specified transaction record, and all those within which + it is nested, are still valid. + + stmValidateNestOfTransactions - optimistically + - Can return false positives when tvars are locked. + - Faster + - Does not take any locks + + stmValidateNestOfTransactions - pessimistic + - Can return false negatives. + - Slower + - Takes locks, negatively affecting performance of other threads. - Note: the caller can assume that once stmValidateTransaction has - returned false for a given trec then that transaction will never - again be valid -- we rely on this in Schedule.c when kicking invalid - threads at GC (in case they are stuck looping) */ -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically); /*---------------------------------------------------------------------- @@ -110,7 +116,7 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); Note that, for nested operations, validity here is solely in terms of the specified trec: it does not say whether those that it may be nested are themselves valid. Callers can check this with - stmValidateNestOfTransactions. + stmValidateNestOfTransactionsPessimistic. The user of the STM should ensure that it is always safe to assume that a transaction context is not valid when in fact it is (i.e. to return false in ===================================== rts/Schedule.c ===================================== @@ -1099,7 +1099,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // and a is never equal to b given a consistent view of memory. // if (t -> trec != NO_TREC && t -> why_blocked == NotBlocked) { - if (!stmValidateNestOfTransactions(cap, t -> trec)) { + if (!stmValidateNestOfTransactions(cap, t -> trec, true)) { debugTrace(DEBUG_sched | DEBUG_stm, "trec %p found wasting its time", t); ===================================== rts/include/stg/SMP.h ===================================== @@ -201,14 +201,15 @@ EXTERN_INLINE void busy_wait_nop(void); * - StgWeak: finalizer * - StgMVar: head, tail, value * - StgMVarTSOQueue: link - * - StgTVar: current_value, first_watch_queue_entry - * - StgTVarWatchQueue: {next,prev}_queue_entry - * - StgTRecChunk: TODO * - StgMutArrPtrs: payload * - StgSmallMutArrPtrs: payload * - StgThunk although this is a somewhat special case; see below * - StgInd: indirectee * - StgTSO: block_info + + * - StgTVar: current_value, first_watch_queue_entry + * - StgTVarWatchQueue: {next,prev}_queue_entry + * - StgTRecChunk: TODO * * Finally, non-pointer fields can be safely mutated without barriers as * they do not refer to other memory locations. Technically, concurrent ===================================== testsuite/tests/rts/T24142.hs ===================================== @@ -0,0 +1,63 @@ +{- This test constructs a program that used to trigger an excessive amount of STM retries. -} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE BangPatterns #-} +module Main where + +import GHC.Conc +import Control.Concurrent (newMVar, newEmptyMVar, takeMVar, putMVar) +import Control.Monad +import Control.Concurrent.STM.TArray +import Data.Array.MArray +import Data.IORef + + +main :: IO () +main = + forM_ [2..40] $ \i -> do + -- Run the test with an increasing number of tvars + let tvar_count = i * 10 + -- print $ "Tvars: " ++ show tvar_count + provokeLivelock tvar_count + + +-- Forks two threads running a STM transactions, both accessing the same tvars but in opposite order. +provokeLivelock :: Int -> IO () +provokeLivelock n = do + -- Use tvar array as a convenient way to bundle up n Tvars. + tvarArray <- atomically $ do + newListArray (0,n) [0.. fromIntegral n :: Integer] :: STM (TArray Int Integer) + m1 <- newEmptyMVar + m2 <- newEmptyMVar + updateCount <- newIORef (0 :: Int) + + let useTvars :: [Int] -> Bool -> IO () + useTvars tvar_order use_writes = atomically $ do + -- Walk the array once in the given order to add all tvars to the transaction log. + unsafeIOToSTM $ atomicModifyIORef' updateCount (\i -> (i+1,())) + mapM_ (\i -> readArray tvarArray i >>= \(!_n) -> return ()) tvar_order + + + -- Then we just enter the scheduler a lot + forM_ tvar_order $ \i -> do + -- when use_writes $ + -- readArray tvarArray i >>= \(!n) -> writeArray tvarArray i (n+1 :: Integer) + unsafeIOToSTM yield + + _ <- forkIO $ do + useTvars [0..n] False + -- print "Thread1 done." + putMVar m1 True + _ <- forkIO $ do + useTvars (reverse [0..n]) False + -- print "Thread1 done." + putMVar m2 True + -- Wait for forked threads. + _ <- takeMVar m1 + _ <- takeMVar m2 + updates <- readIORef updateCount + if updates > n + then putStrLn $ "TVars: " ++ show n ++ ", ERROR: more than " ++ show n ++ " transaction attempts. (" ++ show updates ++")\n" + else putStrLn $ "TVars: " ++ show n ++ ", OK: no more than " ++ show n ++ " transaction attempts." + + return () + ===================================== testsuite/tests/rts/all.T ===================================== @@ -609,3 +609,6 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], compile_and_run, ['']) + +test('T24142', [], compile_and_run, ['-threaded -with-rtsopts "-N2"']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/896dbb542b5c474621090fe300cc00aaf37211d8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/896dbb542b5c474621090fe300cc00aaf37211d8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 08:26:44 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 13 Mar 2024 04:26:44 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/tysyn-info-ppr] Update GHCi :info type synonym printing (24459) Message-ID: <65f16344408c8_67be2d008928964ae@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/tysyn-info-ppr at Glasgow Haskell Compiler / GHC Commits: 61f884a0 by Andrei Borzenkov at 2024-03-13T12:26:22+04:00 Update GHCi :info type synonym printing (24459) - Do not print result's kind since we have full kind in SAKS and we display invisible arity using @-binders - Do not suppress significant invisible binders Invisible binder is considered significant when it meets at least one of two following criteria: - It visibly occurs in the RHS type - It is not followed by a visible binder, so it affects arity of type synonym - - - - - 23 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout - testsuite/tests/backpack/should_fail/T19244a.stderr - testsuite/tests/backpack/should_fail/T19244b.stderr - testsuite/tests/backpack/should_fail/bkpfail46.stderr - testsuite/tests/ghci/T18060/T18060.stdout - testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout - testsuite/tests/ghci/scripts/T15941.stdout - testsuite/tests/ghci/scripts/T19310.stdout - testsuite/tests/ghci/scripts/T21294a.stdout - + testsuite/tests/ghci/scripts/T24459.script - + testsuite/tests/ghci/scripts/T24459.stdout - testsuite/tests/ghci/scripts/T8535.stdout - testsuite/tests/ghci/scripts/T9181.stdout - testsuite/tests/ghci/scripts/all.T - testsuite/tests/ghci/scripts/ghci020.stdout - testsuite/tests/ghci/should_run/T10145.stdout - testsuite/tests/ghci/should_run/T18594.stdout - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/rep-poly/RepPolyBackpack3.stderr Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -25,7 +25,7 @@ module GHC.Core.TyCon( mkRequiredTyConBinder, mkAnonTyConBinder, mkAnonTyConBinders, tyConBinderForAllTyFlag, tyConBndrVisForAllTyFlag, isNamedTyConBinder, - isVisibleTyConBinder, isInvisibleTyConBinder, + isVisibleTyConBinder, isInvisSpecTyConBinder, isInvisibleTyConBinder, isVisibleTcbVis, isInvisSpecTcbVis, -- ** Field labels @@ -514,6 +514,10 @@ isInvisSpecTcbVis :: TyConBndrVis -> Bool isInvisSpecTcbVis (NamedTCB Specified) = True isInvisSpecTcbVis _ = False +isInvisSpecTyConBinder :: VarBndr tv TyConBndrVis -> Bool +-- Works for IfaceTyConBinder too +isInvisSpecTyConBinder (Bndr _ tcb_vis) = isInvisSpecTcbVis tcb_vis + isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool -- Works for IfaceTyConBinder too isInvisibleTyConBinder tcb = not (isVisibleTyConBinder tcb) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1033,15 +1033,14 @@ pprIfaceDecl ss (IfaceClass { ifName = clas pprIfaceDecl ss (IfaceSynonym { ifName = tc , ifBinders = binders - , ifSynRhs = mono_ty + , ifSynRhs = poly_ty , ifResKind = res_kind}) = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind) - , hang (text "type" <+> pprIfaceDeclHead suppress_bndr_sig [] ss tc binders <+> equals) - 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau - , ppUnless (isIfaceLiftedTypeKind res_kind) (dcolon <+> ppr res_kind) ]) + , hang (text "type" <+> pprIfaceDeclHeadInvis suppress_bndr_sig [] ss tc binders tau <+> equals) + 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau ]) ] where - (tvs, theta, tau) = splitIfaceSigmaTy mono_ty + (tvs, theta, tau) = splitIfaceSigmaTy poly_ty name_doc = pprPrefixIfDeclBndr (ss_how_much ss) (occName tc) -- See Note [Printing type abbreviations] in GHC.Iface.Type @@ -1232,6 +1231,18 @@ pprIfaceDeclHead suppress_sig context ss tc_occ bndrs <+> pprIfaceTyConBinders suppress_sig (suppressIfaceInvisibles (PrintExplicitKinds print_kinds) bndrs bndrs) ] +pprIfaceDeclHeadInvis :: SuppressBndrSig + -> IfaceContext -> ShowSub -> Name + -> [IfaceTyConBinder] -- of the tycon, for invisible-suppression + -> IfaceType -- RHS + -> SDoc +pprIfaceDeclHeadInvis suppress_sig context ss tc_occ bndrs rhs + = sdocOption sdocPrintExplicitKinds $ \print_kinds -> + sep [ pprIfaceContextArr context + , pprPrefixIfDeclBndr (ss_how_much ss) (occName tc_occ) + <+> pprIfaceTyConBinders suppress_sig + (suppressIfaceInsignificantInvisibles (PrintExplicitKinds print_kinds) rhs bndrs) ] + pprIfaceConDecl :: ShowSub -> Bool -> IfaceTopBndr -> [IfaceTyConBinder] ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -54,7 +54,7 @@ module GHC.Iface.Type ( pprIfaceCoTcApp, pprTyTcApp, pprIfacePrefixApp, isIfaceRhoType, - suppressIfaceInvisibles, + suppressIfaceInvisibles, suppressIfaceInsignificantInvisibles, stripIfaceInvisVars, stripInvisArgs, @@ -521,6 +521,26 @@ suppressIfaceInvisibles (PrintExplicitKinds False) tys xs = suppress tys xs | isInvisibleTyConBinder k = suppress ks xs | otherwise = x : suppress ks xs +-- Invisible binder is considered significant when it meet at least +-- one of two following criteria: +-- - It visibly occurs in the RHS type +-- - It is not followed by a visible binder, so it +-- affects arity of type synonym +suppressIfaceInsignificantInvisibles :: PrintExplicitKinds -> IfaceType -> [IfaceTyConBinder] -> [IfaceTyConBinder] +suppressIfaceInsignificantInvisibles (PrintExplicitKinds True) _rhs tys = tys +suppressIfaceInsignificantInvisibles (PrintExplicitKinds False) rhs tys = suppress [] tys + where + mentioned_var var = ifTyConBinderName var `ifTypeVarVisiblyOccurs` rhs + + mentioned_vars vars = + filter mentioned_var vars + + suppress acc [] = reverse acc + suppress acc (k:ks) = case binderFlag k of + NamedTCB Specified -> suppress (k : acc) ks + NamedTCB Inferred -> suppress acc ks + _ -> reverse (mentioned_vars acc) ++ k : suppress [] ks + stripIfaceInvisVars :: PrintExplicitKinds -> [IfaceTyConBinder] -> [IfaceTyConBinder] stripIfaceInvisVars (PrintExplicitKinds True) tyvars = tyvars stripIfaceInvisVars (PrintExplicitKinds False) tyvars @@ -561,6 +581,27 @@ ifTypeIsVarFree ty = go ty go_args IA_Nil = True go_args (IA_Arg arg _ args) = go arg && go_args args +ifTypeVarVisiblyOccurs :: IfLclName -> IfaceType -> Bool +-- Returns True if the type contains this name. Doesn't count +-- invisible application +-- Just used to control pretty printing +ifTypeVarVisiblyOccurs name ty = go ty + where + go (IfaceTyVar var) = var == name + go (IfaceFreeTyVar {}) = False + go (IfaceAppTy fun args) = go fun || go_args args + go (IfaceFunTy _ w arg res) = go w || go arg || go res + go (IfaceForAllTy bndr ty) = go (ifaceBndrType (binderVar bndr)) || go ty + go (IfaceTyConApp _ args) = go_args args + go (IfaceTupleTy _ _ args) = go_args args + go (IfaceLitTy _) = False + go (IfaceCastTy {}) = False -- Safe + go (IfaceCoercionTy {}) = False -- Safe + + go_args IA_Nil = False + go_args (IA_Arg arg Required args) = go arg || go_args args + go_args (IA_Arg _arg _ args) = go_args args + {- Note [Substitution on IfaceType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Substitutions on IfaceType are done only during pretty-printing to ===================================== testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout ===================================== @@ -1,11 +1,11 @@ -Preprocessing library 'impl' for bkpcabal08-0.1.0.0... -Building library 'impl' for bkpcabal08-0.1.0.0... Preprocessing library 'p' for bkpcabal08-0.1.0.0... Building library 'p' instantiated with A = B = for bkpcabal08-0.1.0.0... [2 of 2] Compiling B[sig] ( p/B.hsig, nothing ) +Preprocessing library 'impl' for bkpcabal08-0.1.0.0... +Building library 'impl' for bkpcabal08-0.1.0.0... Preprocessing library 'q' for bkpcabal08-0.1.0.0... Building library 'q' instantiated with A = @@ -13,13 +13,13 @@ Building library 'q' instantiated with for bkpcabal08-0.1.0.0... [2 of 4] Compiling B[sig] ( q/B.hsig, nothing ) [3 of 4] Compiling M ( q/M.hs, nothing ) [A changed] -[4 of 4] Instantiating bkpcabal08-0.1.0.0-5O1mUtZZLBeDZEqqtwJcCj-p +[4 of 4] Instantiating bkpcabal08-0.1.0.0-CoQJNXLfoYQ4TyvApzFHv-p Preprocessing library 'q' for bkpcabal08-0.1.0.0... Building library 'q' instantiated with - A = bkpcabal08-0.1.0.0-DlVb5PcmUolGCHYbfTL7EP-impl:A - B = bkpcabal08-0.1.0.0-DlVb5PcmUolGCHYbfTL7EP-impl:B + A = bkpcabal08-0.1.0.0-5HJrxUERN7CD204UZeT4Ws-impl:A + B = bkpcabal08-0.1.0.0-5HJrxUERN7CD204UZeT4Ws-impl:B for bkpcabal08-0.1.0.0... -[1 of 3] Compiling A[sig] ( q/A.hsig, dist/build/bkpcabal08-0.1.0.0-LFiTKyjPqyn9yyuysCoVKg-q+5IA1jA4bEzCFcXtraqAC38/A.o ) [Prelude package changed] -[2 of 3] Compiling B[sig] ( q/B.hsig, dist/build/bkpcabal08-0.1.0.0-LFiTKyjPqyn9yyuysCoVKg-q+5IA1jA4bEzCFcXtraqAC38/B.o ) [Prelude package changed] +[1 of 3] Compiling A[sig] ( q/A.hsig, dist/build/bkpcabal08-0.1.0.0-1DQJ9DKc4h59P07qcb0kBc-q+J5mAfRWG9IgLmFQVftCb8t/A.o ) [Prelude package changed] +[2 of 3] Compiling B[sig] ( q/B.hsig, dist/build/bkpcabal08-0.1.0.0-1DQJ9DKc4h59P07qcb0kBc-q+J5mAfRWG9IgLmFQVftCb8t/B.o ) [Prelude package changed] Preprocessing library 'r' for bkpcabal08-0.1.0.0... Building library 'r' for bkpcabal08-0.1.0.0... ===================================== testsuite/tests/backpack/should_fail/T19244a.stderr ===================================== @@ -17,7 +17,7 @@ T19244a.bkp:22:9: error: [GHC-15843] • Type constructor ‘Key’ has conflicting definitions in the module and its hsig file. Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint + type Key = GHC.Classes.Ord Hsig file: type Key :: forall {k}. k -> Constraint class Key k1 The types have different kinds. ===================================== testsuite/tests/backpack/should_fail/T19244b.stderr ===================================== @@ -1,20 +1,20 @@ [1 of 3] Processing user - [1 of 2] Compiling Map[sig] ( user\Map.hsig, nothing ) - [2 of 2] Compiling User ( user\User.hs, nothing ) + [1 of 2] Compiling Map[sig] ( user/Map.hsig, nothing ) + [2 of 2] Compiling User ( user/User.hs, nothing ) [2 of 3] Processing ordmap Instantiating ordmap - [1 of 1] Compiling Map ( ordmap\Map.hs, T19244b.out\ordmap\Map.o ) + [1 of 1] Compiling Map ( ordmap/Map.hs, T19244b.out/ordmap/Map.o ) [3 of 3] Processing main Instantiating main [1 of 1] Including user[Map=ordmap:Map] Instantiating user[Map=ordmap:Map] - [1 of 2] Compiling Map[sig] ( user\Map.hsig, T19244b.out\user\user-GzloW2NeDdA2M0V8qzN4g2\Map.o ) + [1 of 2] Compiling Map[sig] ( user/Map.hsig, T19244b.out/user/user-GzloW2NeDdA2M0V8qzN4g2/Map.o ) T19244b.bkp:11:27: error: [GHC-15843] • Type constructor ‘Key’ has conflicting definitions in the module and its hsig file. Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint + type Key = GHC.Classes.Ord Hsig file: type Key :: forall {k}. k -> Constraint class Key k1 The types have different kinds. ===================================== testsuite/tests/backpack/should_fail/bkpfail46.stderr ===================================== @@ -1,20 +1,20 @@ [1 of 3] Processing p - [1 of 2] Compiling A[sig] ( p\A.hsig, nothing ) - [2 of 2] Compiling M ( p\M.hs, nothing ) + [1 of 2] Compiling A[sig] ( p/A.hsig, nothing ) + [2 of 2] Compiling M ( p/M.hs, nothing ) [2 of 3] Processing q Instantiating q - [1 of 1] Compiling A ( q\A.hs, bkpfail46.out\q\A.o ) + [1 of 1] Compiling A ( q/A.hs, bkpfail46.out/q/A.o ) [3 of 3] Processing r Instantiating r [1 of 1] Including p[A=q:A] Instantiating p[A=q:A] - [1 of 2] Compiling A[sig] ( p\A.hsig, bkpfail46.out\p\p-HVmFlcYSefiK5n1aDP1v7x\A.o ) + [1 of 2] Compiling A[sig] ( p/A.hsig, bkpfail46.out/p/p-HVmFlcYSefiK5n1aDP1v7x/A.o ) bkpfail46.bkp:16:9: error: [GHC-15843] • Type constructor ‘K’ has conflicting definitions in the module and its hsig file. Main module: type K :: * -> Constraint - type K a = GHC.Classes.Eq a :: Constraint + type K a = GHC.Classes.Eq a Hsig file: type K :: * -> Constraint class K a Illegal parameterized type synonym in implementation of abstract data. ===================================== testsuite/tests/ghci/T18060/T18060.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout ===================================== @@ -74,13 +74,13 @@ data Tuple2# a b = (#,#) a b (# , #) :: a -> b -> Tuple2# a b (Int, Int) :: Tuple2 (*) (*) type T :: Tuple2 (*) (*) -type T = (Int, Int) :: Tuple2 (*) (*) +type T = (Int, Int) -- Defined at :18:1 type S :: Solo (*) -type S = MkSolo Int :: Solo (*) +type S = MkSolo Int -- Defined at :19:1 type L :: List (*) -type L = [Int] :: List (*) +type L = [Int] -- Defined at :20:1 f :: Int -> Tuple2 Int Int -> Int (\ (_, _) -> ()) :: Tuple2 a b -> Unit ===================================== testsuite/tests/ghci/scripts/T15941.stdout ===================================== @@ -1,4 +1,3 @@ type T :: * -> * -> * -type T = - (->) @{GHC.Types.LiftedRep} @{GHC.Types.LiftedRep} :: * -> * -> * +type T = (->) @{GHC.Types.LiftedRep} @{GHC.Types.LiftedRep} -- Defined at :2:1 ===================================== testsuite/tests/ghci/scripts/T19310.stdout ===================================== @@ -1,3 +1,3 @@ type T :: * -> * -> * -type T = (->) @{LiftedRep} @{LiftedRep} :: * -> * -> * +type T = (->) @{LiftedRep} @{LiftedRep} -- Defined at :3:1 ===================================== testsuite/tests/ghci/scripts/T21294a.stdout ===================================== @@ -1,5 +1,5 @@ type L0 :: * -> * -type L0 = [] :: * -> * +type L0 = [] -- Defined at :1:1 type L1 :: * -> * type L1 a = [a] ===================================== testsuite/tests/ghci/scripts/T24459.script ===================================== @@ -0,0 +1,46 @@ +:set -XTypeAbstractions + +:{ +import Data.Kind +import Data.Data + + +type T6 :: forall k. Type -> Type +type T6 _a = () + +type T5 :: forall a. Type -> Type +type T5 @a _b = Proxy _b + +type T4 :: forall a. Type -> Type +type T4 @a _b = Proxy a + +type T3 :: forall k. k -> Type +type T3 a = Proxy a + +type T2 :: forall k. k -> Type +type T2 @k = Proxy + +type T1 :: forall k. k -> Type +type T1 = Proxy + +type T0 :: forall k. k -> Type +type T0 = Proxy :: forall k. k -> Type +:} + +:i T0 +:i T1 +:i T2 +:i T3 +:i T4 +:i T5 +:i T6 + +:set -fprint-explicit-kinds + +:i T0 +:i T1 +:i T2 +:i T3 +:i T4 +:i T5 +:i T6 ===================================== testsuite/tests/ghci/scripts/T24459.stdout ===================================== @@ -0,0 +1,42 @@ +type T0 :: forall k. k -> * +type T0 = Proxy + -- Defined at :27:1 +type T1 :: forall k. k -> * +type T1 = Proxy + -- Defined at :24:1 +type T2 :: forall k. k -> * +type T2 @k = Proxy + -- Defined at :21:1 +type T3 :: forall k. k -> * +type T3 a = Proxy a + -- Defined at :18:1 +type T4 :: forall {k} (a :: k). * -> * +type T4 @a _b = Proxy a + -- Defined at :15:1 +type T5 :: forall {k} (a :: k). * -> * +type T5 _b = Proxy _b + -- Defined at :12:1 +type T6 :: forall {k} (k1 :: k). * -> * +type T6 _a = () + -- Defined at :9:1 +type T0 :: forall k. k -> * +type T0 = Proxy + -- Defined at :27:1 +type T1 :: forall k. k -> * +type T1 = Proxy + -- Defined at :24:1 +type T2 :: forall k. k -> * +type T2 @k = Proxy @{k} + -- Defined at :21:1 +type T3 :: forall k. k -> * +type T3 @k a = Proxy @{k} a + -- Defined at :18:1 +type T4 :: forall {k} (a :: k). * -> * +type T4 @{k} @a _b = Proxy @{k} a + -- Defined at :15:1 +type T5 :: forall {k} (a :: k). * -> * +type T5 @{k} @a _b = Proxy @{*} _b + -- Defined at :12:1 +type T6 :: forall {k} (k1 :: k). * -> * +type T6 @{k} @k1 _a = () + -- Defined at :9:1 ===================================== testsuite/tests/ghci/scripts/T8535.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/scripts/T9181.stdout ===================================== @@ -13,12 +13,10 @@ type (GHC.Internal.Data.Type.Ord.<=) x y = GHC.Internal.TypeError.Assert (x GHC.Internal.Data.Type.Ord.<=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) - :: Constraint type (GHC.Internal.Data.Type.Ord.<=?) :: forall k. k -> k -> Bool type (GHC.Internal.Data.Type.Ord.<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) True True False - :: Bool type GHC.Internal.TypeLits.AppendSymbol :: GHC.Types.Symbol -> GHC.Types.Symbol -> GHC.Types.Symbol type family GHC.Internal.TypeLits.AppendSymbol a b ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -384,3 +384,4 @@ test('T23686', normal, ghci_script, ['T23686.script']) test('T13869', extra_files(['T13869a.hs', 'T13869b.hs']), ghci_script, ['T13869.script']) test('ListTuplePunsPpr', normal, ghci_script, ['ListTuplePunsPpr.script']) test('ListTuplePunsPprNoAbbrevTuple', [expect_broken(23135), limit_stdout_lines(13)], ghci_script, ['ListTuplePunsPprNoAbbrevTuple.script']) +test('T24459', normal, ghci_script, ['T24459.script']) ===================================== testsuite/tests/ghci/scripts/ghci020.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/should_run/T10145.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/ghci/should_run/T18594.stdout ===================================== @@ -1,5 +1,5 @@ type (->) :: * -> * -> * -type (->) = FUN Many :: * -> * -> * +type (->) = FUN Many -- Defined in ‘GHC.Types’ infixr -1 -> instance Monoid b => Monoid (a -> b) ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1760,27 +1760,27 @@ module Data.Type.Equality where module Data.Type.Ord where -- Safety: Safe type (<) :: forall {t}. t -> t -> Constraint - type (<) x y = GHC.Internal.TypeError.Assert (x t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = OrdCond (Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = OrdCond (Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type ( k -> GHC.Types.Bool - type () :: forall {t}. t -> t -> Constraint - type (>) x y = GHC.Internal.TypeError.Assert (x >? y) (GHC.Internal.Data.Type.Ord.GtErrMsg x y) :: Constraint + type (>) x y = GHC.Internal.TypeError.Assert (x >? y) (GHC.Internal.Data.Type.Ord.GtErrMsg x y) type (>=) :: forall {t}. t -> t -> Constraint - type (>=) x y = GHC.Internal.TypeError.Assert (x >=? y) (GHC.Internal.Data.Type.Ord.GeErrMsg x y) :: Constraint + type (>=) x y = GHC.Internal.TypeError.Assert (x >=? y) (GHC.Internal.Data.Type.Ord.GeErrMsg x y) type (>=?) :: forall k. k -> k -> GHC.Types.Bool - type (>=?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.True GHC.Types.True :: GHC.Types.Bool + type (>=?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.True GHC.Types.True type (>?) :: forall k. k -> k -> GHC.Types.Bool - type (>?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.False GHC.Types.True :: GHC.Types.Bool + type (>?) m n = OrdCond (Compare m n) GHC.Types.False GHC.Types.False GHC.Types.True type Compare :: forall k. k -> k -> GHC.Types.Ordering type family Compare a b type Max :: forall k. k -> k -> k - type Max m n = OrdCond (Compare m n) n n m :: k + type Max m n = OrdCond (Compare m n) n n m type Min :: forall k. k -> k -> k - type Min m n = OrdCond (Compare m n) m m n :: k + type Min m n = OrdCond (Compare m n) m m n type OrdCond :: forall k. GHC.Types.Ordering -> k -> k -> k -> k type family OrdCond o lt eq gt where forall k (lt :: k) (eq :: k) (gt :: k). OrdCond GHC.Types.LT lt eq gt = lt @@ -3315,7 +3315,7 @@ module GHC.Base where type Levity :: * data Levity = Lifted | Unlifted type LiftedRep :: RuntimeRep - type LiftedRep = BoxedRep Lifted :: RuntimeRep + type LiftedRep = BoxedRep Lifted type List :: * -> * data List a = ... type role MVar# nominal representational @@ -3428,7 +3428,7 @@ module GHC.Base where type TypeLitSort :: * data TypeLitSort = TypeLitSymbol | TypeLitNat | TypeLitChar type UnliftedRep :: RuntimeRep - type UnliftedRep = BoxedRep Unlifted :: RuntimeRep + type UnliftedRep = BoxedRep Unlifted type UnliftedType :: * type UnliftedType = TYPE UnliftedRep type VecCount :: * @@ -3438,7 +3438,7 @@ module GHC.Base where type Void :: * data Void type Void# :: ZeroBitType - type Void# = (# #) :: ZeroBitType + type Void# = (# #) type Weak# :: forall {l :: Levity}. TYPE (BoxedRep l) -> UnliftedType data Weak# a type WithDict :: Constraint -> * -> Constraint @@ -3484,7 +3484,7 @@ module GHC.Base where type WordBox :: TYPE WordRep -> * data WordBox a = MkWordBox a type ZeroBitRep :: RuntimeRep - type ZeroBitRep = TupleRep '[] :: RuntimeRep + type ZeroBitRep = TupleRep '[] type ZeroBitType :: * type ZeroBitType = TYPE ZeroBitRep absentErr :: forall a. a @@ -5513,7 +5513,7 @@ module GHC.Exts where type Levity :: * data Levity = Lifted | Unlifted type LiftedRep :: RuntimeRep - type LiftedRep = BoxedRep Lifted :: RuntimeRep + type LiftedRep = BoxedRep Lifted type List :: * -> * data List a = ... type role MVar# nominal representational @@ -5588,7 +5588,7 @@ module GHC.Exts where TypeLitNat :: GHC.Types.TypeLitSort TypeLitSymbol :: GHC.Types.TypeLitSort type UnliftedRep :: RuntimeRep - type UnliftedRep = BoxedRep Unlifted :: RuntimeRep + type UnliftedRep = BoxedRep Unlifted type UnliftedType :: * type UnliftedType = TYPE UnliftedRep type VecCount :: * @@ -5596,7 +5596,7 @@ module GHC.Exts where type VecElem :: * data VecElem = Int8ElemRep | Int16ElemRep | Int32ElemRep | Int64ElemRep | Word8ElemRep | Word16ElemRep | Word32ElemRep | Word64ElemRep | FloatElemRep | DoubleElemRep type Void# :: ZeroBitType - type Void# = (# #) :: ZeroBitType + type Void# = (# #) type Weak# :: forall {l :: Levity}. TYPE (BoxedRep l) -> UnliftedType data Weak# a type WithDict :: Constraint -> * -> Constraint @@ -5642,7 +5642,7 @@ module GHC.Exts where type WordBox :: TYPE WordRep -> * data WordBox a = MkWordBox a type ZeroBitRep :: RuntimeRep - type ZeroBitRep = TupleRep '[] :: RuntimeRep + type ZeroBitRep = TupleRep '[] type ZeroBitType :: * type ZeroBitType = TYPE ZeroBitRep acosDouble# :: Double# -> Double# @@ -7377,7 +7377,7 @@ module GHC.Generics where type C :: * data C type C1 :: forall {k}. Meta -> (k -> *) -> k -> * - type C1 = M1 C :: Meta -> (k -> *) -> k -> * + type C1 = M1 C type Constructor :: forall {k}. k -> Constraint class Constructor c where conName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t c f a -> [GHC.Types.Char] @@ -7387,7 +7387,7 @@ module GHC.Generics where type D :: * data D type D1 :: forall {k}. Meta -> (k -> *) -> k -> * - type D1 = M1 D :: Meta -> (k -> *) -> k -> * + type D1 = M1 D type Datatype :: forall {k}. k -> Constraint class Datatype d where datatypeName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t d f a -> [GHC.Types.Char] @@ -7434,14 +7434,14 @@ module GHC.Generics where type R :: * data R type Rec0 :: forall {k}. * -> k -> * - type Rec0 = K1 R :: * -> k -> * + type Rec0 = K1 R type role Rec1 representational nominal type Rec1 :: forall k. (k -> *) -> k -> * newtype Rec1 f p = Rec1 {unRec1 :: f p} type S :: * data S type S1 :: forall {k}. Meta -> (k -> *) -> k -> * - type S1 = M1 S :: Meta -> (k -> *) -> k -> * + type S1 = M1 S type Selector :: forall {k}. k -> Constraint class Selector s where selName :: forall k1 (t :: k -> (k1 -> *) -> k1 -> *) (f :: k1 -> *) (a :: k1). t s f a -> [GHC.Types.Char] @@ -7458,24 +7458,24 @@ module GHC.Generics where data U1 p = U1 UAddr :: forall k (p :: k). GHC.Prim.Addr# -> URec (GHC.Internal.Ptr.Ptr ()) p type UAddr :: forall {k}. k -> * - type UAddr = URec (GHC.Internal.Ptr.Ptr ()) :: k -> * + type UAddr = URec (GHC.Internal.Ptr.Ptr ()) UChar :: forall k (p :: k). GHC.Prim.Char# -> URec GHC.Types.Char p type UChar :: forall {k}. k -> * - type UChar = URec GHC.Types.Char :: k -> * + type UChar = URec GHC.Types.Char UDouble :: forall k (p :: k). GHC.Prim.Double# -> URec GHC.Types.Double p type UDouble :: forall {k}. k -> * - type UDouble = URec GHC.Types.Double :: k -> * + type UDouble = URec GHC.Types.Double UFloat :: forall k (p :: k). GHC.Prim.Float# -> URec GHC.Types.Float p type UFloat :: forall {k}. k -> * - type UFloat = URec GHC.Types.Float :: k -> * + type UFloat = URec GHC.Types.Float UInt :: forall k (p :: k). GHC.Prim.Int# -> URec GHC.Types.Int p type UInt :: forall {k}. k -> * - type UInt = URec GHC.Types.Int :: k -> * + type UInt = URec GHC.Types.Int type URec :: forall k. * -> k -> * data family URec a p UWord :: forall k (p :: k). GHC.Prim.Word# -> URec GHC.Types.Word p type UWord :: forall {k}. k -> * - type UWord = URec GHC.Types.Word :: k -> * + type UWord = URec GHC.Types.Word type role V1 phantom type V1 :: forall k. k -> * data V1 p @@ -8563,7 +8563,7 @@ module GHC.Num.BigNat where type BigNat :: * data BigNat = BN# {unBigNat :: BigNat#} type BigNat# :: GHC.Types.UnliftedType - type BigNat# = GHC.Num.WordArray.WordArray# :: GHC.Types.UnliftedType + type BigNat# = GHC.Num.WordArray.WordArray# bigNatAdd :: BigNat# -> BigNat# -> BigNat# bigNatAddWord :: BigNat# -> GHC.Types.Word -> BigNat# bigNatAddWord# :: BigNat# -> GHC.Prim.Word# -> BigNat# @@ -9345,7 +9345,7 @@ module GHC.Stack where type CostCentreStack :: * data CostCentreStack type HasCallStack :: Constraint - type HasCallStack = ?callStack::CallStack :: Constraint + type HasCallStack = ?callStack::CallStack type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} callStack :: HasCallStack => CallStack @@ -9406,7 +9406,7 @@ module GHC.Stack.Types where type CallStack :: * data CallStack = EmptyCallStack | PushCallStack [GHC.Types.Char] SrcLoc CallStack | FreezeCallStack CallStack type HasCallStack :: Constraint - type HasCallStack = ?callStack::CallStack :: Constraint + type HasCallStack = ?callStack::CallStack type SrcLoc :: * data SrcLoc = SrcLoc {srcLocPackage :: [GHC.Types.Char], srcLocModule :: [GHC.Types.Char], srcLocFile :: [GHC.Types.Char], srcLocStartLine :: GHC.Types.Int, srcLocStartCol :: GHC.Types.Int, srcLocEndLine :: GHC.Types.Int, srcLocEndCol :: GHC.Types.Int} emptyCallStack :: CallStack @@ -9561,9 +9561,9 @@ module GHC.TypeLits where type (-) :: Natural -> Natural -> Natural type family (-) a b type (<=) :: forall {t}. t -> t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type AppendSymbol :: Symbol -> Symbol -> Symbol type family AppendSymbol a b type CharToNat :: GHC.Types.Char -> Natural @@ -9680,9 +9680,9 @@ module GHC.TypeNats where type (-) :: Natural -> Natural -> Natural type family (-) a b type (<=) :: forall {t}. t -> t -> Constraint - type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) :: Constraint + type (<=) x y = GHC.Internal.TypeError.Assert (x <=? y) (GHC.Internal.Data.Type.Ord.LeErrMsg x y) type (<=?) :: forall k. k -> k -> GHC.Types.Bool - type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False :: GHC.Types.Bool + type (<=?) m n = GHC.Internal.Data.Type.Ord.OrdCond (GHC.Internal.Data.Type.Ord.Compare m n) GHC.Types.True GHC.Types.True GHC.Types.False type CmpNat :: Natural -> Natural -> GHC.Types.Ordering type family CmpNat a b type Div :: Natural -> Natural -> Natural ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -1480,9 +1480,9 @@ module Data.Tuple.Experimental where class a => CSolo a {-# MINIMAL #-} type CTuple0 :: Constraint - type CTuple0 = () :: Constraint :: Constraint + type CTuple0 = () :: Constraint type CTuple1 :: Constraint -> Constraint - type CTuple1 = CSolo :: Constraint -> Constraint + type CTuple1 = CSolo type CTuple10 :: Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint class (a, b, c, d, e, f, g, h, i, j) => CTuple10 a b c d e f g h i j {-# MINIMAL #-} @@ -2637,11 +2637,11 @@ module Data.Tuple.Experimental where type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType - type Tuple0# = (# #) :: GHC.Types.ZeroBitType + type Tuple0# = (# #) type Tuple1 :: * -> * - type Tuple1 = Solo :: * -> * + type Tuple1 = Solo type Tuple1# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) - type Tuple1# = Solo# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) + type Tuple1# = Solo# type Tuple10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * data Tuple10 a b c d e f g h i j = ... type Tuple10# :: forall (k0 :: GHC.Types.RuntimeRep) (k1 :: GHC.Types.RuntimeRep) (k2 :: GHC.Types.RuntimeRep) (k3 :: GHC.Types.RuntimeRep) (k4 :: GHC.Types.RuntimeRep) (k5 :: GHC.Types.RuntimeRep) (k6 :: GHC.Types.RuntimeRep) (k7 :: GHC.Types.RuntimeRep) (k8 :: GHC.Types.RuntimeRep) (k9 :: GHC.Types.RuntimeRep). TYPE k0 -> TYPE k1 -> TYPE k2 -> TYPE k3 -> TYPE k4 -> TYPE k5 -> TYPE k6 -> TYPE k7 -> TYPE k8 -> TYPE k9 -> TYPE (GHC.Types.TupleRep [k0, k1, k2, k3, k4, k5, k6, k7, k8, k9]) @@ -4328,9 +4328,9 @@ module Prelude.Experimental where class a => CSolo a {-# MINIMAL #-} type CTuple0 :: Constraint - type CTuple0 = () :: Constraint :: Constraint + type CTuple0 = () :: Constraint type CTuple1 :: Constraint -> Constraint - type CTuple1 = CSolo :: Constraint -> Constraint + type CTuple1 = CSolo type CTuple10 :: Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint -> Constraint class (a, b, c, d, e, f, g, h, i, j) => CTuple10 a b c d e f g h i j {-# MINIMAL #-} @@ -6959,11 +6959,11 @@ module Prelude.Experimental where type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType - type Tuple0# = (# #) :: GHC.Types.ZeroBitType + type Tuple0# = (# #) type Tuple1 :: * -> * - type Tuple1 = Solo :: * -> * + type Tuple1 = Solo type Tuple1# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) - type Tuple1# = Solo# :: * -> TYPE (GHC.Types.TupleRep '[GHC.Types.LiftedRep]) + type Tuple1# = Solo# type Tuple10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * data Tuple10 a b c d e f g h i j = ... type Tuple10# :: forall (k0 :: GHC.Types.RuntimeRep) (k1 :: GHC.Types.RuntimeRep) (k2 :: GHC.Types.RuntimeRep) (k3 :: GHC.Types.RuntimeRep) (k4 :: GHC.Types.RuntimeRep) (k5 :: GHC.Types.RuntimeRep) (k6 :: GHC.Types.RuntimeRep) (k7 :: GHC.Types.RuntimeRep) (k8 :: GHC.Types.RuntimeRep) (k9 :: GHC.Types.RuntimeRep). TYPE k0 -> TYPE k1 -> TYPE k2 -> TYPE k3 -> TYPE k4 -> TYPE k5 -> TYPE k6 -> TYPE k7 -> TYPE k8 -> TYPE k9 -> TYPE (GHC.Types.TupleRep [k0, k1, k2, k3, k4, k5, k6, k7, k8, k9]) ===================================== testsuite/tests/rep-poly/RepPolyBackpack3.stderr ===================================== @@ -1,19 +1,19 @@ [1 of 3] Processing sig - [1 of 1] Compiling Sig[sig] ( sig\Sig.hsig, nothing ) + [1 of 1] Compiling Sig[sig] ( sig/Sig.hsig, nothing ) [2 of 3] Processing impl Instantiating impl - [1 of 1] Compiling Impl ( impl\Impl.hs, RepPolyBackpack3.out\impl\Impl.o ) + [1 of 1] Compiling Impl ( impl/Impl.hs, RepPolyBackpack3.out/impl/Impl.o ) [3 of 3] Processing main Instantiating main [1 of 1] Including sig[Sig=impl:Impl] Instantiating sig[Sig=impl:Impl] - [1 of 1] Compiling Sig[sig] ( sig\Sig.hsig, RepPolyBackpack3.out\sig\sig-Absk5cIXTXe6UYhGMYGber\Sig.o ) + [1 of 1] Compiling Sig[sig] ( sig/Sig.hsig, RepPolyBackpack3.out/sig/sig-Absk5cIXTXe6UYhGMYGber/Sig.o ) RepPolyBackpack3.bkp:17:5: error: [GHC-15843] • Type constructor ‘Rep’ has conflicting definitions in the module and its hsig file. Main module: type Rep :: GHC.Types.RuntimeRep - type Rep = T :: GHC.Types.RuntimeRep + type Rep = T Hsig file: type Rep :: GHC.Types.RuntimeRep data Rep Illegal implementation of abstract data: Invalid type family ‘T’. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61f884a02e9a3360f0a0e911e203c763ea33b90a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61f884a02e9a3360f0a0e911e203c763ea33b90a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 08:55:47 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 13 Mar 2024 04:55:47 -0400 Subject: [Git][ghc/ghc][wip/or-pats] 2 commits: Implement Or Patterns (#22596) Message-ID: <65f16a137790a_67be2ddc85cc982d2@gitlab.mail> Sebastian Graf pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 67709931 by David Knothe at 2024-03-13T09:55:32+01:00 Implement Or Patterns (#22596) This commit introduces a new language extension, `-XOrPatterns`, as described in GHC Proposal 522. An or-pattern `pat1; ...; patk` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. See also the summary `Note [Implmentation of OrPatterns]`. Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> - - - - - 22a2c32e by Sebastian Graf at 2024-03-13T09:55:32+01:00 Undo PgNoPat stuff - - - - - 30 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/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/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs - + docs/users_guide/exts/or_patterns.rst - docs/users_guide/exts/patterns.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68160db0a7c09d07c292c87d530897537adbb3d5...22a2c32e57f94894b398ba4b8b6478fe4fcf4a1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68160db0a7c09d07c292c87d530897537adbb3d5...22a2c32e57f94894b398ba4b8b6478fe4fcf4a1a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 09:24:58 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 13 Mar 2024 05:24:58 -0400 Subject: [Git][ghc/ghc][wip/andreask/stm] STM: Be more optimistic when validating in-flight transactions. Message-ID: <65f170e9ead5e_29bf3dcbe8f067855@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stm at Glasgow Haskell Compiler / GHC Commits: 4d1be3de by Andreas Klebinger at 2024-03-13T10:10:37+01:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 8 changed files: - rts/Exception.cmm - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h - + testsuite/tests/rts/T24142.hs - + testsuite/tests/rts/T24142.stdout - testsuite/tests/rts/all.T Changes: ===================================== rts/Exception.cmm ===================================== @@ -495,7 +495,7 @@ retry_pop_stack: W_ trec, outer; W_ r; trec = StgTSO_trec(CurrentTSO); - (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr"); + (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr", 0); outer = StgTRecHeader_enclosing_trec(trec); ccall stmAbortTransaction(MyCapability() "ptr", trec "ptr"); ccall stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr"); ===================================== rts/STM.c ===================================== @@ -359,6 +359,8 @@ static StgTRecHeader *new_stg_trec_header(Capability *cap, // Allocation / deallocation functions that retain per-capability lists // of closures that can be re-used +//TODO: I think some of these lack write barriers required by the non-moving gc. + static StgTVarWatchQueue *alloc_stg_tvar_watch_queue(Capability *cap, StgClosure *closure) { StgTVarWatchQueue *result = NULL; @@ -681,6 +683,44 @@ static void revert_ownership(Capability *cap STG_UNUSED, /*......................................................................*/ +// validate_optimistic() +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec); + +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec) { + StgBool result; + TRACE("cap %d, trec %p : validate_trec_optimistic", + cap->no, trec); + + if (shake()) { + TRACE("%p : shake, pretending trec is invalid when it may not be", trec); + return false; + } + + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + result = !((trec -> state) == TREC_CONDEMNED); + if (result) { + FOR_EACH_ENTRY(trec, e, { + StgTVar *s; + s = e -> tvar; + StgClosure *current = RELAXED_LOAD(&s->current_value); + if(current != e->expected_value && + //If the trec is locked we optimistically assume our trec will still be valid after it's unlocked. + (GET_INFO(UNTAG_CLOSURE(current)) != &stg_TREC_HEADER_info)) + { TRACE("%p : failed optimistic validate %p", trec, s); + result = false; + BREAK_FOR_EACH; + } + }); + } + + + TRACE("%p : validate_trec_optimistic, result: %d", trec, result); + return result; +} + + // validate_and_acquire_ownership : this performs the twin functions // of checking that the TVars referred to by entries in trec hold the // expected values and: @@ -751,7 +791,7 @@ static StgBool validate_and_acquire_ownership (Capability *cap, revert_ownership(cap, trec, acquire_all); } - // TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); + TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); return result; } @@ -941,17 +981,124 @@ void stmCondemnTransaction(Capability *cap, TRACE("%p : stmCondemnTransaction done", trec); } -/*......................................................................*/ - -// Check if a transaction is known to be invalid by this point. -// Currently we use this to: -// * Eagerly abort invalid transactions from the scheduler. -// * If an exception occured inside a transaction, decide weither or not to -// abort by checking if the transaction was valid. -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { +/*...................................................................... + +Note [STM Validation] +~~~~~~~~~~~~~~~~~~~~~ +We validate STM transactions for two purposes: +* Ensure the trec (transaction log) is valid *after* execution. Either during + commit or after an exception has occured. Potentially locking the tvars in + the process. This is done by validate_and_acquire_ownership. +* Terminate transactions early after their trec became invalid. + This is done by validate_trec_optimistic, + +Note that the second point is not merely a optimization. Consider transactions +that are in an infinite loop as a result of seeing an inconsistent view of +memory, e.g. + + atomically $ do + [a,b] <- mapM readTVar [ta,tb] + -- a is never equal to b given a consistent view of memory. + when (a == b) loop + +We want to to always get a precise result for both checks. And indeed for the +non-threaded runtime this is reasonably (see STM paper "Composable Memory Transactions"). +However for SMP things are more difficult. + +The easiest way to avoid false positives is to lock all relevant tvars during +validation. And indeed that is what we still use for post-run validation. +While this can lead to validation spuriously failing in edge cases when multiple +threads perform validation in parallel the relevant transactions will simply be +restarted and as long as the false-negative rate is reasonably low this is not +problematic. + +However compared to post-run validation in-flight validation can happen multiple +times per transaction. This means even a fairly low rate of spurious validation +failures will result in a large performance hit. In the worst case preventing +progress alltogether (See #24446). + +We don't want to reduce validation frequency too much to detect invalid +transactions early. So we simply stick with the frequency "on return to scheduler" +that's described in the stm paper. + +However we can improve the behaviour of in-flight validations by taking advantage +of the fact that we can allow false positives for these. + +The biggest overhead we can reduce for in-flight validation is locking. We simply +won't take any locks for in-flight validation. If the tvar is already locked we +simply assume the value in our trec is still valid. + +This has the following effects: + +Benefits: +* No lock contention between post-run and in-flight validations operating on the + same tvars. This reduces the false negative rate significantly for both. +* Concurrent in-flight validations won't cause each other to fail spuriously + through lock contention. +* No cas operations for in-flight validation reduces it's overhead significantly. + +Drawbacks: +* We will sometimes fail to recognize invalid trecs as such by assuming locked + tvars contain valid values. + +Why can we simply not lock tvars for in-flight validations? Unlike with post-run +validation if we miss part of an update which would invalidate the trec it will +be either seen by a later validation (at the latest in the post-run validation +which still locks). However there is one exception: Looping transactions. + +If a transaction loops it will *only* be validated optimistically. I think this +is not an issue. The only way for in-flight validation to constantly +result in false-positives is for the conflicting tvar(s) to get constantly locked +for updates by post-run validations. Which seems impossibly unlikely over a long +period of time. At at least not any more likely than some of the other similarly +unlikely live-lock scenarious for the STM implementation. + +Alternatives: + +All of these primarily revolve around ways to ensure that we can recognize invalid +looping transactions. However without proof this is a real problem implementing +those seems not worthwhile. + + +A1: +Take locks for in-flight validation opportunistically to improve things. +While this would solve lock contention/false positives caused +by concurrent in-flight validations. It would still result in in-flight validation +potentially triggering false-negatives during post-run validation by holding a +lock a post-run validation is trying to take. Neither is it guaranteed to +recognize a looping transaction as invalid, so this does not seem like an +improvement to the lock-free inflight validation. + +A2: +Perform occasional locking in-flight validation for long running transactions. +This would solve the theoretical looping transaction recognition issue at the +cost of some performance and complexity. This could done by adding a counter to +the trec, counting the number of validations it has endured. + +A2.1: +Like A2, but instead of counting the number of validations count the number of +potentially false-positives by keeping track of how often we couldn't validate +locked tvars. Could be done fine grained on a trec-entry bases or for the trec +overall. + +A3: +When encountering a locked tvar, validate the trec based on the value of the +tvar before it was locked. This could be done by either adding another field +to the tvar, or by looking for the expected value in the trec that holds the +lock of the tvar. But neither option sounds great. + + +*/ + +// Check if a transaction is possibly invalid by this point. +// Pessimistically - Currently we use this if an exception occured inside a transaction. +// To decide weither or not to abort by checking if the transaction was valid. +// Optimistically - Currently we use this to eagerly abort invalid transactions from the scheduler. +// See Note [STM Validation] +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically) { StgTRecHeader *t; - TRACE("%p : stmValidateNestOfTransactions", trec); + TRACE("%p : stmValidateNestOfTransactions, %b", trec, optimistically); ASSERT(trec != NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_WAITING) || @@ -960,8 +1107,13 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { t = trec; StgBool result = true; while (t != NO_TREC) { - // TODO: I don't think there is a need to lock any tvars here, all even less so. - result &= validate_and_acquire_ownership(cap, t, true, false); + if(optimistically) { + result &= validate_trec_optimistic(cap, t); + + } else { + // TODO: I don't think there is a need to lock all tvars here. + result &= validate_and_acquire_ownership(cap, t, true, false); + } t = t -> enclosing_trec; } @@ -972,7 +1124,6 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmValidateNestOfTransactions()=%d", trec, result); return result; } - /*......................................................................*/ static TRecEntry *get_entry_for(StgTRecHeader *trec, StgTVar *tvar, StgTRecHeader **in) { ===================================== rts/STM.h ===================================== @@ -20,7 +20,7 @@ non-conflicting transactions to commit in parallel. The implementation treats reads optimistically -- extra versioning information is retained in the - saw_update_by field of the TVars so that they do not + num_updates field of the TVars so that they do not need to be locked for reading. STM.C contains more details about the locking schemes used. @@ -84,16 +84,23 @@ void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec); Validation ---------- - Test whether the specified transaction record, and all those within which - it is nested, are still valid. + Test whether the specified transaction record, and all those within which + it is nested, are still valid. + + stmValidateNestOfTransactions - optimistically + - Can return false positives when tvars are locked. + - Faster + - Does not take any locks + + stmValidateNestOfTransactions - pessimistic + - Can return false negatives. + - Slower + - Takes locks, negatively affecting performance of other threads. + - Most importantly - no false positives! - Note: the caller can assume that once stmValidateTransaction has - returned false for a given trec then that transaction will never - again be valid -- we rely on this in Schedule.c when kicking invalid - threads at GC (in case they are stuck looping) */ -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically); /*---------------------------------------------------------------------- @@ -110,7 +117,7 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); Note that, for nested operations, validity here is solely in terms of the specified trec: it does not say whether those that it may be nested are themselves valid. Callers can check this with - stmValidateNestOfTransactions. + stmValidateNestOfTransactionsPessimistic. The user of the STM should ensure that it is always safe to assume that a transaction context is not valid when in fact it is (i.e. to return false in ===================================== rts/Schedule.c ===================================== @@ -1099,7 +1099,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // and a is never equal to b given a consistent view of memory. // if (t -> trec != NO_TREC && t -> why_blocked == NotBlocked) { - if (!stmValidateNestOfTransactions(cap, t -> trec)) { + if (!stmValidateNestOfTransactions(cap, t -> trec, true)) { debugTrace(DEBUG_sched | DEBUG_stm, "trec %p found wasting its time", t); ===================================== rts/include/stg/SMP.h ===================================== @@ -201,14 +201,15 @@ EXTERN_INLINE void busy_wait_nop(void); * - StgWeak: finalizer * - StgMVar: head, tail, value * - StgMVarTSOQueue: link - * - StgTVar: current_value, first_watch_queue_entry - * - StgTVarWatchQueue: {next,prev}_queue_entry - * - StgTRecChunk: TODO * - StgMutArrPtrs: payload * - StgSmallMutArrPtrs: payload * - StgThunk although this is a somewhat special case; see below * - StgInd: indirectee * - StgTSO: block_info + + * - StgTVar: current_value, first_watch_queue_entry + * - StgTVarWatchQueue: {next,prev}_queue_entry + * - StgTRecChunk: TODO * * Finally, non-pointer fields can be safely mutated without barriers as * they do not refer to other memory locations. Technically, concurrent ===================================== testsuite/tests/rts/T24142.hs ===================================== @@ -0,0 +1,63 @@ +{- This test constructs a program that used to trigger an excessive amount of STM retries. -} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE BangPatterns #-} +module Main where + +import GHC.Conc +import Control.Concurrent (newMVar, newEmptyMVar, takeMVar, putMVar) +import Control.Monad +import Control.Concurrent.STM.TArray +import Data.Array.MArray +import Data.IORef + + +main :: IO () +main = + forM_ [2..40] $ \i -> do + -- Run the test with an increasing number of tvars + let tvar_count = i * 10 + -- print $ "Tvars: " ++ show tvar_count + provokeLivelock tvar_count + + +-- Forks two threads running a STM transactions, both accessing the same tvars but in opposite order. +provokeLivelock :: Int -> IO () +provokeLivelock n = do + -- Use tvar array as a convenient way to bundle up n Tvars. + tvarArray <- atomically $ do + newListArray (0,n) [0.. fromIntegral n :: Integer] :: STM (TArray Int Integer) + m1 <- newEmptyMVar + m2 <- newEmptyMVar + updateCount <- newIORef (0 :: Int) + + let useTvars :: [Int] -> Bool -> IO () + useTvars tvar_order use_writes = atomically $ do + -- Walk the array once in the given order to add all tvars to the transaction log. + unsafeIOToSTM $ atomicModifyIORef' updateCount (\i -> (i+1,())) + mapM_ (\i -> readArray tvarArray i >>= \(!_n) -> return ()) tvar_order + + + -- Then we just enter the scheduler a lot + forM_ tvar_order $ \i -> do + -- when use_writes $ + -- readArray tvarArray i >>= \(!n) -> writeArray tvarArray i (n+1 :: Integer) + unsafeIOToSTM yield + + _ <- forkIO $ do + useTvars [0..n] False + -- print "Thread1 done." + putMVar m1 True + _ <- forkIO $ do + useTvars (reverse [0..n]) False + -- print "Thread1 done." + putMVar m2 True + -- Wait for forked threads. + _ <- takeMVar m1 + _ <- takeMVar m2 + updates <- readIORef updateCount + if updates > n + then putStrLn $ "TVars: " ++ show n ++ ", ERROR: more than " ++ show n ++ " transaction attempts. (" ++ show updates ++")\n" + else putStrLn $ "TVars: " ++ show n ++ ", OK: no more than " ++ show n ++ " transaction attempts." + + return () + ===================================== testsuite/tests/rts/T24142.stdout ===================================== @@ -0,0 +1,39 @@ +TVars: 20, OK: no more than 20 transaction attempts. +TVars: 30, OK: no more than 30 transaction attempts. +TVars: 40, OK: no more than 40 transaction attempts. +TVars: 50, OK: no more than 50 transaction attempts. +TVars: 60, OK: no more than 60 transaction attempts. +TVars: 70, OK: no more than 70 transaction attempts. +TVars: 80, OK: no more than 80 transaction attempts. +TVars: 90, OK: no more than 90 transaction attempts. +TVars: 100, OK: no more than 100 transaction attempts. +TVars: 110, OK: no more than 110 transaction attempts. +TVars: 120, OK: no more than 120 transaction attempts. +TVars: 130, OK: no more than 130 transaction attempts. +TVars: 140, OK: no more than 140 transaction attempts. +TVars: 150, OK: no more than 150 transaction attempts. +TVars: 160, OK: no more than 160 transaction attempts. +TVars: 170, OK: no more than 170 transaction attempts. +TVars: 180, OK: no more than 180 transaction attempts. +TVars: 190, OK: no more than 190 transaction attempts. +TVars: 200, OK: no more than 200 transaction attempts. +TVars: 210, OK: no more than 210 transaction attempts. +TVars: 220, OK: no more than 220 transaction attempts. +TVars: 230, OK: no more than 230 transaction attempts. +TVars: 240, OK: no more than 240 transaction attempts. +TVars: 250, OK: no more than 250 transaction attempts. +TVars: 260, OK: no more than 260 transaction attempts. +TVars: 270, OK: no more than 270 transaction attempts. +TVars: 280, OK: no more than 280 transaction attempts. +TVars: 290, OK: no more than 290 transaction attempts. +TVars: 300, OK: no more than 300 transaction attempts. +TVars: 310, OK: no more than 310 transaction attempts. +TVars: 320, OK: no more than 320 transaction attempts. +TVars: 330, OK: no more than 330 transaction attempts. +TVars: 340, OK: no more than 340 transaction attempts. +TVars: 350, OK: no more than 350 transaction attempts. +TVars: 360, OK: no more than 360 transaction attempts. +TVars: 370, OK: no more than 370 transaction attempts. +TVars: 380, OK: no more than 380 transaction attempts. +TVars: 390, OK: no more than 390 transaction attempts. +TVars: 400, OK: no more than 400 transaction attempts. ===================================== testsuite/tests/rts/all.T ===================================== @@ -609,3 +609,6 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], compile_and_run, ['']) + +test('T24142', [], compile_and_run, ['-threaded -with-rtsopts "-N2"']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d1be3deb90759b53d78ea6d5603e33e7a28bd03 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d1be3deb90759b53d78ea6d5603e33e7a28bd03 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 11:46:57 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 13 Mar 2024 07:46:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/sand-witch/bidir-ki-check Message-ID: <65f19231e8f2e_29bf3d4a0257c788e7@gitlab.mail> Andrei Borzenkov pushed new branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sand-witch/bidir-ki-check You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 13:07:16 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 13 Mar 2024 09:07:16 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] mk/relpath: Fix quoting Message-ID: <65f1a504213da_29bf3d6c31c889148f@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 9f85900d by Ben Gamari at 2024-03-13T08:59:50-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 1 changed file: - mk/relpath.sh Changes: ===================================== mk/relpath.sh ===================================== @@ -15,7 +15,7 @@ target="$2" common_part="$src" result="" -while test "${target#$common_part}" = "${target}" ; do +while test "${target#"$common_part"}" = "${target}" ; do #echo "common_part is now : \"$common_part\"" #echo "result is now : \"$result\"" #echo "target#common_part : \"${target#$common_part}\"" @@ -39,7 +39,7 @@ fi # since we now have identified the common part, # compute the non-common part -forward_part="${target#$common_part}" +forward_part="${target#"$common_part"}" #echo "forward_part = \"$forward_part\"" if test -n "$result" && test -n "$forward_part" ; then View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f85900d1d851adaa91215b21d362eed95387b5d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f85900d1d851adaa91215b21d362eed95387b5d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 13:16:36 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 13 Mar 2024 09:16:36 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24538 Message-ID: <65f1a734eadb0_29bf3d7164a5c94120@gitlab.mail> Ben Gamari pushed new branch wip/T24538 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24538 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 13:16:57 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 13 Mar 2024 09:16:57 -0400 Subject: [Git][ghc/ghc][wip/T24538] mk/relpath: Fix quoting Message-ID: <65f1a74975e80_29bf3d719e7ac943b4@gitlab.mail> Ben Gamari pushed to branch wip/T24538 at Glasgow Haskell Compiler / GHC Commits: 5cd42fc8 by Ben Gamari at 2024-03-13T09:16:52-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 1 changed file: - mk/relpath.sh Changes: ===================================== mk/relpath.sh ===================================== @@ -15,7 +15,7 @@ target="$2" common_part="$src" result="" -while test "${target#$common_part}" = "${target}" ; do +while test "${target#"$common_part"}" = "${target}" ; do #echo "common_part is now : \"$common_part\"" #echo "result is now : \"$result\"" #echo "target#common_part : \"${target#$common_part}\"" @@ -39,7 +39,7 @@ fi # since we now have identified the common part, # compute the non-common part -forward_part="${target#$common_part}" +forward_part="${target#"$common_part"}" #echo "forward_part = \"$forward_part\"" if test -n "$result" && test -n "$forward_part" ; then View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cd42fc830146f02309d61031180dc551e6c721b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cd42fc830146f02309d61031180dc551e6c721b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 13:45:49 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 13 Mar 2024 09:45:49 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy Message-ID: <65f1ae0d1c03_29bf3d7efbf6c9745c@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 8afa1b09 by Andrei Borzenkov at 2024-03-13T17:45:30+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy - - - - - 3 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -1022,74 +1022,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tc_hs_type_exp mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1144,15 +1083,33 @@ tc_lhs_type mode (L span ty) exp_kind tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -- See Note [Bidirectional type checking] +tc_hs_type mode ty ek = tc_hs_type_exp mode ty (Check ek) + +type ExpKind = ExpType + +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + +tc_lhs_type_exp :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType +tc_lhs_type_exp mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_hs_type_exp mode ty exp_kind + +tc_hs_type_exp :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +-- See Note [Bidirectional type checking] -tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type mode (HsDocTy _ ty _) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type _ ty@(HsBangTy _ bang _) _ +tc_hs_type_exp mode (HsParTy _ ty) exp_kind = tc_lhs_type_exp mode ty exp_kind +tc_hs_type_exp mode (HsDocTy _ ty _) exp_kind = tc_lhs_type_exp mode ty exp_kind +tc_hs_type_exp _ ty@(HsBangTy _ bang _) _ -- While top-level bangs at this point are eliminated (eg !(Maybe Int)), -- other kinds of bangs are not (eg ((!Maybe) Int)). These kinds of -- bangs are invalid, so fail. (#7210, #14761) = failWith $ TcRnUnexpectedAnnotation ty bang -tc_hs_type _ ty@(HsRecTy {}) _ +tc_hs_type_exp _ ty@(HsRecTy {}) _ -- Record types (which only show up temporarily in constructor -- signatures) should have been removed by now = failWithTc $ TcRnIllegalRecordSyntax (Right ty) @@ -1162,23 +1119,25 @@ tc_hs_type _ ty@(HsRecTy {}) _ -- while capturing the local environment. -- -- See Note [Delaying modFinalizers in untyped splices]. -tc_hs_type mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) +tc_hs_type_exp mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) exp_kind = do addModFinalizersWithLclEnv mod_finalizers - tc_lhs_type mode ty exp_kind + tc_lhs_type_exp mode ty exp_kind -tc_hs_type _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type: invalid nested splice" (pprUntypedSplice True (Just n) s) +tc_hs_type_exp _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type_exp: invalid nested splice" (pprUntypedSplice True (Just n) s) ---------- Functions and applications -tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind - = tc_fun_type mode mult ty1 ty2 exp_kind +tc_hs_type_exp mode (HsFunTy _ mult ty1 ty2) exp_kind + = do k <- expTypeToType exp_kind + tc_fun_type mode mult ty1 ty2 k -tc_hs_type mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind +tc_hs_type_exp mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind | op `hasKey` unrestrictedFunTyConKey - = tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 exp_kind + = do k <- expTypeToType exp_kind + tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 k --------- Foralls -tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind +tc_hs_type_exp mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllInvis{} <- tele = tc_hs_forall_ty tele ty exp_kind -- For an invisible forall, we allow the body to have @@ -1187,15 +1146,15 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] where tc_hs_forall_ty tele ty ek = do { (tv_bndrs, ty') <- tcTKTelescope mode tele $ - tc_lhs_type mode ty ek + tc_lhs_type_exp mode ty ek -- Pass on the mode from the type, to any wildcards -- in kind signatures on the forall'd variables -- e.g. f :: _ -> Int -> forall (a :: _). blah @@ -1203,65 +1162,40 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind -- Do not kind-generalise here! See Note [Kind generalisation] ; return (mkForAllTys tv_bndrs ty') } -tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind - | null (unLoc ctxt) - = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind - = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } +tc_hs_type_exp mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_qual_ty k + where + tc_hs_qual_ty kind + | null (unLoc ctxt) + = tc_lhs_type mode rn_ty kind - | otherwise - = do { ctxt' <- tc_hs_context mode ctxt - - ; ek <- newOpenTypeKind -- The body kind (result of the function) can - -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + -- See Note [Body kind of a HsQualTy] + | isConstraintLikeKind kind + = do { ctxt' <- tc_hs_context mode ctxt + ; ty' <- tc_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } + | otherwise + = do { ctxt' <- tc_hs_context mode ctxt + + ; ek <- newOpenTypeKind -- The body kind (result of the function) can + -- be TYPE r, for any r, hence newOpenTypeKind + ; ty' <- tc_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpectedKind (unLoc rn_ty) res_ty + liftedTypeKind kind } --------- Lists, arrays, and tuples -tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind +tc_hs_type_exp mode rn_ty@(HsListTy _ elt_ty) exp_kind = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" +tc_hs_type_exp mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } - - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind - -tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds @@ -1269,26 +1203,28 @@ tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples -tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind -- The '[] case is handled in tc_infer_hs_type. -- See Note [Future-proofing the type checker]. | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] -tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar @@ -1297,49 +1233,117 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types -tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind +tc_hs_type_exp mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) ; ty' <- tc_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } -tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind +tc_hs_type_exp _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals -tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tc_hs_type_exp mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek +--------- Infer +tc_hs_type_exp mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind + +tc_hs_type_exp mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tc_hs_type_exp:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tc_hs_type_exp _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tc_hs_type_exp tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tc_hs_type_exp tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * + + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind + +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty {- Note [Variable Specificity and Forall Visibility] @@ -1530,9 +1534,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1551,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -4355,7 +4363,7 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind + do { ek <- newExpectedKind ctxt_kind ; ty <- tc_lhs_type mode hs_ty ek ; return (wcs, ty) } ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,9 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + -- Is that safe? + fillInferResult, ) where import GHC.Prelude ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8afa1b09393deadd4d509514cd8065e3f7ae4ce2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8afa1b09393deadd4d509514cd8065e3f7ae4ce2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 14:02:07 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 13 Mar 2024 10:02:07 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy Message-ID: <65f1b1df1e365_29bf3d875262099522@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 1eb6c06e by Andrei Borzenkov at 2024-03-13T18:01:48+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy - - - - - 6 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout - + testsuite/tests/th/T24299.hs - + testsuite/tests/th/T24299.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -1022,74 +1022,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tc_hs_type_exp mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1144,15 +1083,33 @@ tc_lhs_type mode (L span ty) exp_kind tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -- See Note [Bidirectional type checking] +tc_hs_type mode ty ek = tc_hs_type_exp mode ty (Check ek) + +type ExpKind = ExpType + +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + +tc_lhs_type_exp :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType +tc_lhs_type_exp mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_hs_type_exp mode ty exp_kind + +tc_hs_type_exp :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +-- See Note [Bidirectional type checking] -tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type mode (HsDocTy _ ty _) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type _ ty@(HsBangTy _ bang _) _ +tc_hs_type_exp mode (HsParTy _ ty) exp_kind = tc_lhs_type_exp mode ty exp_kind +tc_hs_type_exp mode (HsDocTy _ ty _) exp_kind = tc_lhs_type_exp mode ty exp_kind +tc_hs_type_exp _ ty@(HsBangTy _ bang _) _ -- While top-level bangs at this point are eliminated (eg !(Maybe Int)), -- other kinds of bangs are not (eg ((!Maybe) Int)). These kinds of -- bangs are invalid, so fail. (#7210, #14761) = failWith $ TcRnUnexpectedAnnotation ty bang -tc_hs_type _ ty@(HsRecTy {}) _ +tc_hs_type_exp _ ty@(HsRecTy {}) _ -- Record types (which only show up temporarily in constructor -- signatures) should have been removed by now = failWithTc $ TcRnIllegalRecordSyntax (Right ty) @@ -1162,23 +1119,25 @@ tc_hs_type _ ty@(HsRecTy {}) _ -- while capturing the local environment. -- -- See Note [Delaying modFinalizers in untyped splices]. -tc_hs_type mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) +tc_hs_type_exp mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) exp_kind = do addModFinalizersWithLclEnv mod_finalizers - tc_lhs_type mode ty exp_kind + tc_lhs_type_exp mode ty exp_kind -tc_hs_type _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type: invalid nested splice" (pprUntypedSplice True (Just n) s) +tc_hs_type_exp _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type_exp: invalid nested splice" (pprUntypedSplice True (Just n) s) ---------- Functions and applications -tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind - = tc_fun_type mode mult ty1 ty2 exp_kind +tc_hs_type_exp mode (HsFunTy _ mult ty1 ty2) exp_kind + = do k <- expTypeToType exp_kind + tc_fun_type mode mult ty1 ty2 k -tc_hs_type mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind +tc_hs_type_exp mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind | op `hasKey` unrestrictedFunTyConKey - = tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 exp_kind + = do k <- expTypeToType exp_kind + tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 k --------- Foralls -tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind +tc_hs_type_exp mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllInvis{} <- tele = tc_hs_forall_ty tele ty exp_kind -- For an invisible forall, we allow the body to have @@ -1187,15 +1146,15 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] where tc_hs_forall_ty tele ty ek = do { (tv_bndrs, ty') <- tcTKTelescope mode tele $ - tc_lhs_type mode ty ek + tc_lhs_type_exp mode ty ek -- Pass on the mode from the type, to any wildcards -- in kind signatures on the forall'd variables -- e.g. f :: _ -> Int -> forall (a :: _). blah @@ -1203,65 +1162,40 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind -- Do not kind-generalise here! See Note [Kind generalisation] ; return (mkForAllTys tv_bndrs ty') } -tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind - | null (unLoc ctxt) - = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind - = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } +tc_hs_type_exp mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_qual_ty k + where + tc_hs_qual_ty kind + | null (unLoc ctxt) + = tc_lhs_type mode rn_ty kind - | otherwise - = do { ctxt' <- tc_hs_context mode ctxt - - ; ek <- newOpenTypeKind -- The body kind (result of the function) can - -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + -- See Note [Body kind of a HsQualTy] + | isConstraintLikeKind kind + = do { ctxt' <- tc_hs_context mode ctxt + ; ty' <- tc_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } + | otherwise + = do { ctxt' <- tc_hs_context mode ctxt + + ; ek <- newOpenTypeKind -- The body kind (result of the function) can + -- be TYPE r, for any r, hence newOpenTypeKind + ; ty' <- tc_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpectedKind (unLoc rn_ty) res_ty + liftedTypeKind kind } --------- Lists, arrays, and tuples -tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind +tc_hs_type_exp mode rn_ty@(HsListTy _ elt_ty) exp_kind = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" +tc_hs_type_exp mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } - - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind - -tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds @@ -1269,26 +1203,28 @@ tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples -tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind -- The '[] case is handled in tc_infer_hs_type. -- See Note [Future-proofing the type checker]. | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] -tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar @@ -1297,49 +1233,117 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types -tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind +tc_hs_type_exp mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) ; ty' <- tc_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } -tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind +tc_hs_type_exp _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals -tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tc_hs_type_exp mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek +--------- Infer +tc_hs_type_exp mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind + +tc_hs_type_exp mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tc_hs_type_exp:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tc_hs_type_exp _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tc_hs_type_exp tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tc_hs_type_exp tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * + + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind + +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty {- Note [Variable Specificity and Forall Visibility] @@ -1530,9 +1534,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1551,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -4355,7 +4363,7 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind + do { ek <- newExpectedKind ctxt_kind ; ty <- tc_lhs_type mode hs_ty ek ; return (wcs, ty) } ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,9 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + -- Is that safe? + fillInferResult, ) where import GHC.Prelude ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * ===================================== testsuite/tests/th/T24299.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24299 where +import Language.Haskell.TH.Syntax (addModFinalizer, runIO) +import GHC.Types (Type) + +type Proxy :: forall a. a -> Type +data Proxy a = MkProxy + +check :: ($(addModFinalizer (runIO (putStrLn "check")) >> + [t| Proxy |]) :: Type -> Type) Int -- There is kind signature, we are in check mode +check = MkProxy + +infer :: ($(addModFinalizer (runIO (putStrLn "infer")) >> + [t| Proxy |]) ) Int -- no kind signature, inference mode is enabled +infer = MkProxy ===================================== testsuite/tests/th/T24299.stderr ===================================== @@ -0,0 +1,2 @@ +check +infer ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24299', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1eb6c06e63f0faa03d7c7a1f6c9eb5aa97967153 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1eb6c06e63f0faa03d7c7a1f6c9eb5aa97967153 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 14:31:02 2024 From: gitlab at gitlab.haskell.org (Ben Orchard (@raehik)) Date: Wed, 13 Mar 2024 10:31:02 -0400 Subject: [Git][ghc/ghc][wip/raehik/primop-array-mutability-docs] Note mutability of array and address access primops Message-ID: <65f1b8a662e88_29bf3d9567954102382@gitlab.mail> Ben Orchard pushed to branch wip/raehik/primop-array-mutability-docs at Glasgow Haskell Compiler / GHC Commits: 1dfe742f by Ben Orchard at 2024-03-13T14:19:37+00:00 Note mutability of array and address access primops Without understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature. This adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 1 changed file: - utils/genprimopcode/AccessOps.hs Changes: ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1dfe742fdbcdb001dc99e67ff9f09db3a84d9c6c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1dfe742fdbcdb001dc99e67ff9f09db3a84d9c6c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 14:36:04 2024 From: gitlab at gitlab.haskell.org (Ben Orchard (@raehik)) Date: Wed, 13 Mar 2024 10:36:04 -0400 Subject: [Git][ghc/ghc][wip/raehik/primop-array-mutability-docs] Note mutability of array and address access primops Message-ID: <65f1b9d4858cf_29bf3d95fc3b010259@gitlab.mail> Ben Orchard pushed to branch wip/raehik/primop-array-mutability-docs at Glasgow Haskell Compiler / GHC Commits: f4d3406d by Ben Orchard at 2024-03-13T14:31:08+00:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 1 changed file: - utils/genprimopcode/AccessOps.hs Changes: ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4d3406d13abb4a32020d303181982be7800f5ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4d3406d13abb4a32020d303181982be7800f5ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 16:06:10 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 13 Mar 2024 12:06:10 -0400 Subject: [Git][ghc/ghc][wip/or-pats] Implement Or Patterns (#22596) Message-ID: <65f1cef2c1e85_29bf3dc0a9ec81153e0@gitlab.mail> Sebastian Graf pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 1bd60794 by David Knothe at 2024-03-13T17:06:00+01:00 Implement Or Patterns (#22596) This commit introduces a new language extension, `-XOrPatterns`, as described in GHC Proposal 522. An or-pattern `pat1; ...; patk` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. See also the summary `Note [Implmentation of OrPatterns]`. Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> - - - - - 30 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/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/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs - + docs/users_guide/exts/or_patterns.rst - docs/users_guide/exts/patterns.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bd60794813b00c47d20931847e8790ccf062378 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bd60794813b00c47d20931847e8790ccf062378 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 19:36:10 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 13 Mar 2024 15:36:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Remove duplicate code normalising slashes Message-ID: <65f2002a99922_29bf3d11d21bd814227@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 19dfb9b7 by Andreas Klebinger at 2024-03-13T15:35:35-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - 026033de by Ben Orchard at 2024-03-13T15:35:36-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 20 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c - rts/RtsFlags.c - testsuite/driver/testlib.py - testsuite/tests/parser/should_fail/T21843a.stderr - testsuite/tests/parser/should_fail/T21843b.stderr - testsuite/tests/parser/should_fail/T21843c.stderr - testsuite/tests/parser/should_fail/T21843d.stderr - testsuite/tests/parser/should_fail/T21843e.stderr - testsuite/tests/parser/should_fail/T21843f.stderr - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T - utils/genprimopcode/AccessOps.hs Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== compiler/GHC/Types/Unique/Supply.hs ===================================== @@ -7,7 +7,6 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE UnliftedFFITypes #-} module GHC.Types.Unique.Supply ( -- * Main data type @@ -49,16 +48,16 @@ import Foreign.Storable #define NO_FETCH_ADD #endif -#if defined(javascript_HOST_ARCH) -import GHC.Exts ( atomicCasWord64Addr#, eqWord64# ) -#elif !defined(NO_FETCH_ADD) -import GHC.Exts( fetchAddWordAddr#, word64ToWord#, wordToWord64# ) +#if defined(NO_FETCH_ADD) +import GHC.Exts ( atomicCasWord64Addr#, eqWord64#, readWord64OffAddr# ) +#else +import GHC.Exts( fetchAddWordAddr#, word64ToWord# ) #endif import GHC.Exts ( Addr#, State#, Word64#, RealWorld ) - +import GHC.Int ( Int(..) ) import GHC.Word( Word64(..) ) -import GHC.Exts( plusWord64#, readWord64OffAddr# ) +import GHC.Exts( plusWord64#, int2Word#, wordToWord64# ) {- ************************************************************************ @@ -233,8 +232,9 @@ mkSplitUniqSupply c (# s4, MkSplitUniqSupply (tag .|. u) x y #) }}}} -#if defined(javascript_HOST_ARCH) --- CAS-based pure Haskell implementation +#if defined(NO_FETCH_ADD) +-- GHC currently does not provide this operation on 32-bit platforms, +-- hence the CAS-based implementation. fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# = go @@ -246,35 +246,7 @@ fetchAddWord64Addr# = go (# s2, res #) | 1# <- res `eqWord64#` n0 -> (# s2, n0 #) | otherwise -> go ptr inc s2 - -#elif defined(NO_FETCH_ADD) - --- atomic_inc64 is defined in compiler/cbits/genSym.c. This is of --- course not ideal, but we need to live with it for now given the --- current situation: --- 1. There's no Haskell primop fetchAddWord64Addr# on 32-bit --- platforms yet --- 2. The Cmm %fetch_add64 primop syntax is only present in ghc 9.8 --- but we currently bootstrap from older ghc in our CI --- 3. The Cmm MO_AtomicRMW operation with 64-bit width is well --- supported on 32-bit platforms already, but the plumbing from --- either Haskell or Cmm doesn't work yet because of 1 or 2 --- 4. There's hs_atomic_add64 in ghc-prim cbits that we ought to use, --- but it's only available on 32-bit starting from ghc 9.8 --- 5. The pure Haskell implementation causes mysterious i386 --- regression in unrelated ghc work that can only be fixed by the C --- version here - -foreign import ccall unsafe "atomic_inc64" atomic_inc64 :: Addr# -> Word64# -> IO Word64 - -fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld - -> (# State# RealWorld, Word64# #) -fetchAddWord64Addr# addr inc s0 = - case unIO (atomic_inc64 addr inc) s0 of - (# s1, W64# res #) -> (# s1, res #) - #else - fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# addr inc s0 = @@ -286,9 +258,9 @@ genSym :: IO Word64 genSym = do let !mask = (1 `unsafeShiftL` uNIQUE_BITS) - 1 let !(Ptr counter) = ghc_unique_counter64 - let !(Ptr inc_ptr) = ghc_unique_inc - u <- IO $ \s0 -> case readWord64OffAddr# inc_ptr 0# s0 of - (# s1, inc #) -> case fetchAddWord64Addr# counter inc s1 of + I# inc# <- peek ghc_unique_inc + let !inc = wordToWord64# (int2Word# inc#) + u <- IO $ \s1 -> case fetchAddWord64Addr# counter inc s1 of (# s2, val #) -> let !u = W64# (val `plusWord64#` inc) .&. mask in (# s2, u #) ===================================== compiler/cbits/genSym.c ===================================== @@ -15,11 +15,3 @@ HsWord64 ghc_unique_counter64 = 0; #if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) HsInt ghc_unique_inc = 1; #endif - -// Only used on 32-bit non-JS platforms -#if WORD_SIZE_IN_BITS != 64 -StgWord64 atomic_inc64(StgWord64 volatile* p, StgWord64 incr) -{ - return __atomic_fetch_add(p, incr, __ATOMIC_SEQ_CST); -} -#endif ===================================== rts/RtsFlags.c ===================================== @@ -1951,6 +1951,9 @@ static void normaliseRtsOpts (void) if (RtsFlags.GcFlags.maxHeapSize != 0 && RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) { + errorBelch("Maximum heap size (-M) is smaller than suggested heap size (-H)\n" + "Setting maximum heap size to suggested heap size ( %" FMT_Word " )", + (StgWord64) RtsFlags.GcFlags.maxHeapSize * (StgWord64) BLOCK_SIZE); RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion; } ===================================== testsuite/driver/testlib.py ===================================== @@ -1119,8 +1119,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): @@ -1491,7 +1491,7 @@ async def do_test(name: TestName, if opts.expect not in ['pass', 'fail', 'missing-lib']: framework_fail(name, way, 'bad expected ' + opts.expect) - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) if way in opts.fragile_ways: if_verbose(1, '*** fragile test %s resulted in %s' % (full_name, 'pass' if result.passed else 'fail')) @@ -1538,7 +1538,7 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') @@ -1549,7 +1549,7 @@ def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str def framework_warn(name: TestName, way: WayName, reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = name + '(' + way + ')' if_verbose(1, '*** framework warning for %s %s ' % (full_name, reason)) t.framework_warnings.append(TestResult(directory, name, reason, way)) @@ -2598,8 +2598,9 @@ def normalise_errmsg(s: str) -> str: s = normalise_callstacks(s) s = normalise_type_reps(s) - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + # normalise slashes to minimise Windows/Unix filename differences, + # but don't normalize backslashes in chars + s = re.sub(r"(?!')\\", '/', s) # Normalize the name of the GHC executable. Specifically, # this catches the cases that: @@ -2614,14 +2615,11 @@ def normalise_errmsg(s: str) -> str: # the colon is there because it appears in error messages; this # hacky solution is used in place of more sophisticated filename # mangling - s = re.sub('([^\\s])\\.exe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) # Same thing for .wasm modules generated by the Wasm backend - s = re.sub('([^\\s])\\.wasm', '\\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) # Same thing for .jsexe directories generated by the JS backend - s = re.sub('([^\\s])\\.jsexe', '\\1', s) - - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) # hpc executable is given ghc suffix s = re.sub('hpc-ghc', 'hpc', s) @@ -2631,8 +2629,8 @@ def normalise_errmsg(s: str) -> str: s = re.sub('ghc-stage[123]', 'ghc', s) # Remove platform prefix (e.g. javascript-unknown-ghcjs) for cross-compiled tools # (ghc, ghc-pkg, unlit, etc.) - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) - s = re.sub('\\w+(-\\w+)*-unlit', 'unlit', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-unlit', 'unlit', s) # On windows error messages can mention versioned executables s = re.sub('ghc-[0-9.]+', 'ghc', s) @@ -2735,8 +2733,8 @@ def normalise_prof (s: str) -> str: return s def normalise_slashes_( s: str ) -> str: - s = re.sub('\\\\', '/', s) - s = re.sub('//', '/', s) + s = re.sub(r'\\', '/', s) + s = re.sub(r'//', '/', s) return s def normalise_exe_( s: str ) -> str: @@ -2754,9 +2752,9 @@ def normalise_output( s: str ) -> str: # and .wasm extension (for the Wasm backend) # 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])\\.wasm', '\\1', s) - s = re.sub('([^\\s])\\.jsexe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is @@ -2776,7 +2774,7 @@ def normalise_output( s: str ) -> str: s = re.sub('.*warning: argument unused during compilation:.*\n', '', s) # strip the cross prefix if any - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) return s ===================================== testsuite/tests/parser/should_fail/T21843a.stderr ===================================== @@ -1,4 +1,4 @@ T21843a.hs:3:13: [GHC-31623] - Unicode character '“' ('/8220') looks like '"' (Quotation Mark), but it is not + Unicode character '“' ('\8220') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843b.stderr ===================================== @@ -1,3 +1,3 @@ T21843b.hs:3:11: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843c.stderr ===================================== @@ -1,6 +1,6 @@ T21843c.hs:3:19: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not T21843c.hs:3:20: [GHC-21231] - lexical error in string/character literal at character '/n' + lexical error in string/character literal at character '\n' ===================================== testsuite/tests/parser/should_fail/T21843d.stderr ===================================== @@ -1,3 +1,3 @@ T21843d.hs:3:13: [GHC-31623] - Unicode character '’' ('/8217') looks like ''' (Single Quote), but it is not + Unicode character '’' ('\8217') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843e.stderr ===================================== @@ -1,3 +1,3 @@ T21843e.hs:3:15: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843f.stderr ===================================== @@ -1,3 +1,3 @@ T21843f.hs:3:13: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accommodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a999d85560752ad7d66159a70ef1b9e7cff4c41...026033dee79a59057340b0fe0fc99c096efb7fcf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a999d85560752ad7d66159a70ef1b9e7cff4c41...026033dee79a59057340b0fe0fc99c096efb7fcf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 22:32:59 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 13 Mar 2024 18:32:59 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] 49 commits: ghc-internal: Eliminate GHC.Internal.Data.Kind Message-ID: <65f2299be2939_269833f8d3443271c@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 8ec9a1f2 by Ben Gamari at 2024-03-13T18:32:39-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 6dd1498f by Ben Gamari at 2024-03-13T18:32:39-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - 28c8e644 by Ben Gamari at 2024-03-13T18:32:39-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 07e986d4 by Ben Gamari at 2024-03-13T18:32:39-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/GHC/Utils/Binary.hs - compiler/cbits/genSym.c - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7553df3897c2170b42fbbfbc254fff85e9c0bb10...07e986d4a4611ccda5ea6c6d913a21837cf69f75 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7553df3897c2170b42fbbfbc254fff85e9c0bb10...07e986d4a4611ccda5ea6c6d913a21837cf69f75 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 23:04:41 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 13 Mar 2024 19:04:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24533-missing-comments Message-ID: <65f23109545f7_269834e2da70347c9@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24533-missing-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24533-missing-comments You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 23:22:08 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 13 Mar 2024 19:22:08 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.10.1-alpha1 Message-ID: <65f235207419b_2698356c44f44092b@gitlab.mail> Ben Gamari pushed new tag ghc-9.10.1-alpha1 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.10.1-alpha1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 13 23:22:43 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 13 Mar 2024 19:22:43 -0400 Subject: [Git][ghc/ghc][ghc-9.10] 62 commits: rts: expose HeapAlloc.h as public header Message-ID: <65f235434133a_26983577bc44411c7@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - 09d92280 by Ben Gamari at 2024-03-12T10:14:28-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - a27a477d by Ben Gamari at 2024-03-12T10:14:28-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 63928aeb by Ben Gamari at 2024-03-12T10:14:28-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 2e713fdb by Ben Gamari at 2024-03-12T10:14:28-04:00 gitlab-ci: Allow test-primops to fail It's still a bit sensitive to warnings, unfortunately. - - - - - 66c51e75 by Ben Gamari at 2024-03-12T10:14:28-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - d574a10d by Ben Gamari at 2024-03-12T10:14:28-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 9f85900d by Ben Gamari at 2024-03-13T08:59:50-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 47272633 by Ben Gamari at 2024-03-13T18:21:37-04:00 docs: Drop old release notes - - - - - db8a17a0 by Ben Gamari at 2024-03-13T18:33:12-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - b55e0ef9 by Ben Gamari at 2024-03-13T18:33:17-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21e3f3250e88640087a1a60bee2cc113bf04509f...b55e0ef930f93c13e0f23ed7e129247fb06af9d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21e3f3250e88640087a1a60bee2cc113bf04509f...b55e0ef930f93c13e0f23ed7e129247fb06af9d2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 00:12:24 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Wed, 13 Mar 2024 20:12:24 -0400 Subject: [Git][ghc/ghc][wip/improve-Word32ToInteger-on-64bit] Improve toInteger @Word32 on 64-bit platforms Message-ID: <65f240e86ba5d_2698373ef5604832@gitlab.mail> Matthew Craven pushed to branch wip/improve-Word32ToInteger-on-64bit at Glasgow Haskell Compiler / GHC Commits: 5c7c67e9 by Matthew Craven at 2024-03-13T20:11:38-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 2 changed files: - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/Word.hs Changes: ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.21.0.0 *TBA* + * Improve `toInteger :: Word32 -> Integer` on 64-bit platforms ([CLC proposal #259](https://github.com/haskell/core-libraries-committee/issues/259)) + ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * The top-level handler for uncaught exceptions now displays the output of `displayException` rather than `show` ([CLC proposal #198](https://github.com/haskell/core-libraries-committee/issues/198)) ===================================== libraries/ghc-internal/src/GHC/Internal/Word.hs ===================================== @@ -592,7 +592,13 @@ instance Integral Word32 where mod x y = rem x y divMod x y = quotRem x y - toInteger (W32# x#) = integerFromWord# (word32ToWord# x#) + toInteger (W32# x#) = +#if WORD_SIZE_IN_BITS > 32 + -- In this case the conversion to Int# cannot overflow. + IS (word2Int# (word32ToWord# x#)) +#else + integerFromWord# (word32ToWord# x#) +#endif -- | @since base-2.01 instance Bits Word32 where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c7c67e9a9dcea2e0293c68224e3fad12a08afc6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c7c67e9a9dcea2e0293c68224e3fad12a08afc6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 07:15:32 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 14 Mar 2024 03:15:32 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy Message-ID: <65f2a4141edf5_2b6bf25553d1833955@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 1bcd70ed by Andrei Borzenkov at 2024-03-14T11:15:11+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy - - - - - 6 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout - + testsuite/tests/th/T24299.hs - + testsuite/tests/th/T24299.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -1022,74 +1022,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tc_hs_type_exp mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1144,15 +1083,33 @@ tc_lhs_type mode (L span ty) exp_kind tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -- See Note [Bidirectional type checking] +tc_hs_type mode ty ek = tc_hs_type_exp mode ty (Check ek) + +type ExpKind = ExpType + +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + +tc_lhs_type_exp :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType +tc_lhs_type_exp mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_hs_type_exp mode ty exp_kind + +tc_hs_type_exp :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +-- See Note [Bidirectional type checking] -tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type mode (HsDocTy _ ty _) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type _ ty@(HsBangTy _ bang _) _ +tc_hs_type_exp mode (HsParTy _ ty) exp_kind = tc_lhs_type_exp mode ty exp_kind +tc_hs_type_exp mode (HsDocTy _ ty _) exp_kind = tc_lhs_type_exp mode ty exp_kind +tc_hs_type_exp _ ty@(HsBangTy _ bang _) _ -- While top-level bangs at this point are eliminated (eg !(Maybe Int)), -- other kinds of bangs are not (eg ((!Maybe) Int)). These kinds of -- bangs are invalid, so fail. (#7210, #14761) = failWith $ TcRnUnexpectedAnnotation ty bang -tc_hs_type _ ty@(HsRecTy {}) _ +tc_hs_type_exp _ ty@(HsRecTy {}) _ -- Record types (which only show up temporarily in constructor -- signatures) should have been removed by now = failWithTc $ TcRnIllegalRecordSyntax (Right ty) @@ -1162,23 +1119,25 @@ tc_hs_type _ ty@(HsRecTy {}) _ -- while capturing the local environment. -- -- See Note [Delaying modFinalizers in untyped splices]. -tc_hs_type mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) +tc_hs_type_exp mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) exp_kind = do addModFinalizersWithLclEnv mod_finalizers - tc_lhs_type mode ty exp_kind + tc_lhs_type_exp mode ty exp_kind -tc_hs_type _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type: invalid nested splice" (pprUntypedSplice True (Just n) s) +tc_hs_type_exp _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type_exp: invalid nested splice" (pprUntypedSplice True (Just n) s) ---------- Functions and applications -tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind - = tc_fun_type mode mult ty1 ty2 exp_kind +tc_hs_type_exp mode (HsFunTy _ mult ty1 ty2) exp_kind + = do k <- expTypeToType exp_kind + tc_fun_type mode mult ty1 ty2 k -tc_hs_type mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind +tc_hs_type_exp mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind | op `hasKey` unrestrictedFunTyConKey - = tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 exp_kind + = do k <- expTypeToType exp_kind + tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 k --------- Foralls -tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind +tc_hs_type_exp mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllInvis{} <- tele = tc_hs_forall_ty tele ty exp_kind -- For an invisible forall, we allow the body to have @@ -1187,15 +1146,15 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] where tc_hs_forall_ty tele ty ek = do { (tv_bndrs, ty') <- tcTKTelescope mode tele $ - tc_lhs_type mode ty ek + tc_lhs_type_exp mode ty ek -- Pass on the mode from the type, to any wildcards -- in kind signatures on the forall'd variables -- e.g. f :: _ -> Int -> forall (a :: _). blah @@ -1203,65 +1162,40 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind -- Do not kind-generalise here! See Note [Kind generalisation] ; return (mkForAllTys tv_bndrs ty') } -tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind - | null (unLoc ctxt) - = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind - = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } +tc_hs_type_exp mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_qual_ty k + where + tc_hs_qual_ty kind + | null (unLoc ctxt) + = tc_lhs_type mode rn_ty kind - | otherwise - = do { ctxt' <- tc_hs_context mode ctxt - - ; ek <- newOpenTypeKind -- The body kind (result of the function) can - -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + -- See Note [Body kind of a HsQualTy] + | isConstraintLikeKind kind + = do { ctxt' <- tc_hs_context mode ctxt + ; ty' <- tc_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } + | otherwise + = do { ctxt' <- tc_hs_context mode ctxt + + ; ek <- newOpenTypeKind -- The body kind (result of the function) can + -- be TYPE r, for any r, hence newOpenTypeKind + ; ty' <- tc_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpectedKind (unLoc rn_ty) res_ty + liftedTypeKind kind } --------- Lists, arrays, and tuples -tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind +tc_hs_type_exp mode rn_ty@(HsListTy _ elt_ty) exp_kind = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" +tc_hs_type_exp mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } - - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind - -tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds @@ -1269,26 +1203,28 @@ tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples -tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind -- The '[] case is handled in tc_infer_hs_type. -- See Note [Future-proofing the type checker]. | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] -tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind +tc_hs_type_exp mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar @@ -1297,49 +1233,117 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types -tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind +tc_hs_type_exp mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) ; ty' <- tc_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } -tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind +tc_hs_type_exp _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals -tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } +tc_hs_type_exp _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tc_hs_type_exp mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek +--------- Infer +tc_hs_type_exp mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type_exp mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind + +tc_hs_type_exp mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tc_hs_type_exp:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tc_hs_type_exp _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tc_hs_type_exp tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tc_hs_type_exp tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * + + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind + +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty {- Note [Variable Specificity and Forall Visibility] @@ -1530,9 +1534,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1551,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -4355,7 +4363,7 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind + do { ek <- newExpectedKind ctxt_kind ; ty <- tc_lhs_type mode hs_ty ek ; return (wcs, ty) } ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,9 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + -- Is that safe? + fillInferResult, ) where import GHC.Prelude ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * ===================================== testsuite/tests/th/T24299.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24299 where +import Language.Haskell.TH.Syntax (addModFinalizer, runIO) +import GHC.Types (Type) +import System.IO + +type Proxy :: forall a. a -> Type +data Proxy a = MkProxy + +check :: ($(addModFinalizer (runIO (do putStrLn "check"; hFlush stdout)) >> + [t| Proxy |]) :: Type -> Type) Int -- There is kind signature, we are in check mode +check = MkProxy + +infer :: ($(addModFinalizer (runIO (do putStrLn "infer"; hFlush stdout)) >> + [t| Proxy |]) ) Int -- no kind signature, inference mode is enabled +infer = MkProxy ===================================== testsuite/tests/th/T24299.stderr ===================================== @@ -0,0 +1,2 @@ +check +infer ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24299', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bcd70ed195e52c41dd1b65203431037645d89a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bcd70ed195e52c41dd1b65203431037645d89a6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 08:52:19 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 14 Mar 2024 04:52:19 -0400 Subject: [Git][ghc/ghc][wip/or-pats] Implement Or Patterns (#22596) Message-ID: <65f2bac3bd0ae_2b6bf27d4694c4033d@gitlab.mail> Sebastian Graf pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 14a1c35c by David Knothe at 2024-03-14T09:52:13+01:00 Implement Or Patterns (#22596) This commit introduces a new language extension, `-XOrPatterns`, as described in GHC Proposal 522. An or-pattern `pat1; ...; patk` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. See also the summary `Note [Implmentation of OrPatterns]`. Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> - - - - - 30 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/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/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs - + docs/users_guide/exts/or_patterns.rst - docs/users_guide/exts/patterns.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/14a1c35cc51a0baa14fde85b8bf4c28dfc6120b0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/14a1c35cc51a0baa14fde85b8bf4c28dfc6120b0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 09:40:45 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 14 Mar 2024 05:40:45 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Note mutability of array and address access primops Message-ID: <65f2c61ceffef_2b6bf291d0200493e0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 70043eba by Ben Orchard at 2024-03-14T05:40:34-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 53f757e4 by Alan Zimmerman at 2024-03-14T05:40:34-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 6 changed files: - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24533.hs - + testsuite/tests/printer/Test24533.stdout - testsuite/tests/printer/all.T - utils/genprimopcode/AccessOps.hs Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1135,8 +1135,8 @@ checkCmdBlockArguments :: LHsCmd GhcPs -> PV () -- (((Eq a))) --> [Eq a] -- @ checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) -checkContext orig_t@(L (EpAnn l _ _) _orig_t) = - check ([],[],emptyComments) orig_t +checkContext orig_t@(L (EpAnn l _ cs) _orig_t) = + check ([],[],cs) orig_t where check :: ([EpaLocation],[EpaLocation],EpAnnComments) -> LHsType GhcPs -> P (LHsContext GhcPs) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -816,3 +816,8 @@ Test23885: AnnotationNoListTuplePuns: $(CHECK_PPR) $(LIBDIR) AnnotationNoListTuplePuns.hs $(CHECK_EXACT) $(LIBDIR) AnnotationNoListTuplePuns.hs + +.PHONY: Test24533 +Test24533: + $(CHECK_PPR) $(LIBDIR) Test24533.hs + $(CHECK_EXACT) $(LIBDIR) Test24533.hs ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -ddump-parsed-ast #-} +module Test24533 where + +instance + ( Read a, -- Weird + Read b + ) => + Read (a, b) ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -0,0 +1,548 @@ + +==================== Parser AST ==================== + +(L + { Test24533.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.hs:9:1 } + { Test24533.hs:8:13 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.hs:(4,1)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:4:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(7,3) }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.hs:7:5-6 }))) + [(EpaSpan { Test24533.hs:5:3 })] + [(EpaSpan { Test24533.hs:7:3 })]) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:5:13-20 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:5:11 }))])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:5:5-10 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:5:11 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:6:5-10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:8-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.hs:8:8 }) + (EpaSpan { Test24533.hs:8:13 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:8:10 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) + + + +==================== Parser AST ==================== + +(L + { Test24533.ppr.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.ppr.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.ppr.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.ppr.hs:3:41 } + { Test24533.ppr.hs:3:40 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.ppr.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.ppr.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:1-40 }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:3:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-25 }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.ppr.hs:3:27-28 }))) + [(EpaSpan { Test24533.ppr.hs:3:10 })] + [(EpaSpan { Test24533.ppr.hs:3:25 })]) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-16 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:17 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:35-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.ppr.hs:3:35 }) + (EpaSpan { Test24533.ppr.hs:3:40 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:37 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -196,3 +196,4 @@ test('Test23887', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23887']) test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) +test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/026033dee79a59057340b0fe0fc99c096efb7fcf...53f757e4cc6f6708af3483f17c6812859495ef93 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/026033dee79a59057340b0fe0fc99c096efb7fcf...53f757e4cc6f6708af3483f17c6812859495ef93 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 10:28:27 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 14 Mar 2024 06:28:27 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/9.10-windows-configure Message-ID: <65f2d14b32e83_2b6bf2a6c2c085519@gitlab.mail> Zubin pushed new branch wip/9.10-windows-configure at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/9.10-windows-configure You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 11:46:40 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 14 Mar 2024 07:46:40 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/windows-topdir Message-ID: <65f2e3a0a7098_2b6bf2c7e468459567@gitlab.mail> Zubin pushed new branch wip/windows-topdir at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/windows-topdir You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 12:45:19 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 14 Mar 2024 08:45:19 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24251a Message-ID: <65f2f15f9402c_dbb551a35f7470f8@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24251a at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24251a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 13:01:03 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 14 Mar 2024 09:01:03 -0400 Subject: [Git][ghc/ghc][master] Note mutability of array and address access primops Message-ID: <65f2f50fe6def_dbb5522e20b411957@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 1 changed file: - utils/genprimopcode/AccessOps.hs Changes: ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77171cd1d482dbb2776ee06b2454cc2176a891ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77171cd1d482dbb2776ee06b2454cc2176a891ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 13:01:55 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 14 Mar 2024 09:01:55 -0400 Subject: [Git][ghc/ghc][master] EPA: Fix regression discarding comments in contexts Message-ID: <65f2f5431d608_dbb55248fc7c167b8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 5 changed files: - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24533.hs - + testsuite/tests/printer/Test24533.stdout - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1135,8 +1135,8 @@ checkCmdBlockArguments :: LHsCmd GhcPs -> PV () -- (((Eq a))) --> [Eq a] -- @ checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) -checkContext orig_t@(L (EpAnn l _ _) _orig_t) = - check ([],[],emptyComments) orig_t +checkContext orig_t@(L (EpAnn l _ cs) _orig_t) = + check ([],[],cs) orig_t where check :: ([EpaLocation],[EpaLocation],EpAnnComments) -> LHsType GhcPs -> P (LHsContext GhcPs) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -816,3 +816,8 @@ Test23885: AnnotationNoListTuplePuns: $(CHECK_PPR) $(LIBDIR) AnnotationNoListTuplePuns.hs $(CHECK_EXACT) $(LIBDIR) AnnotationNoListTuplePuns.hs + +.PHONY: Test24533 +Test24533: + $(CHECK_PPR) $(LIBDIR) Test24533.hs + $(CHECK_EXACT) $(LIBDIR) Test24533.hs ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -ddump-parsed-ast #-} +module Test24533 where + +instance + ( Read a, -- Weird + Read b + ) => + Read (a, b) ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -0,0 +1,548 @@ + +==================== Parser AST ==================== + +(L + { Test24533.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.hs:9:1 } + { Test24533.hs:8:13 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.hs:(4,1)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:4:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(7,3) }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.hs:7:5-6 }))) + [(EpaSpan { Test24533.hs:5:3 })] + [(EpaSpan { Test24533.hs:7:3 })]) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:5:13-20 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:5:11 }))])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:5:5-10 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:5:11 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:6:5-10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:8-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.hs:8:8 }) + (EpaSpan { Test24533.hs:8:13 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:8:10 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) + + + +==================== Parser AST ==================== + +(L + { Test24533.ppr.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.ppr.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.ppr.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.ppr.hs:3:41 } + { Test24533.ppr.hs:3:40 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.ppr.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.ppr.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:1-40 }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:3:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-25 }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.ppr.hs:3:27-28 }))) + [(EpaSpan { Test24533.ppr.hs:3:10 })] + [(EpaSpan { Test24533.ppr.hs:3:25 })]) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-16 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:17 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:35-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.ppr.hs:3:35 }) + (EpaSpan { Test24533.ppr.hs:3:40 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:37 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -196,3 +196,4 @@ test('Test23887', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23887']) test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) +test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7da7f8f643f1bfc4aa034a731f2f85cda007b286 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7da7f8f643f1bfc4aa034a731f2f85cda007b286 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 13:26:09 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 14 Mar 2024 09:26:09 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] rel_env/recompress_all: unxz before recompressing Message-ID: <65f2faf17c82f_dbb55324036c218bf@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: 036aedd0 by Ben Gamari at 2024-03-14T09:25:58-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 1 changed file: - .gitlab/rel_eng/recompress-all Changes: ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -9,15 +9,15 @@ usage : %.gz : %.xz echo "[xz->gz] $< to $@..." - xz -c $< | gzip -c > $@ + xz -cd $< | gzip -c > $@ %.bz2 : %.xz echo "[xz->bz2] $< to $@..." - xz -c $< | bzip2 -c > $@ + xz -cd $< | bzip2 -c > $@ %.lz : %.xz echo "[xz->lz] $< to $@..." - xz -c $< | lzip -c > $@ + xz -cd $< | lzip -c > $@ %.zip : %.tar.xz echo "[tarxz->zip] $< to $@..." View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/036aedd045a523e70260af58b7e8643b5b6daff8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/036aedd045a523e70260af58b7e8643b5b6daff8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 13:48:28 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 14 Mar 2024 09:48:28 -0400 Subject: [Git][ghc/ghc][wip/or-pats] Implement Or Patterns (#22596) Message-ID: <65f3002c184b2_dbb553f1707c2768@gitlab.mail> Sebastian Graf pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 3f5cf4ef by David Knothe at 2024-03-14T14:48:20+01:00 Implement Or Patterns (#22596) This commit introduces a new language extension, `-XOrPatterns`, as described in GHC Proposal 522. An or-pattern `pat1; ...; patk` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. See also the summary `Note [Implmentation of OrPatterns]`. Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> - - - - - 30 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/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/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs - + docs/users_guide/exts/or_patterns.rst - docs/users_guide/exts/patterns.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f5cf4ef92ed7b3a4c36698ea0896f1ca3e70ee6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f5cf4ef92ed7b3a4c36698ea0896f1ca3e70ee6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 15:33:27 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 14 Mar 2024 11:33:27 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Note mutability of array and address access primops Message-ID: <65f318c7eae95_dbb556c5926052556@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - a8a170b5 by Fendor at 2024-03-14T11:33:12-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - e0a1d520 by Fendor at 2024-03-14T11:33:15-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 15 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Settings/IO.hs - hadrian/src/Rules/Generate.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24533.hs - + testsuite/tests/printer/Test24533.stdout - testsuite/tests/printer/all.T - utils/genprimopcode/AccessOps.hs Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1135,8 +1135,8 @@ checkCmdBlockArguments :: LHsCmd GhcPs -> PV () -- (((Eq a))) --> [Eq a] -- @ checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) -checkContext orig_t@(L (EpAnn l _ _) _orig_t) = - check ([],[],emptyComments) orig_t +checkContext orig_t@(L (EpAnn l _ cs) _orig_t) = + check ([],[],cs) orig_t where check :: ([EpaLocation],[EpaLocation],EpAnnComments) -> LHsType GhcPs -> P (LHsContext GhcPs) ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -135,12 +141,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +267,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -416,7 +417,7 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) @@ -431,23 +432,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +572,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== ===================================== testsuite/tests/printer/Makefile ===================================== @@ -816,3 +816,8 @@ Test23885: AnnotationNoListTuplePuns: $(CHECK_PPR) $(LIBDIR) AnnotationNoListTuplePuns.hs $(CHECK_EXACT) $(LIBDIR) AnnotationNoListTuplePuns.hs + +.PHONY: Test24533 +Test24533: + $(CHECK_PPR) $(LIBDIR) Test24533.hs + $(CHECK_EXACT) $(LIBDIR) Test24533.hs ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -ddump-parsed-ast #-} +module Test24533 where + +instance + ( Read a, -- Weird + Read b + ) => + Read (a, b) ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -0,0 +1,548 @@ + +==================== Parser AST ==================== + +(L + { Test24533.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.hs:9:1 } + { Test24533.hs:8:13 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.hs:(4,1)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:4:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(7,3) }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.hs:7:5-6 }))) + [(EpaSpan { Test24533.hs:5:3 })] + [(EpaSpan { Test24533.hs:7:3 })]) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:5:13-20 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:5:11 }))])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:5:5-10 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:5:11 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:6:5-10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:8-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.hs:8:8 }) + (EpaSpan { Test24533.hs:8:13 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:8:10 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) + + + +==================== Parser AST ==================== + +(L + { Test24533.ppr.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.ppr.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.ppr.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.ppr.hs:3:41 } + { Test24533.ppr.hs:3:40 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.ppr.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.ppr.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:1-40 }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:3:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-25 }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.ppr.hs:3:27-28 }))) + [(EpaSpan { Test24533.ppr.hs:3:10 })] + [(EpaSpan { Test24533.ppr.hs:3:25 })]) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-16 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:17 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:35-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.ppr.hs:3:35 }) + (EpaSpan { Test24533.ppr.hs:3:40 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:37 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -196,3 +196,4 @@ test('Test23887', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23887']) test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) +test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/53f757e4cc6f6708af3483f17c6812859495ef93...e0a1d5202af25a49398f266cc011ac281ff8f914 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/53f757e4cc6f6708af3483f17c6812859495ef93...e0a1d5202af25a49398f266cc011ac281ff8f914 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 15:43:11 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 14 Mar 2024 11:43:11 -0400 Subject: [Git][ghc/ghc][wip/T24251a] Wibbles Message-ID: <65f31b0f3401b_dbb5571d919057693@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: ca405979 by Simon Peyton Jones at 2024-03-14T15:42:54+00:00 Wibbles - - - - - 2 changed files: - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -17,7 +17,7 @@ module GHC.Core.Opt.Simplify.Env ( seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, - mkSimplEnv, extendIdSubst, + mkSimplEnv, extendIdSubst, extendCvIdSubst, extendTvSubst, extendCvSubst, zapSubstEnv, setSubstEnv, bumpCaseDepth, getInScope, setInScopeFromE, setInScopeFromF, @@ -550,6 +550,10 @@ extendCvSubst env@(SimplEnv {seCvSubst = csubst}) var co = assert (isCoVar var) $ env {seCvSubst = extendVarEnv csubst var co} +extendCvIdSubst :: SimplEnv -> Id -> OutExpr -> SimplEnv +extendCvIdSubst env bndr (Coercion co) = extendCvSubst env bndr co +extendCvIdSubst env bndr rhs = extendIdSubst env bndr (DoneEx rhs NotJoinPoint) + --------------------- getInScope :: SimplEnv -> InScopeSet getInScope env = seInScope env ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -412,9 +412,7 @@ simplAuxBind env bndr new_rhs -- have no NOLINE pragmas, nor RULEs | exprIsTrivial new_rhs -- Short-cut for let x = y in ... = return ( emptyFloats env - , case new_rhs of - Coercion co -> extendCvSubst env bndr co - _ -> extendIdSubst env bndr (DoneEx new_rhs NotJoinPoint) ) + , extendCvIdSubst env bndr new_rhs ) -- bndr can be a CoVar | otherwise = do { -- ANF-ise the RHS @@ -3062,10 +3060,10 @@ rebuildCase env scrut case_bndr alts@[Alt con bndrs rhs] cont | DEFAULT <- con , exprIsTrivial scrut , isEvaldSoon case_bndr rhs - , let env' = extendIdSubst env case_bndr (DoneEx scrut NotJoinPoint) = assert( null bndrs ) $ do { tick (CaseElim case_bndr) - ; simplExprF env' rhs cont } + ; simplExprF (extendCvIdSubst env case_bndr scrut) rhs cont } + -- case_bndr can be a CoVar -- 2a. Dropping the case altogether, if -- a) it binds nothing (so it's really just a 'seq') View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca405979ea626e3e7bcb137f356320827ff18253 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca405979ea626e3e7bcb137f356320827ff18253 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 15:43:41 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 14 Mar 2024 11:43:41 -0400 Subject: [Git][ghc/ghc][wip/T24251a] 11 commits: Remove duplicate code normalising slashes Message-ID: <65f31b2d47409_dbb5573ad6c4578c9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 25a754c5 by Simon Peyton Jones at 2024-03-14T15:43:15+00:00 Rename tryCaseMerge - - - - - 8b8a269c by Simon Peyton Jones at 2024-03-14T15:43:16+00:00 Try a more clever discard-eval Addresses programs like this f xs = xs `seq` (let t = reverse $ reverse $ reverse $ reverse $ reverse $ reverse xs in case xs of [] -> (t,True) (_:_) -> (t,False)) Also including the case where t is a join point. Relates to #24251. See GHC Log 13 March - - - - - 9975ad57 by Simon Peyton Jones at 2024-03-14T15:43:16+00:00 Wibbles - - - - - 27 changed files: - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c - testsuite/driver/testlib.py - testsuite/tests/parser/should_fail/T21843a.stderr - testsuite/tests/parser/should_fail/T21843b.stderr - testsuite/tests/parser/should_fail/T21843c.stderr - testsuite/tests/parser/should_fail/T21843d.stderr - testsuite/tests/parser/should_fail/T21843e.stderr - testsuite/tests/parser/should_fail/T21843f.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24533.hs - + testsuite/tests/printer/Test24533.stdout - testsuite/tests/printer/all.T - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T - utils/genprimopcode/AccessOps.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -17,7 +17,7 @@ module GHC.Core.Opt.Simplify.Env ( seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, - mkSimplEnv, extendIdSubst, + mkSimplEnv, extendIdSubst, extendCvIdSubst, extendTvSubst, extendCvSubst, zapSubstEnv, setSubstEnv, bumpCaseDepth, getInScope, setInScopeFromE, setInScopeFromF, @@ -550,6 +550,10 @@ extendCvSubst env@(SimplEnv {seCvSubst = csubst}) var co = assert (isCoVar var) $ env {seCvSubst = extendVarEnv csubst var co} +extendCvIdSubst :: SimplEnv -> Id -> OutExpr -> SimplEnv +extendCvIdSubst env bndr (Coercion co) = extendCvSubst env bndr co +extendCvIdSubst env bndr rhs = extendIdSubst env bndr (DoneEx rhs NotJoinPoint) + --------------------- getInScope :: SimplEnv -> InScopeSet getInScope env = seInScope env ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -412,9 +412,7 @@ simplAuxBind env bndr new_rhs -- have no NOLINE pragmas, nor RULEs | exprIsTrivial new_rhs -- Short-cut for let x = y in ... = return ( emptyFloats env - , case new_rhs of - Coercion co -> extendCvSubst env bndr co - _ -> extendIdSubst env bndr (DoneEx new_rhs NotJoinPoint) ) + , extendCvIdSubst env bndr new_rhs ) -- bndr can be a CoVar | otherwise = do { -- ANF-ise the RHS @@ -3053,12 +3051,20 @@ rebuildCase env scrut case_bndr alts cont -- 2. Eliminate the case if scrutinee is evaluated -------------------------------------------------- -rebuildCase env scrut case_bndr alts@[Alt _ bndrs rhs] cont +rebuildCase env scrut case_bndr alts@[Alt con bndrs rhs] cont -- See if we can get rid of the case altogether -- See Note [Case elimination] -- mkCase made sure that if all the alternatives are equal, -- then there is now only one (DEFAULT) rhs + | DEFAULT <- con + , exprIsTrivial scrut + , isEvaldSoon case_bndr rhs + = assert( null bndrs ) $ + do { tick (CaseElim case_bndr) + ; simplExprF (extendCvIdSubst env case_bndr scrut) rhs cont } + -- case_bndr can be a CoVar + -- 2a. Dropping the case altogether, if -- a) it binds nothing (so it's really just a 'seq') -- b) evaluating the scrutinee has no side effects @@ -3106,6 +3112,24 @@ rebuildCase env scrut case_bndr alts cont = reallyRebuildCase env scrut case_bndr alts cont +isEvaldSoon :: InId -> InExpr -> Bool +-- (isEvaldSoon b e) is True is evaluated soon by e +isEvaldSoon bndr expr + = go expr + where + go (Var v) = v==bndr + go (Case scrut cb _ alts) + | Var v <- scrut, v==bndr = True + | otherwise = all go_alt alts && cb /= bndr && all ok_alt alts + -- ok_alt only runs if things look good + go (Let _ e) = go e + go (Tick _ e) = go e + go (Cast e _) = go e + go _ = False + + go_alt (Alt _ _ rhs) = go rhs + ok_alt (Alt _ cbs _) = not (bndr `elem` cbs) + doCaseToLet :: OutExpr -- Scrutinee -> InId -- Case binder -> Bool ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2395,7 +2395,7 @@ Wrinkles This story is not fully robust; it will be defeated by a let-binding, whih we don't want to duplicate. But accounting for single-alternative case-on-variable is easy to do, and seems useful in common cases so - `tryMergeCase` does it. + `tryCaseMerge` does it. Note [Eliminate Identity Case] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2578,7 +2578,7 @@ mkCase, mkCase1, mkCase2, mkCase3 mkCase mode scrut outer_bndr alts_ty alts | sm_case_merge mode - , Just alts' <- tryMergeCase outer_bndr alts + , Just alts' <- tryCaseMerge outer_bndr alts = do { tick (CaseMerge outer_bndr) ; mkCase1 mode scrut outer_bndr alts_ty alts' } -- Warning: don't call mkCase recursively! @@ -2589,9 +2589,9 @@ mkCase mode scrut outer_bndr alts_ty alts | otherwise = mkCase1 mode scrut outer_bndr alts_ty alts -tryMergeCase :: OutId -> [OutAlt] -> Maybe [OutAlt] +tryCaseMerge :: OutId -> [OutAlt] -> Maybe [OutAlt] -- See Note [Merge Nested Cases] -tryMergeCase outer_bndr (Alt DEFAULT _ deflt_rhs : outer_alts) +tryCaseMerge outer_bndr (Alt DEFAULT _ deflt_rhs : outer_alts) = case go 5 (\e -> e) emptyVarSet deflt_rhs of Nothing -> Nothing Just inner_alts -> Just (mergeAlts outer_alts inner_alts) @@ -2630,7 +2630,7 @@ tryMergeCase outer_bndr (Alt DEFAULT _ deflt_rhs : outer_alts) go n wrap free_bndrs (Case (Var inner_scrut) inner_bndr ty inner_alts) | [Alt con bndrs rhs] <- inner_alts -- Wrinkle (MC1) , let wrap_case rhs' = Case (Var inner_scrut) inner_bndr ty $ - tryMergeCase inner_bndr alts `orElse` alts + tryCaseMerge inner_bndr alts `orElse` alts where alts = [Alt con bndrs rhs'] = assert (not (outer_bndr `elem` (inner_bndr : bndrs))) $ @@ -2638,7 +2638,7 @@ tryMergeCase outer_bndr (Alt DEFAULT _ deflt_rhs : outer_alts) go _ _ _ _ = Nothing -tryMergeCase _ _ = Nothing +tryCaseMerge _ _ = Nothing -------------------------------------------------- -- 2. Eliminate Identity Case ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1135,8 +1135,8 @@ checkCmdBlockArguments :: LHsCmd GhcPs -> PV () -- (((Eq a))) --> [Eq a] -- @ checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) -checkContext orig_t@(L (EpAnn l _ _) _orig_t) = - check ([],[],emptyComments) orig_t +checkContext orig_t@(L (EpAnn l _ cs) _orig_t) = + check ([],[],cs) orig_t where check :: ([EpaLocation],[EpaLocation],EpAnnComments) -> LHsType GhcPs -> P (LHsContext GhcPs) ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1922,6 +1922,18 @@ instance Diagnostic TcRnMessage where , text "in a fixity signature" ] + TcRnOutOfArityTyVar ts_name tv_name -> mkDecorated + [ vcat [ text "The arity of" <+> quotes (ppr ts_name) <+> text "is insufficiently high to accommodate" + , text "an implicit binding for the" <+> quotes (ppr tv_name) <+> text "type variable." ] + , suggestion ] + where + suggestion = + text "Use" <+> quotes at_bndr <+> text "on the LHS" <+> + text "or" <+> quotes forall_bndr <+> text "on the RHS" <+> + text "to bring it into scope." + at_bndr = char '@' <> ppr tv_name + forall_bndr = text "forall" <+> ppr tv_name <> text "." + diagnosticReason :: TcRnMessage -> DiagnosticReason diagnosticReason = \case TcRnUnknownMessage m @@ -2556,6 +2568,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnNamespacedFixitySigWithoutFlag{} -> ErrorWithoutFlag + TcRnOutOfArityTyVar{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -3224,6 +3238,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnNamespacedFixitySigWithoutFlag{} -> [suggestExtension LangExt.ExplicitNamespaces] + TcRnOutOfArityTyVar{} + -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2272,6 +2272,8 @@ data TcRnMessage where where the implicitly-bound type type variables can't be matched up unambiguously with the ones from the signature. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType. + + Test cases: T24083 -} TcRnDisconnectedTyVar :: !Name -> TcRnMessage @@ -4267,6 +4269,24 @@ data TcRnMessage where -} TcRnDefaultedExceptionContext :: CtLoc -> TcRnMessage + {-| TcRnOutOfArityTyVar is an error raised when the arity of a type synonym + (as determined by the SAKS and the LHS) is insufficiently high to + accommodate an implicit binding for a free variable that occurs in the + outermost kind signature on the RHS of the said type synonym. + + Example: + + type SynBad :: forall k. k -> Type + type SynBad = Proxy :: j -> Type + + Test cases: + T24770a + -} + TcRnOutOfArityTyVar + :: Name -- ^ Type synonym's name + -> Name -- ^ Type variable's name + -> TcRnMessage + deriving Generic ---- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2617,7 +2617,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars name flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2978,25 +2978,32 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] +checkForDisconnectedScopedTyVars :: Name -> TyConFlavour TyCon -> [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] +-- For the type synonym case see Note [Out of arity type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs - = when (needsEtaExpansion flav) $ +checkForDisconnectedScopedTyVars name flav all_tcbs scoped_prs -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] - mapM_ report_disconnected (filterOut ok scoped_prs) + | needsEtaExpansion flav = mapM_ report_disconnected (filterOut ok scoped_prs) + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + | otherwise = pure () where - sig_tvs = mkVarSet (binderVars sig_tcbs) - ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + all_tvs = mkVarSet (binderVars all_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` all_tvs report_disconnected :: (Name,TcTyVar) -> TcM () report_disconnected (nm, _) = setSrcSpan (getSrcSpan nm) $ addErrTc $ TcRnDisconnectedTyVar nm + report_out_of_arity :: (Name,TcTyVar) -> TcM () + report_out_of_arity (tv_nm, _) + = setSrcSpan (getSrcSpan tv_nm) $ + addErrTc $ TcRnOutOfArityTyVar name tv_nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -3083,6 +3090,63 @@ explicitly, rather than binding it implicitly via unification. The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, where needsEtaExpansion is True. + +Note [Out of arity type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(Relevant ticket: #24470) +Type synonyms have a special scoping rule that allows implicit quantification in +the outermost kind signature: + + type P_e :: k -> Type + type P_e @k = Proxy :: k -> Type -- explicit binding + + type P_i = Proxy :: k -> Type -- implicit binding (relies on the special rule) + +This is a deprecated feature (warning flag: -Wimplicit-rhs-quantification) but +we have to support it for a couple more releases. It is explained in more detail +in Note [Implicit quantification in type synonyms] in GHC.Rename.HsType. + +Type synonyms `P_e` and `P_i` are equivalent. Both of them have kind +`forall k. k -> Type` and arity 1. (Recall that the arity of a type synonym is +the number of arguments it requires at use sites; the arity matter because +unsaturated application of type families and type synonyms is not allowed). + +We start to see problems when implicit RHS quantification (as in `P_i`) is +combined with a standalone king signature (like the one that `P_e` has). +That is: + + type P_i_sig :: k -> Type + type P_i_sig = Proxy :: k -> Type + +Per GHC Proposal #425, the arity of `P_i_sig` is determined /by the LHS only/, +which has no binders. So the arity of `P_i_sig` is 0. +At the same time, the legacy implicit quantification rule dictates that `k` is +brought into scope, as if there was a binder `@k` on the LHS. + +We end up with a `k` that is in scope on the RHS but cannot be bound implicitly +on the LHS without affecting the arity. This led to #24470 (a compiler crash) + + GHC internal error: ‘k’ is not in scope during type checking, + but it passed the renamer + +This problem occurs only if the arity of the type synonym is insufficiently +high to accommodate an implicit binding. It can be worked around by adding an +unused binder on the LHS: + + type P_w :: k -> Type + type P_w @_w = Proxy :: k -> Type + +The variable `_w` is unused. The only effect of the `@_w` binder is that the +arity of `P_w` is changed from 0 to 1. However, bumping the arity is exactly +what's needed to make the implicit binding of `k` possible. + +All this is a rather unfortunate bit of accidental complexity that will go away +when GHC drops support for implicit RHS quantification. In the meantime, we +ought to produce a proper error message instead of a compiler panic, and we do +that with a check in checkForDisconnectedScopedTyVars: + + | flav == TypeSynonymFlavour = mapM_ report_out_of_arity (filterOut ok scoped_prs) + -} {- ********************************************************************* ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -606,6 +606,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvisPatWithNoForAll" = 14964 GhcDiagnosticCode "TcRnIllegalInvisibleTypePattern" = 78249 GhcDiagnosticCode "TcRnNamespacedFixitySigWithoutFlag" = 78534 + GhcDiagnosticCode "TcRnOutOfArityTyVar" = 84925 -- TcRnTypeApplicationsDisabled GhcDiagnosticCode "TypeApplication" = 23482 ===================================== compiler/GHC/Types/Unique/Supply.hs ===================================== @@ -7,7 +7,6 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE UnliftedFFITypes #-} module GHC.Types.Unique.Supply ( -- * Main data type @@ -49,16 +48,16 @@ import Foreign.Storable #define NO_FETCH_ADD #endif -#if defined(javascript_HOST_ARCH) -import GHC.Exts ( atomicCasWord64Addr#, eqWord64# ) -#elif !defined(NO_FETCH_ADD) -import GHC.Exts( fetchAddWordAddr#, word64ToWord#, wordToWord64# ) +#if defined(NO_FETCH_ADD) +import GHC.Exts ( atomicCasWord64Addr#, eqWord64#, readWord64OffAddr# ) +#else +import GHC.Exts( fetchAddWordAddr#, word64ToWord# ) #endif import GHC.Exts ( Addr#, State#, Word64#, RealWorld ) - +import GHC.Int ( Int(..) ) import GHC.Word( Word64(..) ) -import GHC.Exts( plusWord64#, readWord64OffAddr# ) +import GHC.Exts( plusWord64#, int2Word#, wordToWord64# ) {- ************************************************************************ @@ -233,8 +232,9 @@ mkSplitUniqSupply c (# s4, MkSplitUniqSupply (tag .|. u) x y #) }}}} -#if defined(javascript_HOST_ARCH) --- CAS-based pure Haskell implementation +#if defined(NO_FETCH_ADD) +-- GHC currently does not provide this operation on 32-bit platforms, +-- hence the CAS-based implementation. fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# = go @@ -246,35 +246,7 @@ fetchAddWord64Addr# = go (# s2, res #) | 1# <- res `eqWord64#` n0 -> (# s2, n0 #) | otherwise -> go ptr inc s2 - -#elif defined(NO_FETCH_ADD) - --- atomic_inc64 is defined in compiler/cbits/genSym.c. This is of --- course not ideal, but we need to live with it for now given the --- current situation: --- 1. There's no Haskell primop fetchAddWord64Addr# on 32-bit --- platforms yet --- 2. The Cmm %fetch_add64 primop syntax is only present in ghc 9.8 --- but we currently bootstrap from older ghc in our CI --- 3. The Cmm MO_AtomicRMW operation with 64-bit width is well --- supported on 32-bit platforms already, but the plumbing from --- either Haskell or Cmm doesn't work yet because of 1 or 2 --- 4. There's hs_atomic_add64 in ghc-prim cbits that we ought to use, --- but it's only available on 32-bit starting from ghc 9.8 --- 5. The pure Haskell implementation causes mysterious i386 --- regression in unrelated ghc work that can only be fixed by the C --- version here - -foreign import ccall unsafe "atomic_inc64" atomic_inc64 :: Addr# -> Word64# -> IO Word64 - -fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld - -> (# State# RealWorld, Word64# #) -fetchAddWord64Addr# addr inc s0 = - case unIO (atomic_inc64 addr inc) s0 of - (# s1, W64# res #) -> (# s1, res #) - #else - fetchAddWord64Addr# :: Addr# -> Word64# -> State# RealWorld -> (# State# RealWorld, Word64# #) fetchAddWord64Addr# addr inc s0 = @@ -286,9 +258,9 @@ genSym :: IO Word64 genSym = do let !mask = (1 `unsafeShiftL` uNIQUE_BITS) - 1 let !(Ptr counter) = ghc_unique_counter64 - let !(Ptr inc_ptr) = ghc_unique_inc - u <- IO $ \s0 -> case readWord64OffAddr# inc_ptr 0# s0 of - (# s1, inc #) -> case fetchAddWord64Addr# counter inc s1 of + I# inc# <- peek ghc_unique_inc + let !inc = wordToWord64# (int2Word# inc#) + u <- IO $ \s1 -> case fetchAddWord64Addr# counter inc s1 of (# s2, val #) -> let !u = W64# (val `plusWord64#` inc) .&. mask in (# s2, u #) ===================================== compiler/cbits/genSym.c ===================================== @@ -15,11 +15,3 @@ HsWord64 ghc_unique_counter64 = 0; #if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) HsInt ghc_unique_inc = 1; #endif - -// Only used on 32-bit non-JS platforms -#if WORD_SIZE_IN_BITS != 64 -StgWord64 atomic_inc64(StgWord64 volatile* p, StgWord64 incr) -{ - return __atomic_fetch_add(p, incr, __ATOMIC_SEQ_CST); -} -#endif ===================================== testsuite/driver/testlib.py ===================================== @@ -1119,8 +1119,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): @@ -1491,7 +1491,7 @@ async def do_test(name: TestName, if opts.expect not in ['pass', 'fail', 'missing-lib']: framework_fail(name, way, 'bad expected ' + opts.expect) - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) if way in opts.fragile_ways: if_verbose(1, '*** fragile test %s resulted in %s' % (full_name, 'pass' if result.passed else 'fail')) @@ -1538,7 +1538,7 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') @@ -1549,7 +1549,7 @@ def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str def framework_warn(name: TestName, way: WayName, reason: str) -> None: opts = getTestOpts() - directory = re.sub('^\\.[/\\\\]', '', str(opts.testdir)) + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) full_name = name + '(' + way + ')' if_verbose(1, '*** framework warning for %s %s ' % (full_name, reason)) t.framework_warnings.append(TestResult(directory, name, reason, way)) @@ -2598,8 +2598,9 @@ def normalise_errmsg(s: str) -> str: s = normalise_callstacks(s) s = normalise_type_reps(s) - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + # normalise slashes to minimise Windows/Unix filename differences, + # but don't normalize backslashes in chars + s = re.sub(r"(?!')\\", '/', s) # Normalize the name of the GHC executable. Specifically, # this catches the cases that: @@ -2614,14 +2615,11 @@ def normalise_errmsg(s: str) -> str: # the colon is there because it appears in error messages; this # hacky solution is used in place of more sophisticated filename # mangling - s = re.sub('([^\\s])\\.exe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) # Same thing for .wasm modules generated by the Wasm backend - s = re.sub('([^\\s])\\.wasm', '\\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) # Same thing for .jsexe directories generated by the JS backend - s = re.sub('([^\\s])\\.jsexe', '\\1', s) - - # normalise slashes, minimise Windows/Unix filename differences - s = re.sub('\\\\', '/', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) # hpc executable is given ghc suffix s = re.sub('hpc-ghc', 'hpc', s) @@ -2631,8 +2629,8 @@ def normalise_errmsg(s: str) -> str: s = re.sub('ghc-stage[123]', 'ghc', s) # Remove platform prefix (e.g. javascript-unknown-ghcjs) for cross-compiled tools # (ghc, ghc-pkg, unlit, etc.) - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) - s = re.sub('\\w+(-\\w+)*-unlit', 'unlit', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-unlit', 'unlit', s) # On windows error messages can mention versioned executables s = re.sub('ghc-[0-9.]+', 'ghc', s) @@ -2735,8 +2733,8 @@ def normalise_prof (s: str) -> str: return s def normalise_slashes_( s: str ) -> str: - s = re.sub('\\\\', '/', s) - s = re.sub('//', '/', s) + s = re.sub(r'\\', '/', s) + s = re.sub(r'//', '/', s) return s def normalise_exe_( s: str ) -> str: @@ -2754,9 +2752,9 @@ def normalise_output( s: str ) -> str: # and .wasm extension (for the Wasm backend) # 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])\\.wasm', '\\1', s) - s = re.sub('([^\\s])\\.jsexe', '\\1', s) + s = re.sub(r'([^\s])\.exe', r'\1', s) + s = re.sub(r'([^\s])\.wasm', r'\1', s) + s = re.sub(r'([^\s])\.jsexe', r'\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is @@ -2776,7 +2774,7 @@ def normalise_output( s: str ) -> str: s = re.sub('.*warning: argument unused during compilation:.*\n', '', s) # strip the cross prefix if any - s = re.sub('\\w+(-\\w+)*-ghc', 'ghc', s) + s = re.sub(r'\w+(-\w+)*-ghc', 'ghc', s) return s ===================================== testsuite/tests/parser/should_fail/T21843a.stderr ===================================== @@ -1,4 +1,4 @@ T21843a.hs:3:13: [GHC-31623] - Unicode character '“' ('/8220') looks like '"' (Quotation Mark), but it is not + Unicode character '“' ('\8220') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843b.stderr ===================================== @@ -1,3 +1,3 @@ T21843b.hs:3:11: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843c.stderr ===================================== @@ -1,6 +1,6 @@ T21843c.hs:3:19: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not T21843c.hs:3:20: [GHC-21231] - lexical error in string/character literal at character '/n' + lexical error in string/character literal at character '\n' ===================================== testsuite/tests/parser/should_fail/T21843d.stderr ===================================== @@ -1,3 +1,3 @@ T21843d.hs:3:13: [GHC-31623] - Unicode character '’' ('/8217') looks like ''' (Single Quote), but it is not + Unicode character '’' ('\8217') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/parser/should_fail/T21843e.stderr ===================================== @@ -1,3 +1,3 @@ T21843e.hs:3:15: [GHC-31623] - Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not + Unicode character '”' ('\8221') looks like '"' (Quotation Mark), but it is not ===================================== testsuite/tests/parser/should_fail/T21843f.stderr ===================================== @@ -1,3 +1,3 @@ T21843f.hs:3:13: [GHC-31623] - Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not + Unicode character '‘' ('\8216') looks like ''' (Single Quote), but it is not ===================================== testsuite/tests/printer/Makefile ===================================== @@ -816,3 +816,8 @@ Test23885: AnnotationNoListTuplePuns: $(CHECK_PPR) $(LIBDIR) AnnotationNoListTuplePuns.hs $(CHECK_EXACT) $(LIBDIR) AnnotationNoListTuplePuns.hs + +.PHONY: Test24533 +Test24533: + $(CHECK_PPR) $(LIBDIR) Test24533.hs + $(CHECK_EXACT) $(LIBDIR) Test24533.hs ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -ddump-parsed-ast #-} +module Test24533 where + +instance + ( Read a, -- Weird + Read b + ) => + Read (a, b) ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -0,0 +1,548 @@ + +==================== Parser AST ==================== + +(L + { Test24533.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.hs:9:1 } + { Test24533.hs:8:13 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.hs:(4,1)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:4:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(8,13) }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:(5,3)-(7,3) }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.hs:7:5-6 }))) + [(EpaSpan { Test24533.hs:5:3 })] + [(EpaSpan { Test24533.hs:7:3 })]) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:5:13-20 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:5:11 }))])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:5:5-10 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:5:11 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:5:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:6:5-10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:5-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:6:10 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:3-6 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:8-13 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.hs:8:8 }) + (EpaSpan { Test24533.hs:8:13 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.hs:8:10 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:8:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) + + + +==================== Parser AST ==================== + +(L + { Test24533.ppr.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (EpaSpan { Test24533.ppr.hs:1:1 }) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { Test24533.ppr.hs:2:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:2:18-22 }))] + [] + (Just + ((,) + { Test24533.ppr.hs:3:41 } + { Test24533.ppr.hs:3:40 }))) + (EpaCommentsBalanced + [(L + (EpaSpan + { Test24533.ppr.hs:1:1-33 }) + (EpaComment + (EpaBlockComment + "{-# OPTIONS -ddump-parsed-ast #-}") + { Test24533.ppr.hs:1:1 }))] + [])) + (EpVirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:2:8-16 }) + (AnnListItem + []) + (EpaComments + [])) + {ModuleName: Test24533})) + (Nothing) + [] + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:1-40 }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:3:1-8 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsQualTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:10-25 }) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { Test24533.ppr.hs:3:27-28 }))) + [(EpaSpan { Test24533.ppr.hs:3:10 })] + [(EpaSpan { Test24533.ppr.hs:3:25 })]) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-16 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:17 }))]) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:11-14 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:16 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:19-22 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:24 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))))]) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:30-33 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Read})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:35-40 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTupleTy + (AnnParen + AnnParens + (EpaSpan { Test24533.ppr.hs:3:35 }) + (EpaSpan { Test24533.ppr.hs:3:40 })) + (HsBoxedOrConstraintTuple) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (AnnListItem + [(AddCommaAnn + (EpaSpan { Test24533.ppr.hs:3:37 }))]) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:36 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:3:39 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: b}))))])))))))) + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + [] + (Nothing)))))])) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -196,3 +196,4 @@ test('Test23887', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23887']) test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) +test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) ===================================== testsuite/tests/typecheck/should_compile/T24470b.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-implicit-rhs-quantification #-} +{-# LANGUAGE TypeAbstractions #-} + +module T24470b where + +import Data.Kind +import Data.Data + +type SynOK :: forall k. k -> Type +type SynOK @t = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -912,3 +912,4 @@ test('T21206', normal, compile, ['']) test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) +test('T24470b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24470a.hs ===================================== @@ -0,0 +1,7 @@ +module T24470a where + +import Data.Data +import Data.Kind + +type SynBad :: forall k. k -> Type +type SynBad = Proxy :: j -> Type ===================================== testsuite/tests/typecheck/should_fail/T24470a.stderr ===================================== @@ -0,0 +1,6 @@ + +T24470a.hs:7:24: error: [GHC-84925] + • The arity of ‘SynBad’ is insufficiently high to accommodate + an implicit binding for the ‘j’ type variable. + • Use ‘@j’ on the LHS or ‘forall j.’ on the RHS to bring it into scope. + • In the type synonym declaration for ‘SynBad’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -722,3 +722,5 @@ test('DoExpansion3', normal, compile, ['-fdefer-type-errors']) test('T17594c', normal, compile_fail, ['']) test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) + +test('T24470a', normal, compile_fail, ['']) ===================================== utils/genprimopcode/AccessOps.hs ===================================== @@ -82,7 +82,7 @@ mkIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect CanFail] } @@ -94,7 +94,7 @@ mkUnalignedIndexByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable array; offset in bytes." , opts = [OptionEffect CanFail] } @@ -106,7 +106,7 @@ mkReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -118,7 +118,7 @@ mkUnalignedReadByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -130,7 +130,7 @@ mkWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ "." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in " ++ prettyOffset e ++ "." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -142,7 +142,7 @@ mkUnalignedWriteByteArrayOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable array; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -166,7 +166,7 @@ mkIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect CanFail] } @@ -179,7 +179,7 @@ mkUnalignedIndexOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") (elt_rep_ty e) , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from immutable address; offset in bytes." , opts = [OptionEffect CanFail] } @@ -191,7 +191,7 @@ mkReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -204,7 +204,7 @@ mkUnalignedReadOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ readResTy e , cat = GenPrimOp - , desc = "Read " ++ elt_desc e ++ "; offset in bytes." + , desc = "Read " ++ elt_desc e ++ " from mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -216,7 +216,7 @@ mkWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in " ++ prettyOffset e ++ ".\n\n" + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in " ++ prettyOffset e ++ ".\n\n" ++ getAlignWarn e , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } @@ -229,7 +229,7 @@ mkUnalignedWriteOffAddrOp e = PrimOpSpec $ TyF (strToTy "Int#") $ writeResTy e , cat = GenPrimOp - , desc = "Write " ++ elt_desc e ++ "; offset in bytes." + , desc = "Write " ++ elt_desc e ++ " to mutable address; offset in bytes." , opts = [OptionEffect ReadWriteEffect, OptionCanFailWarnFlag YesWarnCanFail] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca405979ea626e3e7bcb137f356320827ff18253...9975ad57752aacdf96eed7874c1a042bce3e05af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca405979ea626e3e7bcb137f356320827ff18253...9975ad57752aacdf96eed7874c1a042bce3e05af You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 16:09:37 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 14 Mar 2024 12:09:37 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 64 commits: base: Use strerror_r instead of strerror Message-ID: <65f3214155de4_dbb557e56f585988c@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 89166ff5 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 232eea83 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The net result is good: a 1.5% improvement in compile time. The table below shows changes over 1%. The main changes are: * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Many new or rewritten Notes. E.g. Note [Avoiding simplifying repeatedly] Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * When considering inlining a join point, never do so unless there is a positive gain: see (DJ5) in Note [Duplicating join points]. * Do not float join points at all, except to top level. See GHC.Core.Opt.SetLevels.dontFloatNonRec * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. * Use plan A for dataToTag and tagToEnum I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I added an INLINE pragma to it. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -8.2% GOOD LargeRecord(normal) -22.7% GOOD PmSeriesS(normal) -4.1% PmSeriesT(normal) -3.1% PmSeriesV(normal) -1.6% T11195(normal) -1.9% T12227(normal) -19.9% GOOD T12545(normal) -5.4% T12707(normal) -2.1% GOOD T13253-spj(normal) -13.1% GOOD T13386(normal) -1.6% T14766(normal) -2.2% GOOD T15630a(normal) NEW T15703(normal) -13.5% GOOD T16577(normal) -4.3% GOOD T17096(normal) -4.4% T17516(normal) -0.2% T18223(normal) -16.3% GOOD T18282(normal) -5.3% GOOD T18730(optasm) NEW T18923(normal) -3.7% GOOD T21839c(normal) -2.3% GOOD T3064(normal) -1.3% T5030(normal) -16.1% GOOD T5321Fun(normal) -1.5% T6048(optasm) -11.8% GOOD T783(normal) -1.4% T8095(normal) -5.9% GOOD T9630(normal) -5.1% GOOD T9020(optasm) +1.5% T18698a(normal) +1.5% BAD T14683(normal) +1.2% DsIncompleteRecSel3(normal) +1.2% MultiComponentModulesRecomp(normal) +1.0% MultiLayerModulesRecomp(normal) +1.9% MultiLayerModulesTH_Make(normal) +1.4% T10421(normal) +1.9% BAD T10421a(normal) +3.0% T13056(optasm) +1.1% T13253(normal) +1.0% T1969(normal) +1.1% BAD T15304(normal) +1.7% T9675(optasm) +1.2% T9961(normal) +2.4% BAD geo. mean -1.5% minimum -22.7% maximum +3.0% Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T12990 T13253-spj T13536a T14766 T15703 T16577 T18223 T18282 T18923 T21839c T5030 T6048 T8095 T9630 Metric Increase: T10421 T18698a T1969 T9961 - - - - - 55455474 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Improve postInlineUnconditionally This commit adds two things to postInlineUnconditionally: 1. Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. 2. Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. - - - - - b1163fb7 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 More wibbles * Inline join points whose RHS just calls another join point * Don't float join points at all (SetLevels) * Ensure that WorkWrap preserves lambda binders, in case of join points - - - - - 329c3e58 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Unused variable wibbles - - - - - e239a94a by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 More import wibbles - - - - - adddc6aa by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 More imports - - - - - b01b7089 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 More wibbles - - - - - 70ae1bbf by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 More on floating join points * Get rid of the "join ceiling" which I have always hated * Float joins to top level in final pass only (needs documenting--see my GHC log) * Refactor wantToFloat so that it applies to Rec and NonRec uniformly - - - - - 660ce223 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Comments about floating joins - - - - - 5ca6974d by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Improve occurrence analyis for bottoming function calls See Note [Bottoming function calls] - - - - - 045227d7 by Simon Peyton Jones at 2024-03-14T16:07:33+00:00 Test output wibbles - - - - - 5fdcd133 by Simon Peyton Jones at 2024-03-14T16:07:34+00:00 More testsuite wibbles - - - - - 86bf6d2f by Simon Peyton Jones at 2024-03-14T16:07:34+00:00 Float recursive joins to top level This seems be be a net win. Example joinrec { f x = ..f x'... } in f v Despite Note [Floating join point bindings] - - - - - 9fb899b8 by Simon Peyton Jones at 2024-03-14T16:07:34+00:00 Inline join points that have evaluated things at the use site. This helps quite a bit with wheel-sieve1. Example let x = <small thunk> in join $j = (x,y) in case z of A -> case x of P -> $j Q -> blah B -> x C -> True Here `x` can't be duplicated into the branches becuase it is used in both the join point and the A branch. But if we inline $j we get let x = <small thunk> in join $j = (x,y) in case z of A -> case x of x' P -> (x', y) Q -> blah B -> x C -> True and now we /can/ duplicate x into the branches. - - - - - 7b20d3a7 by Simon Peyton Jones at 2024-03-14T16:07:34+00:00 Two small things * isConLikeUnfolding is false for OtherCon * Evaluated args look like NonTrivArg not ValueArg See GHC log 15 Feb - - - - - bb585b86 by Simon Peyton Jones at 2024-03-14T16:07:34+00:00 Further careful changes - - - - - e18261b5 by Simon Peyton Jones at 2024-03-14T16:07:51+00:00 Try a more clever discard-eval Addresses programs like this f xs = xs `seq` (let t = reverse $ reverse $ reverse $ reverse $ reverse $ reverse xs in case xs of [] -> (t,True) (_:_) -> (t,False)) Also including the case where t is a join point. Relates to #24251. See GHC Log 13 March - - - - - 401113c9 by Simon Peyton Jones at 2024-03-14T16:08:09+00:00 Wibbles - - - - - 22 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/FloatOut.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a33476b9bdca731d1a90466fe866b417f2cdd09c...401113c9731c7dcd47e5f2e39ffb6c5ee3975af4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a33476b9bdca731d1a90466fe866b417f2cdd09c...401113c9731c7dcd47e5f2e39ffb6c5ee3975af4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 16:25:17 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 14 Mar 2024 12:25:17 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] mk-ghcup-metadata: Fix directory of testsuite tarball Message-ID: <65f324ed5dac3_dbb55858d6c86273c@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: e8bb627d by Ben Gamari at 2024-03-14T11:10:40-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 1 changed file: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -80,7 +80,7 @@ source_artifact = Artifact('source-tarball' test_artifact = Artifact('source-tarball' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' - , 'ghc-{version}' ) + , 'ghc-{version}/testsuite' ) def debian(arch, n): return linux_platform(arch, "{arch}-linux-deb{n}".format(arch=arch, n=n)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8bb627d23028bfaf4f29033be2e50a01bb36e6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8bb627d23028bfaf4f29033be2e50a01bb36e6e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 16:33:08 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 14 Mar 2024 12:33:08 -0400 Subject: [Git][ghc/ghc][wip/release-fixes] ghcup-metadata: Don't populate dlOutput unless necessary Message-ID: <65f326c485df6_dbb5588c92ec64866@gitlab.mail> Ben Gamari pushed to branch wip/release-fixes at Glasgow Haskell Compiler / GHC Commits: 470331cd by Ben Gamari at 2024-03-14T12:32:01-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 1 changed file: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -36,6 +36,7 @@ import os import yaml import gitlab from urllib.request import urlopen +from urllib.parse import urlparse import hashlib import sys import json @@ -156,13 +157,18 @@ def mk_one_metadata(release_mode, version, job_map, artifact): eprint(f"Bindist URL: {url}") eprint(f"Download URL: {final_url}") - #Download and hash from the release pipeline, this must not change anyway during upload. + # Download and hash from the release pipeline, this must not change anyway during upload. h = download_and_hash(url) res = { "dlUri": final_url , "dlSubdir": artifact.subdir.format(version=version) - , "dlOutput": artifact.output_name.format(version=version) , "dlHash" : h } + + # Only add dlOutput if it is inconsistent with the filename inferred from the URL + output = artifact.output_name.format(version=version) + if Path(urlparse(final_url).path).name != output: + res["dlOutput"] = output + eprint(res) return res View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/470331cd89b6184125f8876085c2aae073d3ea43 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/470331cd89b6184125f8876085c2aae073d3ea43 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 17:31:43 2024 From: gitlab at gitlab.haskell.org (Brandon Chinn (@brandonchinn178)) Date: Thu, 14 Mar 2024 13:31:43 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/stderr-normalize-escape Message-ID: <65f3347f5e4e2_dbb55a34f5946744b@gitlab.mail> Brandon Chinn deleted branch wip/stderr-normalize-escape at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 17:40:44 2024 From: gitlab at gitlab.haskell.org (Brandon Chinn (@brandonchinn178)) Date: Thu, 14 Mar 2024 13:40:44 -0400 Subject: [Git][ghc/ghc][wip/multiline-strings] 129 commits: Improve the synopsis and description of base Message-ID: <65f3369ccb84a_1ca96757a094966f3@gitlab.mail> Brandon Chinn pushed to branch wip/multiline-strings at Glasgow Haskell Compiler / GHC Commits: 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 7ff30f85 by Brandon Chinn at 2024-03-14T10:32:54-07:00 Add MultilineStrings extension - - - - - d69c82d3 by Brandon Chinn at 2024-03-14T10:40:33-07:00 Add test cases for MultilineStrings - - - - - f7a57615 by Brandon Chinn at 2024-03-14T10:40:34-07:00 Break out common lex_magic_hash logic for strings and chars - - - - - 857bbf05 by Brandon Chinn at 2024-03-14T10:40:34-07:00 Factor out string processing functions - - - - - 8d2cf320 by Brandon Chinn at 2024-03-14T10:40:34-07:00 Implement MultilineStrings (#24390) Updates haddock submodule for new ITmultiline constructor - - - - - 775254fb by Brandon Chinn at 2024-03-14T10:40:34-07:00 Add docs for MultilineStrings - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - 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/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d2edce69340c31ab7ed995f7db5fae269976733f...775254fb84509381e042bba0d03d3b88139e6eed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d2edce69340c31ab7ed995f7db5fae269976733f...775254fb84509381e042bba0d03d3b88139e6eed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 14 23:24:09 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 14 Mar 2024 19:24:09 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Escape multiple arguments in the settings file Message-ID: <65f38719ca945_1ca967962718c130824@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5bea24cf by Fendor at 2024-03-14T19:24:01-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - 9848d580 by Fendor at 2024-03-14T19:24:03-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 9 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Settings/IO.hs - hadrian/src/Rules/Generate.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -135,12 +141,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +267,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -416,7 +417,7 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) @@ -431,23 +432,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +572,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e0a1d5202af25a49398f266cc011ac281ff8f914...9848d58006f7361b847e4991d899fdc5a06d75ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e0a1d5202af25a49398f266cc011ac281ff8f914...9848d58006f7361b847e4991d899fdc5a06d75ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 15 12:44:06 2024 From: gitlab at gitlab.haskell.org (Torsten Schmits (@torsten.schmits)) Date: Fri, 15 Mar 2024 08:44:06 -0400 Subject: [Git][ghc/ghc][wip/torsten.schmits/rts-linker-direct-symbol-lookup] 3 commits: move test to subdir Message-ID: <65f44296b0bc1_2befd6d187a88392ca@gitlab.mail> Torsten Schmits pushed to branch wip/torsten.schmits/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: a68cbaf2 by Torsten Schmits at 2024-03-13T15:15:18+01:00 move test to subdir - - - - - fb25ac08 by Torsten Schmits at 2024-03-15T13:42:56+01:00 add flag and logging - - - - - 17319148 by Torsten Schmits at 2024-03-15T13:43:51+01:00 add test case with long chain of package deps - - - - - 17 changed files: - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/Types.hs - ghc/Main.hs - testsuite/tests/rts/linker/Makefile - + testsuite/tests/rts/linker/T23415/Makefile - testsuite/tests/rts/linker/Reuse.hs → testsuite/tests/rts/linker/T23415/Reuse.hs - testsuite/tests/rts/linker/Reuse.script → testsuite/tests/rts/linker/T23415/Reuse.script - testsuite/tests/rts/linker/ReusePlugin.hs → testsuite/tests/rts/linker/T23415/ReusePlugin.hs - testsuite/tests/rts/linker/T23415.stderr → testsuite/tests/rts/linker/T23415/T23415a.stderr - + testsuite/tests/rts/linker/T23415/T23415b.script - + testsuite/tests/rts/linker/T23415/all.T - + testsuite/tests/rts/linker/T23415/prepare-load.sh - testsuite/tests/rts/linker/reuse.conf → testsuite/tests/rts/linker/T23415/reuse.conf - testsuite/tests/rts/linker/all.T Changes: ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -46,6 +46,7 @@ import Language.Haskell.Syntax.Module.Name import Data.Array.Unboxed import Foreign.Ptr import GHC.Exts +import GHC.Utils.Error (debugTraceMsg) {- Linking interpretables into something we can run @@ -53,7 +54,7 @@ import GHC.Exts linkBCO :: Interp - -> PkgsLoaded + -> PkgsLoadedEnv -> LinkerEnv -> NameEnv Int -> UnlinkedBCO @@ -68,7 +69,7 @@ linkBCO interp pkgs_loaded le bco_ix (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) -lookupLiteral :: Interp -> PkgsLoaded -> LinkerEnv -> BCONPtr -> IO Word +lookupLiteral :: Interp -> PkgsLoadedEnv -> LinkerEnv -> BCONPtr -> IO Word lookupLiteral interp pkgs_loaded le ptr = case ptr of BCONPtrWord lit -> return lit BCONPtrLbl sym -> do @@ -92,7 +93,7 @@ lookupStaticPtr interp addr_of_label_string = do Nothing -> linkFail "GHC.ByteCode.Linker: can't find label" (unpackFS addr_of_label_string) -lookupIE :: Interp -> PkgsLoaded -> ItblEnv -> Name -> IO (Ptr ()) +lookupIE :: Interp -> PkgsLoadedEnv -> ItblEnv -> Name -> IO (Ptr ()) lookupIE interp pkgs_loaded ie con_nm = case lookupNameEnv ie con_nm of Just (_, ItblPtr a) -> return (fromRemotePtr (castRemotePtr a)) @@ -112,7 +113,7 @@ lookupIE interp pkgs_loaded ie con_nm = unpackFS sym_to_find2) -- see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode -lookupAddr :: Interp -> PkgsLoaded -> AddrEnv -> Name -> IO (Ptr ()) +lookupAddr :: Interp -> PkgsLoadedEnv -> AddrEnv -> Name -> IO (Ptr ()) lookupAddr interp pkgs_loaded ae addr_nm = do case lookupNameEnv ae addr_nm of Just (_, AddrPtr ptr) -> return (fromRemotePtr ptr) @@ -135,7 +136,7 @@ lookupPrimOp interp primop = do resolvePtr :: Interp - -> PkgsLoaded + -> PkgsLoadedEnv -> LinkerEnv -> NameEnv Int -> BCOPtr @@ -166,8 +167,8 @@ resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of BCOPtrBreakArray breakarray -> withForeignRef breakarray $ \ba -> return (ResolvedBCOPtrBreakArray ba) -lookupHsSymbol :: Interp -> PkgsLoaded -> Name -> String -> IO (Maybe (Ptr ())) -lookupHsSymbol interp pkgs_loaded nm sym_suffix = do +lookupHsSymbol :: Interp -> PkgsLoadedEnv -> Name -> String -> IO (Maybe (Ptr ())) +lookupHsSymbol interp PkgsLoadedEnv {ple_pkgs_loaded = pkgs_loaded, ple_logger = logger} nm sym_suffix = do massertPpr (isExternalName nm) (ppr nm) let sym_to_find = nameToCLabel nm sym_suffix pkg_id = moduleUnitId $ nameModule nm @@ -176,12 +177,20 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do go (dll:dlls) = do mb_ptr <- lookupSymbolInDLL interp dll sym_to_find case mb_ptr of - Just ptr -> pure (Just ptr) + Just ptr -> do + log_resolution sym_to_find "hit" + pure (Just ptr) Nothing -> go dlls - go [] = + go [] = do + log_resolution sym_to_find "miss" lookupSymbol interp sym_to_find go loaded_dlls + where + log_resolution sym_to_find res = + debugTraceMsg logger 3 $ + text "lookupHsSymbol: Cache" <+> text res <+> text "for" <+> ppr nm <+> + parens (ftext sym_to_find) linkFail :: String -> String -> IO a linkFail who what ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -468,6 +468,7 @@ data GeneralFlag -- temporary flags | Opt_AutoLinkPackages | Opt_ImplicitImportQualified + | Opt_CacheLoadedLibraryUnits -- keeping stuff | Opt_KeepHscppFiles ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2345,8 +2345,8 @@ fFlagsDeps = [ flagGhciSpec "break-on-error" Opt_BreakOnError, flagGhciSpec "break-on-exception" Opt_BreakOnException, flagSpec "building-cabal-package" Opt_BuildingCabalPackage, + flagGhciSpec "cache-loaded-library-units" Opt_CacheLoadedLibraryUnits, flagSpec "call-arity" Opt_CallArity, - flagSpec "exitification" Opt_Exitification, flagSpec "case-merge" Opt_CaseMerge, flagSpec "case-folding" Opt_CaseFolding, flagSpec "cmm-elim-common-blocks" Opt_CmmElimCommonBlocks, @@ -2379,6 +2379,7 @@ fFlagsDeps = [ flagSpec "enable-th-splice-warnings" Opt_EnableThSpliceWarnings, flagSpec "error-spans" Opt_ErrorSpans, flagSpec "excess-precision" Opt_ExcessPrecision, + flagSpec "exitification" Opt_Exitification, flagSpec "expose-all-unfoldings" Opt_ExposeAllUnfoldings, flagSpec "keep-auto-rules" Opt_KeepAutoRules, flagSpec "expose-internal-symbols" Opt_ExposeInternalSymbols, ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -588,7 +588,7 @@ loadExpr interp hsc_env span root_ul_bco = do -- Load the necessary packages and linkables let le = linker_env pls bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)] - resolved <- linkBCO interp (pkgs_loaded pls) le bco_ix root_ul_bco + resolved <- linkBCO interp (PkgsLoadedEnv (pkgs_loaded pls) (hsc_logger hsc_env)) le bco_ix root_ul_bco [root_hvref] <- createBCOs interp [resolved] fhv <- mkFinalizedHValue interp root_hvref return (pls, fhv) @@ -651,7 +651,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do , addr_env = plusNameEnv (addr_env le) bc_strs } -- Link the necessary packages and linkables - new_bindings <- linkSomeBCOs interp (pkgs_loaded pls) le2 [cbc] + new_bindings <- linkSomeBCOs interp (PkgsLoadedEnv (pkgs_loaded pls) (hsc_logger hsc_env)) le2 [cbc] nms_fhvs <- makeForeignNamedHValueRefs interp new_bindings let ce2 = extendClosureEnv (closure_env le2) nms_fhvs !pls2 = pls { linker_env = le2 { closure_env = ce2 } } @@ -706,7 +706,7 @@ loadModuleLinkables interp hsc_env pls linkables if failed ok_flag then return (pls1, Failed) else do - pls2 <- dynLinkBCOs interp pls1 bcos + pls2 <- dynLinkBCOs interp hsc_env pls1 bcos return (pls2, Succeeded) @@ -856,8 +856,8 @@ rmDupLinkables already ls ********************************************************************* -} -dynLinkBCOs :: Interp -> LoaderState -> [Linkable] -> IO LoaderState -dynLinkBCOs interp pls bcos = do +dynLinkBCOs :: Interp -> HscEnv -> LoaderState -> [Linkable] -> IO LoaderState +dynLinkBCOs interp hsc_env pls bcos = do let (bcos_loaded', new_bcos) = rmDupLinkables (bcos_loaded pls) bcos pls1 = pls { bcos_loaded = bcos_loaded' } @@ -873,7 +873,7 @@ dynLinkBCOs interp pls bcos = do ae2 = foldr plusNameEnv (addr_env le1) (map bc_strs cbcs) le2 = le1 { itbl_env = ie2, addr_env = ae2 } - names_and_refs <- linkSomeBCOs interp (pkgs_loaded pls) le2 cbcs + names_and_refs <- linkSomeBCOs interp (PkgsLoadedEnv (pkgs_loaded pls) (hsc_logger hsc_env)) le2 cbcs -- We only want to add the external ones to the ClosureEnv let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs @@ -888,7 +888,7 @@ dynLinkBCOs interp pls bcos = do -- Link a bunch of BCOs and return references to their values linkSomeBCOs :: Interp - -> PkgsLoaded + -> PkgsLoadedEnv -> LinkerEnv -> [CompiledByteCode] -> IO [(Name,HValueRef)] @@ -896,7 +896,7 @@ linkSomeBCOs :: Interp -- the incoming unlinked BCOs. Each gives the -- value of the corresponding unlinked BCO -linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] +linkSomeBCOs interp pkgs_loaded_env le mods = foldr fun do_link mods [] where fun CompiledByteCode{..} inner accum = inner (bc_bcos : accum) @@ -905,7 +905,7 @@ linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) - resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] + resolved <- sequence [ linkBCO interp pkgs_loaded_env le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) @@ -1072,11 +1072,18 @@ loadPackages' interp hsc_env new_pks pls = do | dep_pkg <- deps , Just loaded_pkg_info <- pure (lookupUDFM pkgs' dep_pkg) ] - ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls loaded_dlls trans_deps)) } + cached | cacheDlls = loaded_dlls + | otherwise = [] + ; when (cacheDlls && not (null cached)) $ + debugTraceMsg (hsc_logger hsc_env) 3 $ + text "loadPackages': Updating cache for" <+> ppr (unitId pkg_cfg) + ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls cached trans_deps)) } | otherwise = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unpackFS (unitIdFS new_pkg))) + cacheDlls = gopt Opt_CacheLoadedLibraryUnits (hsc_dflags hsc_env) + loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec], [RemotePtr LoadedDLL]) loadPackage interp hsc_env pkg ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -33,6 +33,7 @@ module GHC.Linker.Types , LibrarySpec(..) , LoadedPkgInfo(..) , PkgsLoaded + , PkgsLoadedEnv(..) ) where @@ -57,6 +58,7 @@ import GHC.Unit.Module.Env import GHC.Types.Unique.DSet import GHC.Types.Unique.DFM import GHC.Unit.Module.WholeCoreBindings +import GHC.Utils.Logger (Logger) {- ********************************************************************** @@ -140,6 +142,12 @@ extendClosureEnv :: ClosureEnv -> [(Name,ForeignHValue)] -> ClosureEnv extendClosureEnv cl_env pairs = extendNameEnvList cl_env [ (n, (n,v)) | (n,v) <- pairs] +data PkgsLoadedEnv = + PkgsLoadedEnv { + ple_pkgs_loaded :: !PkgsLoaded, + ple_logger :: !Logger + } + type PkgsLoaded = UniqDFM UnitId LoadedPkgInfo data LoadedPkgInfo ===================================== ghc/Main.hs ===================================== @@ -218,6 +218,8 @@ main' postLoadMode units dflags0 args flagWarnings = do `gopt_set` Opt_UseBytecodeRatherThanObjects -- By default enable the debugger by inserting breakpoints `gopt_set` Opt_InsertBreakpoints + -- Speed up symbol lookup + `gopt_set` Opt_CacheLoadedLibraryUnits logger1 <- getLogger let logger2 = setLogFlags logger1 (initLogFlags dflags2) ===================================== testsuite/tests/rts/linker/Makefile ===================================== @@ -140,35 +140,3 @@ T20918: T21618: "$(TEST_HC)" -c T21618_c.c -o T21618_c.o echo main | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T21618_c.o T21618.hs - -REUSE_DB=db -REUSE_CONF=reuse.conf -REUSE_PKG=pkg-reuse - -.PHONY: T23415 -T23415: - mkdir -p "$(REUSE_PKG)"/{lib,hi} - mkdir -p src - mkdir -p "$(REUSE_DB)" - mv Reuse.hs ReusePlugin.hs src/ - "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) \ - -dynamic-too \ - -hidir "$(REUSE_PKG)/hi/" \ - -O0 \ - -this-unit-id reuse-1.0 \ - -package ghc \ - -c src/* - "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) \ - -dynamic -shared -fPIC \ - -hidir "$(REUSE_PKG)/hi/" \ - -this-unit-id reuse-1.0 \ - -package ghc \ - -O0 \ - -o "$(REUSE_PKG)/lib/libHSreuse-1.0-ghc$(shell "$(TEST_HC)" --numeric-version)$(dllext)" src/*.dyn_o - "$(GHC_PKG)" --no-user-package-db --package-db="$(REUSE_DB)" recache - "$(GHC_PKG)" --no-user-package-db --package-db="$(REUSE_DB)" register "$(REUSE_CONF)" - "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) \ - -package-db $(REUSE_DB) \ - -v0 +RTS -Dl -RTS \ - -fplugin=ReusePlugin \ - -ghci-script Reuse.script ===================================== testsuite/tests/rts/linker/T23415/Makefile ===================================== @@ -0,0 +1,43 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +REUSE_DB=db +REUSE_CONF=reuse.conf +REUSE_PKG=pkg-reuse + +.PHONY: T23415a +T23415a: + mkdir -p "$(REUSE_PKG)"/{lib,hi} + mkdir -p src + mkdir -p "$(REUSE_DB)" + mv Reuse.hs ReusePlugin.hs src/ + "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) \ + -dynamic-too \ + -hidir "$(REUSE_PKG)/hi/" \ + -O0 \ + -this-unit-id reuse-1.0 \ + -package ghc \ + -c src/* + "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) \ + -dynamic -shared -fPIC \ + -hidir "$(REUSE_PKG)/hi/" \ + -this-unit-id reuse-1.0 \ + -package ghc \ + -O0 \ + -o "$(REUSE_PKG)/lib/libHSreuse-1.0-ghc$(shell "$(TEST_HC)" --numeric-version)$(dllext)" src/*.dyn_o + "$(GHC_PKG)" --no-user-package-db --package-db="$(REUSE_DB)" recache + "$(GHC_PKG)" --no-user-package-db --package-db="$(REUSE_DB)" register "$(REUSE_CONF)" + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) \ + -package-db $(REUSE_DB) \ + -v0 +RTS -Dl -RTS \ + -fplugin=ReusePlugin \ + -ghci-script Reuse.script + +.PHONY: T23415b +T23415b: + ./prepare-load.sh "$(TEST_HC)" " $(filter-out -rtsopts, $(TEST_HC_OPTS))" "$(GHC_PKG)" "$(dllext)" 30 100 1000 + +.PHONY: T23415d +T23415d: T23415b + "$(TEST_HC)" -package-db=db -fcache-loaded-library-units -v0 --interactive -ghci-script T23415.script ===================================== testsuite/tests/rts/linker/Reuse.hs → testsuite/tests/rts/linker/T23415/Reuse.hs ===================================== ===================================== testsuite/tests/rts/linker/Reuse.script → testsuite/tests/rts/linker/T23415/Reuse.script ===================================== ===================================== testsuite/tests/rts/linker/ReusePlugin.hs → testsuite/tests/rts/linker/T23415/ReusePlugin.hs ===================================== ===================================== testsuite/tests/rts/linker/T23415.stderr → testsuite/tests/rts/linker/T23415/T23415a.stderr ===================================== ===================================== testsuite/tests/rts/linker/T23415/T23415b.script ===================================== @@ -0,0 +1,13 @@ +import Data.Time.Clock.System +import System.IO +import Data.Int +start <- systemSeconds <$> getSystemTime +writeFile "start-time" (show start) +hPutStrLn stderr "--------------------- START" +:load Main +hPutStrLn stderr "--------------------- LOADED" +main +hPutStrLn stderr "--------------------- EXECUTED" +end <- systemSeconds <$> getSystemTime +start :: Int64 <- readIO =<< readFile "start-time" +hPutStrLn stderr (show (end - start) ++ " seconds") ===================================== testsuite/tests/rts/linker/T23415/all.T ===================================== @@ -0,0 +1,36 @@ +setTestOpts([ + # unless(doing_ghci, skip), + unless(have_dynamic(),skip), +]) + +###################################### +# https://gitlab.haskell.org/ghc/ghc/-/issues/23415 + +###################################### +# When loading a Haskell symbol from a shared object (here `libHS_Reuse-1.0-ghcXXX.so` created from `Reuse.hs`), +# the native object loader in `loadNativeObj_ELF` stores the object code in a list. +# When the function is called again for the same object, the previously stored object code is returned. +test('T23415a', + [extra_files(['Reuse.hs', 'Reuse.script', 'reuse.conf', 'ReusePlugin.hs']), + grep_stderr('Found existing OC for.*libHSreuse-1.*'), + req_rts_linker], + makefile_test, ['T23415a']) + +test('T23415b', + [extra_files(['prepare-load.sh']), + pre_cmd('$MAKE T23415b'), + req_rts_linker, + # extra_hc_opts('-package-db=db -fno-cache-loaded-library-units -v3')], + extra_hc_opts('-package-db=db -fno-cache-loaded-library-units -v3')], + ghci_script, ['T23415b.script']) + +test('T23415c', + [extra_files(['prepare-load.sh']), + pre_cmd('$MAKE T23415b'), + req_rts_linker], + multimod_compile_and_run, ['Main', '-dynamic -package-db=db -O0']) + +test('T23415d', + [extra_files(['prepare-load.sh']), + req_rts_linker], + makefile_test, ['T23415d']) ===================================== testsuite/tests/rts/linker/T23415/prepare-load.sh ===================================== @@ -0,0 +1,203 @@ +#!/usr/bin/env bash + +set -e + +if [[ $# < 6 ]] +then + echo "Usage: ./prepare-transitive-load.sh GHC GHC_OPTS GHC_PKG DLL_EXT NUM_PKGS NUM_FUNCS NUM_REFS" + exit 1 +fi + +ghc_cmd="$1" +ghc_opts="$2" +ghc_pkg_cmd="$3" +dll_ext="$4" +num_pkgs="$5" +num_funcs="$6" +num_refs="$7" + +base="$PWD" +src="$base/src" +build="$base/build" +db="$base/db" + +ghc_pkg() +{ + eval "${ghc_pkg_cmd at Q} --no-user-package-db --package-db=${db at Q} $@" +} + +ghc() +{ + eval "${ghc_cmd at Q} $ghc_opts $@" +} + +version_suffix=$(ghc --numeric-version) + +range() +{ + eval echo "{1..$1}" +} + +append() +{ + echo -e "$*" >> $file_name +} + +create_sources() +{ + local num="$1" + local prev="$(($num - 1))" + local name="load${num}" + local module_name="Load${num}" + local fun expr + file_name="${module_name}.hs" + cd "$base" + mkdir -p "$src/$name" "$build/$name/lib" "$build/$name/hi" + cd "$src" + cd "$name" + append "module $module_name where" + if [[ $prev != 0 ]] + then + append "\nimport Load${prev}" + fi + for j in $(range $num_funcs) + do + fun="num${num}_${j}" + append "\n$fun :: Int" + if [[ $prev == 0 ]] + then + expr="$j" + else + expr="num${prev}_${j}" + fi + append "$fun = $expr" + done + cd "$build" + file_name="${name}/${name}.conf" + append "name: $name +version: 1.0 +id: ${name}-1.0 +key: ${name}-1.0 +exposed: True +exposed-modules: ${module_name} +import-dirs: \${pkgroot}/build/${name}/hi +dynamic-library-dirs: \${pkgroot}/build/${name}/lib +hs-libraries: HS${name}-1.0" + if [[ $prev != 0 ]] + then + append "depends: load${prev}-1.0" + fi +} + +create_package() +{ + local num="$1" + local prev="$(($num - 1))" + local name="load${num}" + local module_name="Load${num}" + local pkg_build="$build/$name" + if [[ $prev != 0 ]] + then + extra="-package load${prev}" + fi + local opts="-package-db ${db at Q} -hidir ${pkg_build at Q}/hi -O0 -this-unit-id ${name}-1.0 $extra" + # dynamic-too produces .dyn_o and .dyn_hi + # eval "${ghc at Q} $opts -dynamic-too -c ${src at Q}/${name}/${module_name}.hs" + ghc "$opts -dynamic-too -c ${src at Q}/${name}/${module_name}.hs" + # -dynamic instructs GHC to link against shared objects of dependencies + ghc "$opts -dynamic -shared -fPIC -o ${pkg_build at Q}/lib/libHS${name}-1.0-ghc${version_suffix}${dll_ext} ${src at Q}/${name}/${module_name}.dyn_o" + ghc_pkg register "${build at Q}/${name}/${name}.conf" +} + +mkdir "$src" "$build" "$db" + +for i in $(range $num_pkgs) +do + create_sources $i +done + +cd "$base" +ghc_pkg recache + +for i in $(range $num_pkgs) +do + create_package $i +done + +cd "$base" + +file_name="Main.hs" + +append "module Main where" + +# for i in $(range $num_pkgs) +# do +# append "import Load${i}" +# done + +append "import Load${num_pkgs}" + +for i in $(range $num_refs) +do + append " +ref${i} :: Int +ref${i} = sum [" + for j in $(range $num_funcs) + do + append " num${num_pkgs}_${j}," + done + append " 0]" +done + +append ' +main :: IO () +main = do' + +append ' putStrLn $ show $ sum [' + +for i in $(range $num_refs) +do + append " ref${i}," +done + +append " 0]" + +file_name=T23415.script + +append 'import Data.Time.Clock.System +import System.IO +import Data.Int +start <- systemSeconds <$> getSystemTime +writeFile "start-time" (show start) +hPutStrLn stderr "--------------------- START" +' + +for i in $(eval echo "{1..${num_pkgs}}") +# for i in $(eval echo "{${num_pkgs}..1}") +do + append "import Load${i} +putStrLn (show num${i}_1)" +done + +append ' +endLoad1 <- systemSeconds <$> getSystemTime +start :: Int64 <- readIO =<< readFile "start-time" +writeFile "start-time" (show endLoad1) +hPutStrLn stderr ("--------------------- LOADED 1: " ++ show (endLoad1 - start) ++ " seconds") +:load Main +endLoad2 <- systemSeconds <$> getSystemTime +endLoad1 :: Int64 <- readIO =<< readFile "start-time" +hPutStrLn stderr ("--------------------- LOADED 2: " ++ show (endLoad2 - endLoad1) ++ " seconds") +main +endExec1 <- systemSeconds <$> getSystemTime +hPutStrLn stderr ("--------------------- EXECUTED 1: " ++ show (endExec1 - endLoad2) ++ " seconds") +main +endExec2 <- systemSeconds <$> getSystemTime +writeFile "start-time" (show endExec2) +hPutStrLn stderr ("--------------------- EXECUTED 2: " ++ show (endExec2 - endExec1) ++ " seconds") +:reload +main +endExec3 <- systemSeconds <$> getSystemTime +endExec2 :: Int64 <- readIO =<< readFile "start-time" +hPutStrLn stderr ("--------------------- EXECUTED 3: " ++ show (endExec3 - endExec2) ++ " seconds") +' ===================================== testsuite/tests/rts/linker/reuse.conf → testsuite/tests/rts/linker/T23415/reuse.conf ===================================== ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -159,18 +159,3 @@ test('T20918', test('T21618', [unless(opsys('mingw32'), skip), req_rts_linker], makefile_test, ['T21618']) - -###################################### -# https://gitlab.haskell.org/ghc/ghc/-/issues/23415 -# When loading a Haskell symbol from a shared object (here `libHS_Reuse-1.0-ghcXXX.so` created from `Reuse.hs`), -# the native object loader in `loadNativeObj_ELF` stores the object code in a list. -# When the function is called again for the same object, the previously stored object code is returned. -test('T23415', - [extra_files(['Reuse.hs', 'Reuse.script', 'reuse.conf', 'ReusePlugin.hs']), - unless(arch('x86_64'), skip), - unless(opsys('linux'), skip), - unless(doing_ghci, skip), - unless(have_dynamic(),skip), - # grep_stderr('Found existing OC for.*libHSreuse-1.*'), - req_rts_linker], - makefile_test, ['T23415']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e7f4491aaae861bb2c64bb8e9ffa8aaf22ef8bff...17319148af7f860ab0c7a813b601767a8611229a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e7f4491aaae861bb2c64bb8e9ffa8aaf22ef8bff...17319148af7f860ab0c7a813b601767a8611229a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 15 23:55:38 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 15 Mar 2024 19:55:38 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Escape multiple arguments in the settings file Message-ID: <65f4dffa3ef90_27ddd1c97a110709c8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 220568fe by Fendor at 2024-03-15T19:55:07-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - a8186ca5 by Matthew Pickering at 2024-03-15T19:55:08-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - ab9d3bb9 by Matthew Pickering at 2024-03-15T19:55:08-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - eb914c7b by Fendor at 2024-03-15T19:55:11-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 15 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - libraries/ghc-boot/GHC/Settings/Utils.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep - utils/ghc-pkg/Main.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3611,7 +3611,8 @@ compilerInfo dflags ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), ("LibDir", topDir dflags), - -- The path of the global package database used by GHC + -- This is always an absolute path, unlike "Relative Global Package DB" which is + -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ] where ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -112,8 +118,14 @@ initSettings top_dir = do ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" - let globalpkgdb_path = installed "package.conf.d" - ghc_usage_msg_path = installed "ghc-usage.txt" + + -- The package database is either a relative path to the location of the settings file + -- OR an absolute path. + -- In case the path is absolute then top_dir abs_path == abs_path + -- the path is relative then top_dir rel_path == top_dir rel_path + globalpkgdb_path <- installed <$> getSetting "Relative Global Package DB" + + let ghc_usage_msg_path = installed "ghc-usage.txt" ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities @@ -135,12 +147,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +273,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/bindist/Makefile ===================================== @@ -141,6 +141,7 @@ lib/settings : config.mk @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@ @echo ',("RTS expects libdw", "$(GhcRtsWithLibdw)")' >> $@ + @echo ',("Relative Global Package DB", "package.conf.d")' >> $@ @echo "]" >> $@ # We need to install binaries relative to libraries. ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -13,8 +13,6 @@ import Hadrian.Oracles.TextFile import Oracles.Setting (topDirectory, setting, Setting(..)) import Packages import Settings.Program (programContext) -import Hadrian.Oracles.Path -import System.Directory (makeAbsolute) testConfigFile :: Action FilePath testConfigFile = buildRoot <&> (-/- "test/ghcconfig") @@ -81,15 +79,12 @@ testRTSSettings = do file <- testConfigFile words <$> lookupValueOrError Nothing file "GhcRTSWays" -absoluteBuildRoot :: Action FilePath -absoluteBuildRoot = (fixAbsolutePathOnWindows =<< liftIO . makeAbsolute =<< buildRoot) - -- | Directory to look for binaries. -- We assume that required programs are present in the same binary directory -- in which ghc is stored and that they have their conventional name. getBinaryDirectory :: String -> Action FilePath getBinaryDirectory "stage0" = takeDirectory <$> setting SystemGhc -getBinaryDirectory "stage1" = liftM2 (-/-) absoluteBuildRoot (pure "stage1-test/bin/") +getBinaryDirectory "stage1" = liftM2 (-/-) topDirectory (stageBinPath stage0InTree) getBinaryDirectory "stage2" = liftM2 (-/-) topDirectory (stageBinPath Stage1) getBinaryDirectory "stage3" = liftM2 (-/-) topDirectory (stageBinPath Stage2) getBinaryDirectory "stage-cabal" = do @@ -101,7 +96,7 @@ getBinaryDirectory compiler = pure $ takeDirectory compiler -- | Get the path to the given @--test-compiler at . getCompilerPath :: String -> Action FilePath getCompilerPath "stage0" = setting SystemGhc -getCompilerPath "stage1" = liftM2 (-/-) absoluteBuildRoot (pure ("stage1-test/bin/ghc" <.> exe)) +getCompilerPath "stage1" = liftM2 (-/-) topDirectory (fullPath stage0InTree ghc) getCompilerPath "stage2" = liftM2 (-/-) topDirectory (fullPath Stage1 ghc) getCompilerPath "stage3" = liftM2 (-/-) topDirectory (fullPath Stage2 ghc) getCompilerPath "stage-cabal" = do ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -234,8 +235,8 @@ generateRules = do forM_ allStages $ \stage -> do let prefix = root -/- stageString stage -/- "lib" - go gen file = generate file (semiEmptyTarget stage) gen - (prefix -/- "settings") %> go generateSettings + go gen file = generate file (semiEmptyTarget (succStage stage)) gen + (prefix -/- "settings") %> \out -> go (generateSettings out) out where file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out @@ -355,21 +356,26 @@ templateRules = do ghcWrapper :: Stage -> Expr String ghcWrapper (Stage0 {}) = error "Stage0 GHC does not require a wrapper script to run." ghcWrapper stage = do - dbPath <- expr $ () <$> topDirectory <*> packageDbPath (PackageDbLoc stage Final) ghcPath <- expr $ () <$> topDirectory <*> programPath (vanillaContext (predStage stage) ghc) return $ unwords $ map show $ [ ghcPath ] - ++ (if stage == Stage1 - then ["-no-global-package-db" - , "-package-env=-" - , "-package-db " ++ dbPath - ] - else []) ++ [ "$@" ] -generateSettings :: Expr String -generateSettings = do +generateSettings :: FilePath -> Expr String +generateSettings settingsFile = do ctx <- getContext + stage <- getStage + + package_db_path <- expr $ do + let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final) + case stage of + Stage0 {} -> error "Unable to generate settings for stage0" + Stage1 -> get_pkg_db Stage1 + Stage2 -> get_pkg_db Stage1 + Stage3 -> get_pkg_db Stage2 + + let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path + settings <- traverse sequence $ [ ("C compiler command", queryTarget ccPath) , ("C compiler flags", queryTarget ccFlags) @@ -416,11 +422,12 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of @@ -431,23 +438,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +578,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -124,28 +124,6 @@ testRules = do testsuiteDeps - -- we need to create wrappers to test the stage1 compiler - -- as the stage1 compiler needs the stage2 libraries - -- to have any hope of passing tests. - root -/- "stage1-test/bin/*" %> \path -> do - - bin_path <- stageBinPath stage0InTree - let prog = takeBaseName path - stage0prog = bin_path -/- prog <.> exe - need [stage0prog] - abs_prog_path <- liftIO (IO.canonicalizePath stage0prog) - -- Use the stage1 package database - pkgDb <- liftIO . IO.makeAbsolute =<< packageDbPath (PackageDbLoc Stage1 Final) - if prog `elem` ["ghc","runghc"] then do - let flags = [ "-no-global-package-db", "-no-user-package-db", "-hide-package", "ghc" , "-package-env","-","-package-db",pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else if prog == "ghc-pkg" then do - let flags = ["--no-user-package-db", "--global-package-db", pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else createFileLink abs_prog_path path - -- Rules for building check-ppr, check-exact and -- check-ppr-annotations with the compiler we are going to test -- (in-tree or out-of-tree). @@ -344,18 +322,6 @@ needTestsuitePackages stg = do need =<< mapM (uncurry pkgFile) pkgs cross <- flag CrossCompiling when (not cross) $ needIservBins stg - root <- buildRoot - -- require the shims for testing stage1 - when (stg == stage0InTree) $ do - -- Windows not supported as the wrapper scripts don't work on windows.. we could - -- support it with a separate .bat or C wrapper code path but seems overkill when no-one will - -- probably ever try and do this. - when windowsHost $ do - putFailure $ unlines [ "Testing stage1 compiler with windows is currently unsupported," - , "if you desire to do this then please open a ticket"] - fail "Testing stage1 is not supported" - - need =<< sequence [(\f -> root -/- "stage1-test/bin" -/- takeFileName f) <$> (pkgFile stage0InTree p) | (Stage0 InTreeLibs,p) <- exepkgs] -- stage 1 ghc lives under stage0/bin, -- stage 2 ghc lives under stage1/bin, etc ===================================== libraries/ghc-boot/GHC/Settings/Utils.hs ===================================== @@ -8,6 +8,7 @@ import qualified Data.Map as Map import GHC.BaseDir import GHC.Platform.ArchOS +import System.FilePath maybeRead :: Read a => String -> Maybe a maybeRead str = case reads str of @@ -42,6 +43,12 @@ getTargetArchOS settingsFile settings = ArchOS <$> readRawSetting settingsFile settings "target arch" <*> readRawSetting settingsFile settings "target os" +getGlobalPackageDb :: FilePath -> RawSettings -> Either String FilePath +getGlobalPackageDb settingsFile settings = do + rel_db <- getRawSetting settingsFile settings "Relative Global Package DB" + return (dropFileName settingsFile rel_db) + + getRawSetting :: FilePath -> RawSettings -> String -> Either String String ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -28,7 +28,7 @@ import qualified GHC.Unit.Database as GhcPkg import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) -import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) +import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy, getGlobalPackageDb, RawSettings) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) import qualified GHC.Data.ShortText as ST @@ -582,6 +582,21 @@ allPackagesInStack = concatMap packages stackUpTo :: FilePath -> PackageDBStack -> PackageDBStack stackUpTo to_modify = dropWhile ((/= to_modify) . location) +readFromSettingsFile :: FilePath + -> (FilePath -> RawSettings -> Either String b) + -> IO (Either String b) +readFromSettingsFile settingsFile f = do + settingsStr <- readFile settingsFile + pure $ do + mySettings <- case maybeReadFuzzy settingsStr of + Just s -> pure $ Map.fromList s + -- It's excusable to not have a settings file (for now at + -- least) but completely inexcusable to have a malformed one. + Nothing -> Left $ "Can't parse settings file " ++ show settingsFile + case f settingsFile mySettings of + Right archOS -> Right archOS + Left e -> Left e + getPkgDatabases :: Verbosity -> GhcPkg.DbOpenMode mode DbModifySelector -> Bool -- use the user db @@ -605,24 +620,38 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do -- location is passed to the binary using the --global-package-db flag by the -- wrapper script. let err_msg = "missing --global-package-db option, location of global package database unknown\n" - global_conf <- + (top_dir, global_conf) <- case [ f | FlagGlobalConfig f <- my_flags ] of -- See Note [Base Dir] for more information on the base dir / top dir. [] -> do mb_dir <- getBaseDir case mb_dir of Nothing -> die err_msg Just dir -> do - r <- lookForPackageDBIn dir - case r of - Nothing -> die ("Can't find package database in " ++ dir) - Just path -> return path - fs -> return (last fs) - - -- The value of the $topdir variable used in some package descriptions - -- Note that the way we calculate this is slightly different to how it - -- is done in ghc itself. We rely on the convention that the global - -- package db lives in ghc's libdir. - top_dir <- absolutePath (takeDirectory global_conf) + -- Look for where it is given in the settings file, if marked there. + let settingsFile = dir "settings" + exists_settings_file <- doesFileExist settingsFile + erel_db <- + if exists_settings_file + then readFromSettingsFile settingsFile getGlobalPackageDb + else pure (Left ("Settings file doesn't exist: " ++ settingsFile)) + + case erel_db of + Right rel_db -> return (dir, dir rel_db) + -- If the version of GHC doesn't have this field or the settings file + -- doesn't exist for some reason, look in the libdir. + Left err -> do + r <- lookForPackageDBIn dir + case r of + Nothing -> die (unlines [err, ("Fallback: Can't find package database in " ++ dir)]) + Just path -> return (dir, path) + fs -> do + -- The value of the $topdir variable used in some package descriptions + -- Note that the way we calculate this is slightly different to how it + -- is done in ghc itself. We rely on the convention that the global + -- package db lives in ghc's libdir. + let pkg_db = last fs + top_dir <- absolutePath (takeDirectory pkg_db) + return (top_dir, pkg_db) let no_user_db = FlagNoUserDb `elem` my_flags @@ -641,16 +670,11 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do warn $ "WARNING: settings file doesn't exist " ++ show settingsFile warn "cannot know target platform so guessing target == host (native compiler)." pure hostPlatformArchOS - True -> do - settingsStr <- readFile settingsFile - mySettings <- case maybeReadFuzzy settingsStr of - Just s -> pure $ Map.fromList s - -- It's excusable to not have a settings file (for now at - -- least) but completely inexcusable to have a malformed one. - Nothing -> die $ "Can't parse settings file " ++ show settingsFile - case getTargetArchOS settingsFile mySettings of - Right archOS -> pure archOS + True -> + readFromSettingsFile settingsFile getTargetArchOS >>= \case + Right v -> pure v Left e -> die e + let subdir = uniqueSubdir targetArchOS getFirstSuccess :: [IO a] -> IO (Maybe a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9848d58006f7361b847e4991d899fdc5a06d75ca...eb914c7bc49307f246cb58770b167a92e0ddccd5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9848d58006f7361b847e4991d899fdc5a06d75ca...eb914c7bc49307f246cb58770b167a92e0ddccd5 You're receiving 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 Mar 16 13:46:27 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 16 Mar 2024 09:46:27 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Escape multiple arguments in the settings file Message-ID: <65f5a2b388bc9_194f2babac340685eb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3875b5f0 by Fendor at 2024-03-16T09:46:01-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - c4e33527 by Matthew Pickering at 2024-03-16T09:46:02-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - da69a7a0 by Matthew Pickering at 2024-03-16T09:46:02-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 601e560a by Fendor at 2024-03-16T09:46:05-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 15 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - libraries/ghc-boot/GHC/Settings/Utils.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep - utils/ghc-pkg/Main.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3611,7 +3611,8 @@ compilerInfo dflags ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), ("LibDir", topDir dflags), - -- The path of the global package database used by GHC + -- This is always an absolute path, unlike "Relative Global Package DB" which is + -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ] where ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -112,8 +118,14 @@ initSettings top_dir = do ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" - let globalpkgdb_path = installed "package.conf.d" - ghc_usage_msg_path = installed "ghc-usage.txt" + + -- The package database is either a relative path to the location of the settings file + -- OR an absolute path. + -- In case the path is absolute then top_dir abs_path == abs_path + -- the path is relative then top_dir rel_path == top_dir rel_path + globalpkgdb_path <- installed <$> getSetting "Relative Global Package DB" + + let ghc_usage_msg_path = installed "ghc-usage.txt" ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities @@ -135,12 +147,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +273,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/bindist/Makefile ===================================== @@ -141,6 +141,7 @@ lib/settings : config.mk @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@ @echo ',("RTS expects libdw", "$(GhcRtsWithLibdw)")' >> $@ + @echo ',("Relative Global Package DB", "package.conf.d")' >> $@ @echo "]" >> $@ # We need to install binaries relative to libraries. ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -13,8 +13,6 @@ import Hadrian.Oracles.TextFile import Oracles.Setting (topDirectory, setting, Setting(..)) import Packages import Settings.Program (programContext) -import Hadrian.Oracles.Path -import System.Directory (makeAbsolute) testConfigFile :: Action FilePath testConfigFile = buildRoot <&> (-/- "test/ghcconfig") @@ -81,15 +79,12 @@ testRTSSettings = do file <- testConfigFile words <$> lookupValueOrError Nothing file "GhcRTSWays" -absoluteBuildRoot :: Action FilePath -absoluteBuildRoot = (fixAbsolutePathOnWindows =<< liftIO . makeAbsolute =<< buildRoot) - -- | Directory to look for binaries. -- We assume that required programs are present in the same binary directory -- in which ghc is stored and that they have their conventional name. getBinaryDirectory :: String -> Action FilePath getBinaryDirectory "stage0" = takeDirectory <$> setting SystemGhc -getBinaryDirectory "stage1" = liftM2 (-/-) absoluteBuildRoot (pure "stage1-test/bin/") +getBinaryDirectory "stage1" = liftM2 (-/-) topDirectory (stageBinPath stage0InTree) getBinaryDirectory "stage2" = liftM2 (-/-) topDirectory (stageBinPath Stage1) getBinaryDirectory "stage3" = liftM2 (-/-) topDirectory (stageBinPath Stage2) getBinaryDirectory "stage-cabal" = do @@ -101,7 +96,7 @@ getBinaryDirectory compiler = pure $ takeDirectory compiler -- | Get the path to the given @--test-compiler at . getCompilerPath :: String -> Action FilePath getCompilerPath "stage0" = setting SystemGhc -getCompilerPath "stage1" = liftM2 (-/-) absoluteBuildRoot (pure ("stage1-test/bin/ghc" <.> exe)) +getCompilerPath "stage1" = liftM2 (-/-) topDirectory (fullPath stage0InTree ghc) getCompilerPath "stage2" = liftM2 (-/-) topDirectory (fullPath Stage1 ghc) getCompilerPath "stage3" = liftM2 (-/-) topDirectory (fullPath Stage2 ghc) getCompilerPath "stage-cabal" = do ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -234,8 +235,8 @@ generateRules = do forM_ allStages $ \stage -> do let prefix = root -/- stageString stage -/- "lib" - go gen file = generate file (semiEmptyTarget stage) gen - (prefix -/- "settings") %> go generateSettings + go gen file = generate file (semiEmptyTarget (succStage stage)) gen + (prefix -/- "settings") %> \out -> go (generateSettings out) out where file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out @@ -355,21 +356,26 @@ templateRules = do ghcWrapper :: Stage -> Expr String ghcWrapper (Stage0 {}) = error "Stage0 GHC does not require a wrapper script to run." ghcWrapper stage = do - dbPath <- expr $ () <$> topDirectory <*> packageDbPath (PackageDbLoc stage Final) ghcPath <- expr $ () <$> topDirectory <*> programPath (vanillaContext (predStage stage) ghc) return $ unwords $ map show $ [ ghcPath ] - ++ (if stage == Stage1 - then ["-no-global-package-db" - , "-package-env=-" - , "-package-db " ++ dbPath - ] - else []) ++ [ "$@" ] -generateSettings :: Expr String -generateSettings = do +generateSettings :: FilePath -> Expr String +generateSettings settingsFile = do ctx <- getContext + stage <- getStage + + package_db_path <- expr $ do + let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final) + case stage of + Stage0 {} -> error "Unable to generate settings for stage0" + Stage1 -> get_pkg_db Stage1 + Stage2 -> get_pkg_db Stage1 + Stage3 -> get_pkg_db Stage2 + + let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path + settings <- traverse sequence $ [ ("C compiler command", queryTarget ccPath) , ("C compiler flags", queryTarget ccFlags) @@ -416,11 +422,12 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of @@ -431,23 +438,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +578,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -124,28 +124,6 @@ testRules = do testsuiteDeps - -- we need to create wrappers to test the stage1 compiler - -- as the stage1 compiler needs the stage2 libraries - -- to have any hope of passing tests. - root -/- "stage1-test/bin/*" %> \path -> do - - bin_path <- stageBinPath stage0InTree - let prog = takeBaseName path - stage0prog = bin_path -/- prog <.> exe - need [stage0prog] - abs_prog_path <- liftIO (IO.canonicalizePath stage0prog) - -- Use the stage1 package database - pkgDb <- liftIO . IO.makeAbsolute =<< packageDbPath (PackageDbLoc Stage1 Final) - if prog `elem` ["ghc","runghc"] then do - let flags = [ "-no-global-package-db", "-no-user-package-db", "-hide-package", "ghc" , "-package-env","-","-package-db",pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else if prog == "ghc-pkg" then do - let flags = ["--no-user-package-db", "--global-package-db", pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else createFileLink abs_prog_path path - -- Rules for building check-ppr, check-exact and -- check-ppr-annotations with the compiler we are going to test -- (in-tree or out-of-tree). @@ -344,18 +322,6 @@ needTestsuitePackages stg = do need =<< mapM (uncurry pkgFile) pkgs cross <- flag CrossCompiling when (not cross) $ needIservBins stg - root <- buildRoot - -- require the shims for testing stage1 - when (stg == stage0InTree) $ do - -- Windows not supported as the wrapper scripts don't work on windows.. we could - -- support it with a separate .bat or C wrapper code path but seems overkill when no-one will - -- probably ever try and do this. - when windowsHost $ do - putFailure $ unlines [ "Testing stage1 compiler with windows is currently unsupported," - , "if you desire to do this then please open a ticket"] - fail "Testing stage1 is not supported" - - need =<< sequence [(\f -> root -/- "stage1-test/bin" -/- takeFileName f) <$> (pkgFile stage0InTree p) | (Stage0 InTreeLibs,p) <- exepkgs] -- stage 1 ghc lives under stage0/bin, -- stage 2 ghc lives under stage1/bin, etc ===================================== libraries/ghc-boot/GHC/Settings/Utils.hs ===================================== @@ -8,6 +8,7 @@ import qualified Data.Map as Map import GHC.BaseDir import GHC.Platform.ArchOS +import System.FilePath maybeRead :: Read a => String -> Maybe a maybeRead str = case reads str of @@ -42,6 +43,12 @@ getTargetArchOS settingsFile settings = ArchOS <$> readRawSetting settingsFile settings "target arch" <*> readRawSetting settingsFile settings "target os" +getGlobalPackageDb :: FilePath -> RawSettings -> Either String FilePath +getGlobalPackageDb settingsFile settings = do + rel_db <- getRawSetting settingsFile settings "Relative Global Package DB" + return (dropFileName settingsFile rel_db) + + getRawSetting :: FilePath -> RawSettings -> String -> Either String String ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -28,7 +28,7 @@ import qualified GHC.Unit.Database as GhcPkg import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) -import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) +import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy, getGlobalPackageDb, RawSettings) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) import qualified GHC.Data.ShortText as ST @@ -582,6 +582,21 @@ allPackagesInStack = concatMap packages stackUpTo :: FilePath -> PackageDBStack -> PackageDBStack stackUpTo to_modify = dropWhile ((/= to_modify) . location) +readFromSettingsFile :: FilePath + -> (FilePath -> RawSettings -> Either String b) + -> IO (Either String b) +readFromSettingsFile settingsFile f = do + settingsStr <- readFile settingsFile + pure $ do + mySettings <- case maybeReadFuzzy settingsStr of + Just s -> pure $ Map.fromList s + -- It's excusable to not have a settings file (for now at + -- least) but completely inexcusable to have a malformed one. + Nothing -> Left $ "Can't parse settings file " ++ show settingsFile + case f settingsFile mySettings of + Right archOS -> Right archOS + Left e -> Left e + getPkgDatabases :: Verbosity -> GhcPkg.DbOpenMode mode DbModifySelector -> Bool -- use the user db @@ -605,24 +620,38 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do -- location is passed to the binary using the --global-package-db flag by the -- wrapper script. let err_msg = "missing --global-package-db option, location of global package database unknown\n" - global_conf <- + (top_dir, global_conf) <- case [ f | FlagGlobalConfig f <- my_flags ] of -- See Note [Base Dir] for more information on the base dir / top dir. [] -> do mb_dir <- getBaseDir case mb_dir of Nothing -> die err_msg Just dir -> do - r <- lookForPackageDBIn dir - case r of - Nothing -> die ("Can't find package database in " ++ dir) - Just path -> return path - fs -> return (last fs) - - -- The value of the $topdir variable used in some package descriptions - -- Note that the way we calculate this is slightly different to how it - -- is done in ghc itself. We rely on the convention that the global - -- package db lives in ghc's libdir. - top_dir <- absolutePath (takeDirectory global_conf) + -- Look for where it is given in the settings file, if marked there. + let settingsFile = dir "settings" + exists_settings_file <- doesFileExist settingsFile + erel_db <- + if exists_settings_file + then readFromSettingsFile settingsFile getGlobalPackageDb + else pure (Left ("Settings file doesn't exist: " ++ settingsFile)) + + case erel_db of + Right rel_db -> return (dir, dir rel_db) + -- If the version of GHC doesn't have this field or the settings file + -- doesn't exist for some reason, look in the libdir. + Left err -> do + r <- lookForPackageDBIn dir + case r of + Nothing -> die (unlines [err, ("Fallback: Can't find package database in " ++ dir)]) + Just path -> return (dir, path) + fs -> do + -- The value of the $topdir variable used in some package descriptions + -- Note that the way we calculate this is slightly different to how it + -- is done in ghc itself. We rely on the convention that the global + -- package db lives in ghc's libdir. + let pkg_db = last fs + top_dir <- absolutePath (takeDirectory pkg_db) + return (top_dir, pkg_db) let no_user_db = FlagNoUserDb `elem` my_flags @@ -641,16 +670,11 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do warn $ "WARNING: settings file doesn't exist " ++ show settingsFile warn "cannot know target platform so guessing target == host (native compiler)." pure hostPlatformArchOS - True -> do - settingsStr <- readFile settingsFile - mySettings <- case maybeReadFuzzy settingsStr of - Just s -> pure $ Map.fromList s - -- It's excusable to not have a settings file (for now at - -- least) but completely inexcusable to have a malformed one. - Nothing -> die $ "Can't parse settings file " ++ show settingsFile - case getTargetArchOS settingsFile mySettings of - Right archOS -> pure archOS + True -> + readFromSettingsFile settingsFile getTargetArchOS >>= \case + Right v -> pure v Left e -> die e + let subdir = uniqueSubdir targetArchOS getFirstSuccess :: [IO a] -> IO (Maybe a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb914c7bc49307f246cb58770b167a92e0ddccd5...601e560a187b2902ab43a2a6db424caf423cd31a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb914c7bc49307f246cb58770b167a92e0ddccd5...601e560a187b2902ab43a2a6db424caf423cd31a You're receiving 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 Mar 16 14:28:23 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 16 Mar 2024 10:28:23 -0400 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Implement switch (case) jump tables Message-ID: <65f5ac87c0c36_194f2bc39fc0475013@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 9be2b121 by Sven Tennie at 2024-03-16T15:26:36+01:00 Implement switch (case) jump tables - - - - - 3 changed files: - compiler/GHC/CmmToAsm/RV64/CodeGen.hs - compiler/GHC/CmmToAsm/RV64/Instr.hs - compiler/GHC/CmmToAsm/RV64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/CodeGen.hs ===================================== @@ -23,10 +23,16 @@ import GHC.CmmToAsm.RV64.Cond import GHC.CmmToAsm.CPrim import GHC.Cmm.DebugBlock import GHC.CmmToAsm.Monad - ( NatM, getNewRegNat - , getPicBaseMaybeNat, getPlatform, getConfig - , getDebugBlock, getFileId - ) + ( NatM, + getConfig, + getDebugBlock, + getFileId, + getNewLabelNat, + getNewRegNat, + getPicBaseMaybeNat, + getPlatform, + ) + -- import GHC.CmmToAsm.Instr import GHC.CmmToAsm.PIC import GHC.CmmToAsm.Format @@ -208,42 +214,66 @@ annExpr e {- debugIsOn -} = ANN (text . show $ e) -- ----------------------------------------------------------------------------- -- Generating a table-branch --- TODO jump tables would be a lot faster, but we'll use bare bones for now. --- this is usually done by sticking the jump table ids into an instruction --- and then have the @generateJumpTableForInstr@ callback produce the jump --- table as a static. --- --- See Ticket 19912 --- --- data SwitchTargets = --- SwitchTargets --- Bool -- Signed values --- (Integer, Integer) -- Range --- (Maybe Label) -- Default value --- (M.Map Integer Label) -- The branches +-- | Generate jump to jump table target -- --- Non Jumptable plan: --- xE <- expr +-- The index into the jump table is calulated by evaluating @expr at . The +-- corresponding table entry contains the address to jump to. +genSwitch :: NCGConfig -> CmmExpr -> SwitchTargets -> NatM InstrBlock +genSwitch config expr targets = do + (reg, fmt1, e_code) <- getSomeReg indexExpr + let fmt = II64 + tmp <- getNewRegNat fmt + lbl <- getNewLabelNat + dynRef <- cmmMakeDynamicReference config DataReference lbl + (tableReg, fmt2, t_code) <- getSomeReg $ dynRef + let code = + toOL [ COMMENT (text "indexExpr" <+> (text . show) indexExpr) + , COMMENT (text "dynRef" <+> (text . show) dynRef) + ] + `appOL` e_code + `appOL` t_code + `appOL` toOL + [ + COMMENT (ftext "Jump table for switch") + , annExpr expr (LSL (OpReg (formatToWidth fmt1) reg) (OpReg (formatToWidth fmt1) reg) (OpImm (ImmInt 3))) + , ADD (OpReg W64 tmp) (OpReg (formatToWidth fmt1) reg) (OpReg (formatToWidth fmt2) tableReg) + , LDRU II64 (OpReg W64 tmp) (OpAddr (AddrRegImm tmp (ImmInt 0))) + , J_TBL ids (Just lbl) tmp + ] + return code + where + -- See Note [Sub-word subtlety during jump-table indexing] in + -- GHC.CmmToAsm.X86.CodeGen for why we must first offset, then widen. + indexExpr0 = cmmOffset platform expr offset + -- We widen to a native-width register to sanitize the high bits + indexExpr = + CmmMachOp + (MO_UU_Conv expr_w (platformWordWidth platform)) + [indexExpr0] + expr_w = cmmExprWidth platform expr + (offset, ids) = switchTargetsToTable targets + platform = ncgPlatform config + +-- | Generate jump table data (if required) -- -genSwitch :: CmmExpr -> SwitchTargets -> NatM InstrBlock -genSwitch expr targets = do -- pprPanic "genSwitch" (ppr expr) - (reg, format, code) <- getSomeReg expr - let w = formatToWidth format - let mkbranch acc (key, bid) = do - (keyReg, _format, code) <- getSomeReg (CmmLit (CmmInt key w)) - return $ code `appOL` - toOL [ BCOND EQ (OpReg w reg) (OpReg w keyReg) (TBlock bid) - ] `appOL` acc - def_code = case switchTargetsDefault targets of - Just bid -> unitOL (B (TBlock bid)) - Nothing -> nilOL - - switch_code <- foldM mkbranch nilOL (switchTargetsCases targets) - return $ code `appOL` switch_code `appOL` def_code - --- We don't do jump tables for now, see Ticket 19912 -generateJumpTableForInstr :: NCGConfig -> Instr - -> Maybe (NatCmmDecl RawCmmStatics Instr) +-- Relies on PIC relocations. The idea is to emit one table entry per case. The +-- entry is the label of the block to jump to. This will be relocated to be the +-- address of the jump target. +generateJumpTableForInstr :: + NCGConfig -> + Instr -> + Maybe (NatCmmDecl RawCmmStatics Instr) +generateJumpTableForInstr config (J_TBL ids (Just lbl) _) = + let jumpTable = + map jumpTableEntryRel ids + where + jumpTableEntryRel Nothing = + CmmStaticLit (CmmInt 0 (ncgWordWidth config)) + jumpTableEntryRel (Just blockid) = + CmmStaticLit (CmmLabel blockLabel) + where + blockLabel = blockLbl blockid + in Just (CmmData (Section ReadOnlyData lbl) (CmmStaticsRaw lbl jumpTable)) generateJumpTableForInstr _ _ = Nothing -- ----------------------------------------------------------------------------- @@ -275,6 +305,7 @@ stmtToInstrs :: BlockId -- ^ Basic block this statement will start to be placed stmtToInstrs bid stmt = do -- traceM $ "-- -------------------------- stmtToInstrs -------------------------- --\n" -- ++ showSDocUnsafe (ppr stmt) + config <- getConfig platform <- getPlatform case stmt of CmmUnsafeForeignCall target result_regs args @@ -303,7 +334,7 @@ stmtToInstrs bid stmt = do CmmCondBranch arg true false _prediction -> genCondBranch bid true false arg - CmmSwitch arg ids -> genSwitch arg ids + CmmSwitch arg ids -> genSwitch config arg ids CmmCall { cml_target = arg } -> genJump arg ===================================== compiler/GHC/CmmToAsm/RV64/Instr.hs ===================================== @@ -117,6 +117,7 @@ regUsageOfInstr platform instr = case instr of XORI dst src1 _ -> usage (regOp src1, regOp dst) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) + J_TBL _ _ t -> usage ([t], []) B t -> usage (regTarget t, []) B_FAR _t -> usage ([], []) BCOND _ l r t -> usage (regTarget t ++ regOp l ++ regOp r, []) @@ -248,6 +249,7 @@ patchRegsOfInstr instr env = case instr of -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) + J_TBL ids mbLbl t -> J_TBL ids mbLbl (env t) B t -> B (patchTarget t) B_FAR t -> B_FAR t BL t rs ts -> BL (patchTarget t) rs ts @@ -296,6 +298,7 @@ isJumpishInstr :: Instr -> Bool isJumpishInstr instr = case instr of ANN _ i -> isJumpishInstr i J {} -> True + J_TBL {} -> True B {} -> True B_FAR {} -> True BL {} -> True @@ -307,6 +310,7 @@ isJumpishInstr instr = case instr of jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (J_TBL ids _mbLbl _r) = [id | Just id <- ids] jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] jumpDestsOfInstr (B_FAR t) = [t] jumpDestsOfInstr (BL t _ _) = [id | TBlock id <- [t]] @@ -323,6 +327,7 @@ patchJumpInstr instr patchF = case instr of ANN d i -> ANN d (patchJumpInstr i patchF) J (TBlock bid) -> J (TBlock (patchF bid)) + J_TBL ids mbLbl r -> J_TBL (map (fmap patchF) ids) mbLbl r B (TBlock bid) -> B (TBlock (patchF bid)) B_FAR bid -> B_FAR (patchF bid) BL (TBlock bid) ps rs -> BL (TBlock (patchF bid)) ps rs @@ -510,7 +515,8 @@ allocMoreStack platform slots proc@(CmmProc info lbl live (ListGraph code)) = do insert_dealloc insn r = case insn of J _ -> dealloc ++ (insn : r) - ANN _ (J _) -> dealloc ++ (insn : r) + J_TBL {} -> dealloc ++ (insn : r) + ANN _ e -> insert_dealloc e r _other | jumpDestsOfInstr insn /= [] -> patchJumpInstr insn retarget : r _other -> insn : r @@ -659,6 +665,8 @@ data Instr -- Branching. -- TODO: Unused | J Target -- like B, but only generated from genJump. Used to distinguish genJumps from others. + -- | A `J` instruction with data for switch jump tables + | J_TBL [Maybe BlockId] (Maybe CLabel) Reg | B Target -- unconditional branching b/br. (To a blockid, label or register) -- | pseudo-op for far branch targets | B_FAR BlockId @@ -721,6 +729,7 @@ instrCon i = LDRU{} -> "LDRU" CSET{} -> "CSET" J{} -> "J" + J_TBL{} -> "J_TBL" B{} -> "B" B_FAR{} -> "B_FAR" BL{} -> "BL" ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -531,6 +531,7 @@ pprInstr platform instr = case instr of -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) + J_TBL _ _ r -> pprInstr platform (J (TReg r)) -- TODO: This is odd: (B)ranch and branch and link (BL) do the same: branch and link B l | isLabel l -> line $ text "\tjal" <+> pprOp platform x0 <> comma <+> getLabel platform l B (TReg r) -> line $ text "\tjalr" <+> text "x0" <> comma <+> pprReg W64 r <> comma <+> text "0" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9be2b1217a7ba6ca5da5ed157abf4959747bdb95 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9be2b1217a7ba6ca5da5ed157abf4959747bdb95 You're receiving 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 Mar 17 03:27:18 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 16 Mar 2024 23:27:18 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Escape multiple arguments in the settings file Message-ID: <65f66316b9055_3a248fb5ccb681566d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c8c0732b by Fendor at 2024-03-16T23:27:02-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - effeb877 by Matthew Pickering at 2024-03-16T23:27:03-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - fdcdb69f by Matthew Pickering at 2024-03-16T23:27:03-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 182a0997 by Fendor at 2024-03-16T23:27:05-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 15 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - libraries/ghc-boot/GHC/Settings/Utils.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep - utils/ghc-pkg/Main.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3611,7 +3611,8 @@ compilerInfo dflags ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), ("LibDir", topDir dflags), - -- The path of the global package database used by GHC + -- This is always an absolute path, unlike "Relative Global Package DB" which is + -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ] where ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -112,8 +118,14 @@ initSettings top_dir = do ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" - let globalpkgdb_path = installed "package.conf.d" - ghc_usage_msg_path = installed "ghc-usage.txt" + + -- The package database is either a relative path to the location of the settings file + -- OR an absolute path. + -- In case the path is absolute then top_dir abs_path == abs_path + -- the path is relative then top_dir rel_path == top_dir rel_path + globalpkgdb_path <- installed <$> getSetting "Relative Global Package DB" + + let ghc_usage_msg_path = installed "ghc-usage.txt" ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities @@ -135,12 +147,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +273,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/bindist/Makefile ===================================== @@ -141,6 +141,7 @@ lib/settings : config.mk @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@ @echo ',("RTS expects libdw", "$(GhcRtsWithLibdw)")' >> $@ + @echo ',("Relative Global Package DB", "package.conf.d")' >> $@ @echo "]" >> $@ # We need to install binaries relative to libraries. ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -13,8 +13,6 @@ import Hadrian.Oracles.TextFile import Oracles.Setting (topDirectory, setting, Setting(..)) import Packages import Settings.Program (programContext) -import Hadrian.Oracles.Path -import System.Directory (makeAbsolute) testConfigFile :: Action FilePath testConfigFile = buildRoot <&> (-/- "test/ghcconfig") @@ -81,15 +79,12 @@ testRTSSettings = do file <- testConfigFile words <$> lookupValueOrError Nothing file "GhcRTSWays" -absoluteBuildRoot :: Action FilePath -absoluteBuildRoot = (fixAbsolutePathOnWindows =<< liftIO . makeAbsolute =<< buildRoot) - -- | Directory to look for binaries. -- We assume that required programs are present in the same binary directory -- in which ghc is stored and that they have their conventional name. getBinaryDirectory :: String -> Action FilePath getBinaryDirectory "stage0" = takeDirectory <$> setting SystemGhc -getBinaryDirectory "stage1" = liftM2 (-/-) absoluteBuildRoot (pure "stage1-test/bin/") +getBinaryDirectory "stage1" = liftM2 (-/-) topDirectory (stageBinPath stage0InTree) getBinaryDirectory "stage2" = liftM2 (-/-) topDirectory (stageBinPath Stage1) getBinaryDirectory "stage3" = liftM2 (-/-) topDirectory (stageBinPath Stage2) getBinaryDirectory "stage-cabal" = do @@ -101,7 +96,7 @@ getBinaryDirectory compiler = pure $ takeDirectory compiler -- | Get the path to the given @--test-compiler at . getCompilerPath :: String -> Action FilePath getCompilerPath "stage0" = setting SystemGhc -getCompilerPath "stage1" = liftM2 (-/-) absoluteBuildRoot (pure ("stage1-test/bin/ghc" <.> exe)) +getCompilerPath "stage1" = liftM2 (-/-) topDirectory (fullPath stage0InTree ghc) getCompilerPath "stage2" = liftM2 (-/-) topDirectory (fullPath Stage1 ghc) getCompilerPath "stage3" = liftM2 (-/-) topDirectory (fullPath Stage2 ghc) getCompilerPath "stage-cabal" = do ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -234,8 +235,8 @@ generateRules = do forM_ allStages $ \stage -> do let prefix = root -/- stageString stage -/- "lib" - go gen file = generate file (semiEmptyTarget stage) gen - (prefix -/- "settings") %> go generateSettings + go gen file = generate file (semiEmptyTarget (succStage stage)) gen + (prefix -/- "settings") %> \out -> go (generateSettings out) out where file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out @@ -355,21 +356,26 @@ templateRules = do ghcWrapper :: Stage -> Expr String ghcWrapper (Stage0 {}) = error "Stage0 GHC does not require a wrapper script to run." ghcWrapper stage = do - dbPath <- expr $ () <$> topDirectory <*> packageDbPath (PackageDbLoc stage Final) ghcPath <- expr $ () <$> topDirectory <*> programPath (vanillaContext (predStage stage) ghc) return $ unwords $ map show $ [ ghcPath ] - ++ (if stage == Stage1 - then ["-no-global-package-db" - , "-package-env=-" - , "-package-db " ++ dbPath - ] - else []) ++ [ "$@" ] -generateSettings :: Expr String -generateSettings = do +generateSettings :: FilePath -> Expr String +generateSettings settingsFile = do ctx <- getContext + stage <- getStage + + package_db_path <- expr $ do + let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final) + case stage of + Stage0 {} -> error "Unable to generate settings for stage0" + Stage1 -> get_pkg_db Stage1 + Stage2 -> get_pkg_db Stage1 + Stage3 -> get_pkg_db Stage2 + + let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path + settings <- traverse sequence $ [ ("C compiler command", queryTarget ccPath) , ("C compiler flags", queryTarget ccFlags) @@ -416,11 +422,12 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of @@ -431,23 +438,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +578,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -124,28 +124,6 @@ testRules = do testsuiteDeps - -- we need to create wrappers to test the stage1 compiler - -- as the stage1 compiler needs the stage2 libraries - -- to have any hope of passing tests. - root -/- "stage1-test/bin/*" %> \path -> do - - bin_path <- stageBinPath stage0InTree - let prog = takeBaseName path - stage0prog = bin_path -/- prog <.> exe - need [stage0prog] - abs_prog_path <- liftIO (IO.canonicalizePath stage0prog) - -- Use the stage1 package database - pkgDb <- liftIO . IO.makeAbsolute =<< packageDbPath (PackageDbLoc Stage1 Final) - if prog `elem` ["ghc","runghc"] then do - let flags = [ "-no-global-package-db", "-no-user-package-db", "-hide-package", "ghc" , "-package-env","-","-package-db",pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else if prog == "ghc-pkg" then do - let flags = ["--no-user-package-db", "--global-package-db", pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else createFileLink abs_prog_path path - -- Rules for building check-ppr, check-exact and -- check-ppr-annotations with the compiler we are going to test -- (in-tree or out-of-tree). @@ -344,18 +322,6 @@ needTestsuitePackages stg = do need =<< mapM (uncurry pkgFile) pkgs cross <- flag CrossCompiling when (not cross) $ needIservBins stg - root <- buildRoot - -- require the shims for testing stage1 - when (stg == stage0InTree) $ do - -- Windows not supported as the wrapper scripts don't work on windows.. we could - -- support it with a separate .bat or C wrapper code path but seems overkill when no-one will - -- probably ever try and do this. - when windowsHost $ do - putFailure $ unlines [ "Testing stage1 compiler with windows is currently unsupported," - , "if you desire to do this then please open a ticket"] - fail "Testing stage1 is not supported" - - need =<< sequence [(\f -> root -/- "stage1-test/bin" -/- takeFileName f) <$> (pkgFile stage0InTree p) | (Stage0 InTreeLibs,p) <- exepkgs] -- stage 1 ghc lives under stage0/bin, -- stage 2 ghc lives under stage1/bin, etc ===================================== libraries/ghc-boot/GHC/Settings/Utils.hs ===================================== @@ -8,6 +8,7 @@ import qualified Data.Map as Map import GHC.BaseDir import GHC.Platform.ArchOS +import System.FilePath maybeRead :: Read a => String -> Maybe a maybeRead str = case reads str of @@ -42,6 +43,12 @@ getTargetArchOS settingsFile settings = ArchOS <$> readRawSetting settingsFile settings "target arch" <*> readRawSetting settingsFile settings "target os" +getGlobalPackageDb :: FilePath -> RawSettings -> Either String FilePath +getGlobalPackageDb settingsFile settings = do + rel_db <- getRawSetting settingsFile settings "Relative Global Package DB" + return (dropFileName settingsFile rel_db) + + getRawSetting :: FilePath -> RawSettings -> String -> Either String String ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -28,7 +28,7 @@ import qualified GHC.Unit.Database as GhcPkg import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) -import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) +import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy, getGlobalPackageDb, RawSettings) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) import qualified GHC.Data.ShortText as ST @@ -582,6 +582,21 @@ allPackagesInStack = concatMap packages stackUpTo :: FilePath -> PackageDBStack -> PackageDBStack stackUpTo to_modify = dropWhile ((/= to_modify) . location) +readFromSettingsFile :: FilePath + -> (FilePath -> RawSettings -> Either String b) + -> IO (Either String b) +readFromSettingsFile settingsFile f = do + settingsStr <- readFile settingsFile + pure $ do + mySettings <- case maybeReadFuzzy settingsStr of + Just s -> pure $ Map.fromList s + -- It's excusable to not have a settings file (for now at + -- least) but completely inexcusable to have a malformed one. + Nothing -> Left $ "Can't parse settings file " ++ show settingsFile + case f settingsFile mySettings of + Right archOS -> Right archOS + Left e -> Left e + getPkgDatabases :: Verbosity -> GhcPkg.DbOpenMode mode DbModifySelector -> Bool -- use the user db @@ -605,24 +620,38 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do -- location is passed to the binary using the --global-package-db flag by the -- wrapper script. let err_msg = "missing --global-package-db option, location of global package database unknown\n" - global_conf <- + (top_dir, global_conf) <- case [ f | FlagGlobalConfig f <- my_flags ] of -- See Note [Base Dir] for more information on the base dir / top dir. [] -> do mb_dir <- getBaseDir case mb_dir of Nothing -> die err_msg Just dir -> do - r <- lookForPackageDBIn dir - case r of - Nothing -> die ("Can't find package database in " ++ dir) - Just path -> return path - fs -> return (last fs) - - -- The value of the $topdir variable used in some package descriptions - -- Note that the way we calculate this is slightly different to how it - -- is done in ghc itself. We rely on the convention that the global - -- package db lives in ghc's libdir. - top_dir <- absolutePath (takeDirectory global_conf) + -- Look for where it is given in the settings file, if marked there. + let settingsFile = dir "settings" + exists_settings_file <- doesFileExist settingsFile + erel_db <- + if exists_settings_file + then readFromSettingsFile settingsFile getGlobalPackageDb + else pure (Left ("Settings file doesn't exist: " ++ settingsFile)) + + case erel_db of + Right rel_db -> return (dir, dir rel_db) + -- If the version of GHC doesn't have this field or the settings file + -- doesn't exist for some reason, look in the libdir. + Left err -> do + r <- lookForPackageDBIn dir + case r of + Nothing -> die (unlines [err, ("Fallback: Can't find package database in " ++ dir)]) + Just path -> return (dir, path) + fs -> do + -- The value of the $topdir variable used in some package descriptions + -- Note that the way we calculate this is slightly different to how it + -- is done in ghc itself. We rely on the convention that the global + -- package db lives in ghc's libdir. + let pkg_db = last fs + top_dir <- absolutePath (takeDirectory pkg_db) + return (top_dir, pkg_db) let no_user_db = FlagNoUserDb `elem` my_flags @@ -641,16 +670,11 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do warn $ "WARNING: settings file doesn't exist " ++ show settingsFile warn "cannot know target platform so guessing target == host (native compiler)." pure hostPlatformArchOS - True -> do - settingsStr <- readFile settingsFile - mySettings <- case maybeReadFuzzy settingsStr of - Just s -> pure $ Map.fromList s - -- It's excusable to not have a settings file (for now at - -- least) but completely inexcusable to have a malformed one. - Nothing -> die $ "Can't parse settings file " ++ show settingsFile - case getTargetArchOS settingsFile mySettings of - Right archOS -> pure archOS + True -> + readFromSettingsFile settingsFile getTargetArchOS >>= \case + Right v -> pure v Left e -> die e + let subdir = uniqueSubdir targetArchOS getFirstSuccess :: [IO a] -> IO (Maybe a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/601e560a187b2902ab43a2a6db424caf423cd31a...182a09975b1d834b0aeead3c277d72e34d2fb1e5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/601e560a187b2902ab43a2a6db424caf423cd31a...182a09975b1d834b0aeead3c277d72e34d2fb1e5 You're receiving 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 Mar 17 11:19:45 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sun, 17 Mar 2024 07:19:45 -0400 Subject: [Git][ghc/ghc][wip/global-package-db] 75 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65f6d1d1e0492_79c4c1f3d1e885223@gitlab.mail> Matthew Pickering pushed to branch wip/global-package-db at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 382ac566 by Matthew Pickering at 2024-03-17T11:19:39+00:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - bc8d1842 by Matthew Pickering at 2024-03-17T11:19:39+00:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8e3cb48ce42cfd6ea83528ae70df486e011bb017...bc8d184209e1e9767a7229d7f5ad048f5a4f22ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8e3cb48ce42cfd6ea83528ae70df486e011bb017...bc8d184209e1e9767a7229d7f5ad048f5a4f22ab You're receiving 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 Mar 17 15:26:15 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 17 Mar 2024 11:26:15 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24533-missing-comments-2 Message-ID: <65f70b97d3f27_79c4c872358c90057@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24533-missing-comments-2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24533-missing-comments-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 Mar 17 15:58:19 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 17 Mar 2024 11:58:19 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Escape multiple arguments in the settings file Message-ID: <65f7131b6ba89_79c4c95faa881110e0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d7ed2c1a by Fendor at 2024-03-17T11:58:00-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - 47d2eaf6 by Fendor at 2024-03-17T11:58:03-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 9 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Settings/IO.hs - hadrian/src/Rules/Generate.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -135,12 +141,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +267,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -416,7 +417,7 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) @@ -431,23 +432,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +572,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/182a09975b1d834b0aeead3c277d72e34d2fb1e5...47d2eaf6eef0600fb9132e2a22ccac5ff1e514e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/182a09975b1d834b0aeead3c277d72e34d2fb1e5...47d2eaf6eef0600fb9132e2a22ccac5ff1e514e1 You're receiving 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 Mar 17 20:18:59 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 17 Mar 2024 16:18:59 -0400 Subject: [Git][ghc/ghc][wip/az/T24533-missing-comments-2] EPA: Address more 9.10.1-alpha1 regressions from recent changes Message-ID: <65f7503395f97_26f06c1becea8912c8@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24533-missing-comments-2 at Glasgow Haskell Compiler / GHC Commits: 77aeba3c by Alan Zimmerman at 2024-03-17T20:02:20+00:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 5 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77aeba3c35a0f741a9f06a96888a2197fd04e07e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77aeba3c35a0f741a9f06a96888a2197fd04e07e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 04:29:10 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 18 Mar 2024 00:29:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Escape multiple arguments in the settings file Message-ID: <65f7c316bf55e_26f06cf4aa0b0119567@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d93c241f by Fendor at 2024-03-18T00:28:58-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up our flags. We avoid this by escaping the $topdir before replacing in GHC. Add regression test case to count the number of options after variable expansion took place. Additionally, check escaping works. - - - - - 4f7386e8 by Fendor at 2024-03-18T00:29:01-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 9 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Settings/IO.hs - hadrian/src/Rules/Generate.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -135,12 +141,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +267,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -416,7 +417,7 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) @@ -431,23 +432,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +572,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,73 @@ + +import GHC.Settings +import GHC.Settings.IO +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import Data.Maybe (fromJust) +import System.Directory (makeAbsolute) +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +main :: IO () +main = do + topDir <- makeAbsolute "./ghc-install-folder/lib" + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr $ "=== Number of '" <> label <> "' options: " ++ show (length opts) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' and '$tooldir' references. + -- Resolving those while containing spaces, should not introduce more options. + -- '$tooldir' will only be expanded in windows, while '$topdir' is always expanded. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP Flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP Flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- We know in this case, that 'toolSettings_pgm_lm' is 'Just' + recordSetting "Merge objects flags" (map showOpt . snd . fromJust . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,13 @@ +=== Number of 'Haskell CPP flags' options: 5 + Contains spaces: True +=== Number of 'C compiler flags' options: 3 + Contains spaces: True +=== Number of 'C compiler link flags' options: 7 + Contains spaces: True +=== Number of 'C++ compiler flags' options: 2 + Contains spaces: True +=== Number of 'CPP Flags' options: 3 + Contains spaces: True +=== Number of 'Merge objects flags' options: 3 + Contains spaces: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1 @@ +test('T11938', [normal, extra_files(['ghc-install-folder/'])], compile_and_run, ['-package ghc -package directory -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/settings ===================================== @@ -0,0 +1,51 @@ +[("C compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("C compiler flags", "-O2 \"-some option\" -some\\ other") +,("C++ compiler command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++") +,("C++ compiler flags", "\"-some option\" -some\\ other") +,("C compiler link flags", "-fuse-ld=gold -Wl,--no-as-needed \"-some option\" -some\\ other") +,("C compiler supports -no-pie", "YES") +,("CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("CPP flags", "-E \"-some option\" -some\\ other") +,("Haskell CPP command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/cc") +,("Haskell CPP flags", "-E -undef -traditional -I$topdir/ -I$tooldir/") +,("ld supports compact unwind", "NO") +,("ld supports filelist", "NO") +,("ld supports single module", "NO") +,("ld is GNU ld", "YES") +,("Merge objects command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ld.gold") +,("Merge objects flags", "-r \"-some option\" -some\\ other") +,("Merge objects supports response files", "YES") +,("ar command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ar") +,("ar flags", "q") +,("ar supports at file", "YES") +,("ar supports -L", "NO") +,("ranlib command", "/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/ranlib") +,("otool command", "otool") +,("install_name_tool command", "install_name_tool") +,("touch command", "touch") +,("windres command", "/bin/false") +,("unlit command", "$topdir/../bin/unlit") +,("cross compiling", "NO") +,("target platform string", "x86_64-unknown-linux") +,("target os", "OSLinux") +,("target arch", "ArchX86_64") +,("target word size", "8") +,("target word big endian", "NO") +,("target has GNU nonexec stack", "YES") +,("target has .ident directive", "YES") +,("target has subsections via symbols", "NO") +,("target has libm", "YES") +,("Unregisterised", "NO") +,("LLVM target", "x86_64-unknown-linux") +,("LLVM llc command", "llc") +,("LLVM opt command", "opt") +,("LLVM llvm-as command", "clang") +,("Use inplace MinGW toolchain", "NO") +,("Use interpreter", "YES") +,("Support SMP", "YES") +,("RTS ways", "v thr thr_debug thr_debug_dyn thr_dyn debug debug_dyn dyn") +,("Tables next to code", "YES") +,("Leading underscore", "NO") +,("Use LibFFI", "NO") +,("RTS expects libdw", "YES") +] ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47d2eaf6eef0600fb9132e2a22ccac5ff1e514e1...4f7386e8aa1ab74361c2a74c92d1c0d758da6a89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47d2eaf6eef0600fb9132e2a22ccac5ff1e514e1...4f7386e8aa1ab74361c2a74c92d1c0d758da6a89 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 09:48:25 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 18 Mar 2024 05:48:25 -0400 Subject: [Git][ghc/ghc][wip/windows-topdir] Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" Message-ID: <65f80de91dcc7_32062326d63004613@gitlab.mail> Matthew Pickering pushed to branch wip/windows-topdir at Glasgow Haskell Compiler / GHC Commits: ae112bbb by Zubin Duggal at 2024-03-18T09:47:30+00:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - 1 changed file: - m4/fp_settings.m4 Changes: ===================================== m4/fp_settings.m4 ===================================== @@ -44,7 +44,7 @@ dnl ghc-toolchain. AC_DEFUN([SUBST_TOOLDIR], [ dnl and Note [How we configure the bundled windows toolchain] -set -- "$(echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g')" + $1=`echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'` ]) # FP_SETTINGS View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae112bbbbd8c7db7fbc677e589d9803b5e47de2a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae112bbbbd8c7db7fbc677e589d9803b5e47de2a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 11:32:54 2024 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Mon, 18 Mar 2024 07:32:54 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/b/T21336a-skip-wasm Message-ID: <65f82666af1a1_32062350f3a48591b1@gitlab.mail> Bryan R pushed new branch wip/b/T21336a-skip-wasm at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/b/T21336a-skip-wasm You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 11:34:38 2024 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Mon, 18 Mar 2024 07:34:38 -0400 Subject: [Git][ghc/ghc][wip/b/T21336a-skip-wasm] testsuite: Disable T21336a on wasm Message-ID: <65f826ce42c77_32062352dbd3860979@gitlab.mail> Bryan R pushed to branch wip/b/T21336a-skip-wasm at Glasgow Haskell Compiler / GHC Commits: 9765247d by Bryan Richter at 2024-03-18T13:34:27+02:00 testsuite: Disable T21336a on wasm - - - - - 1 changed file: - libraries/base/tests/IO/T21336/all.T Changes: ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -3,6 +3,10 @@ test('T21336a', [ unless(opsys('linux') or opsys('freebsd'), skip) , js_broken(22261) , fragile(22022) + # More than fragile, the test is failing consistently on wasm. See #22022. + # It would be nice to see if the test is NOT fragile on the other + # architectures, but right now I don't know how to check. + , when(arch('wasm32'), skip) , extra_files(['FinalizerExceptionHandler.hs']) ], compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9765247d06764e86931b908c90fa408ec8f66b78 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9765247d06764e86931b908c90fa408ec8f66b78 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 11:35:25 2024 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Mon, 18 Mar 2024 07:35:25 -0400 Subject: [Git][ghc/ghc][wip/b/T21336a-skip-wasm] 74 commits: rel_eng: Update hackage docs upload scripts Message-ID: <65f826fda71ad_3206235494440613b1@gitlab.mail> Bryan R pushed to branch wip/b/T21336a-skip-wasm at Glasgow Haskell Compiler / GHC Commits: 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 2ef9b382 by Bryan Richter at 2024-03-18T13:34:59+02:00 testsuite: Disable T21336a on wasm - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9765247d06764e86931b908c90fa408ec8f66b78...2ef9b382b99f5b22ea9ab3ca7ce9228a0cf97aae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9765247d06764e86931b908c90fa408ec8f66b78...2ef9b382b99f5b22ea9ab3ca7ce9228a0cf97aae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 12:41:09 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 18 Mar 2024 08:41:09 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f8366541092_320623728457c77899@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8304f8fe by Fendor at 2024-03-18T08:40:57-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 7ae667db by Alan Zimmerman at 2024-03-18T08:40:58-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 6 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f7386e8aa1ab74361c2a74c92d1c0d758da6a89...7ae667dbbc811ac944728a3608d72796de6505ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f7386e8aa1ab74361c2a74c92d1c0d758da6a89...7ae667dbbc811ac944728a3608d72796de6505ba You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 13:15:53 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Mon, 18 Mar 2024 09:15:53 -0400 Subject: [Git][ghc/ghc][wip/T24031] 60 commits: Rephrase error message to say "visible arguments" (#24318) Message-ID: <65f83e89201fb_320623856b140862cf@gitlab.mail> Teo Camarasu pushed to branch wip/T24031 at Glasgow Haskell Compiler / GHC Commits: 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 87702681 by Teo Camarasu at 2024-03-18T13:15:48+00:00 Deprecate PrimTyConI - We produce `TyConI` for types where we used to use `PrimTyConI`. - We add a deprecation warning to `PrimTyConI` - We add a test case to ensure we can actually reify primitive types. Resolves #24031 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Predicate.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ead2f38a5f448ea1a669fcbbfa8469004b46f4d...877026819baaba0a63b8709840b151ded8f33df4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ead2f38a5f448ea1a669fcbbfa8469004b46f4d...877026819baaba0a63b8709840b151ded8f33df4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 14:38:51 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 18 Mar 2024 10:38:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/mpickering-hannes Message-ID: <65f851fb26c28_320623a68eb3810067c@gitlab.mail> Matthew Pickering pushed new branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mpickering-hannes You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 15:13:13 2024 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 18 Mar 2024 11:13:13 -0400 Subject: [Git][ghc/ghc][wip/hadrian-subst-bindist] 126 commits: Define GHC2024 language edition (#24320) Message-ID: <65f85a09c32e3_320623b8df63410817@gitlab.mail> John Ericson pushed to branch wip/hadrian-subst-bindist at Glasgow Haskell Compiler / GHC Commits: 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 951f109f by John Ericson at 2024-03-18T11:12:42-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - 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/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/454cc14472536fd21243a44af8404003b2b3c4ce...951f109f9ba2a02b30be18b573ecc09962ab0b6a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/454cc14472536fd21243a44af8404003b2b3c4ce...951f109f9ba2a02b30be18b573ecc09962ab0b6a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 15:31:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 18 Mar 2024 11:31:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f85e581c2ee_320623c599118115953@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3b4fb239 by Fendor at 2024-03-18T11:31:21-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 47b06a3a by Alan Zimmerman at 2024-03-18T11:31:21-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 6 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ae667dbbc811ac944728a3608d72796de6505ba...47b06a3a877222c316ece5e279bf7c4b39aa9529 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ae667dbbc811ac944728a3608d72796de6505ba...47b06a3a877222c316ece5e279bf7c4b39aa9529 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 15:40:20 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 18 Mar 2024 11:40:20 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Make it not take ages Message-ID: <65f8606463d49_320623c7587881240d4@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: b9ce372a by Matthew Pickering at 2024-03-18T15:39:58+00:00 Make it not take ages - - - - - 2 changed files: - compiler/GHC/Iface/Binary.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -241,13 +241,13 @@ writeBinIface profile traceBinIface hi_path mod_iface = do report <- profileBinMem bh writeStackFormat (hi_path <.> "stats") report -writeStackFormat :: FilePath -> Map.Map [String] Int -> IO () +writeStackFormat :: Show a => FilePath -> Map.Map [a] Int -> IO () writeStackFormat fp report = do let elems = Map.assocs report remove_bad = map (\c -> if c `elem` " ;" then '_' else c) withFile fp WriteMode $ \h -> do forM_ elems $ \(k, v) -> do - hPutStrLn h (intercalate ";" (map remove_bad (reverse k)) ++ " " ++ show v) + hPutStrLn h (intercalate ";" (map (remove_bad . show) (reverse k)) ++ " " ++ show v) -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -190,12 +190,18 @@ data BinHandle prof :: {-# UNPACK #-} !BinProf } -data BinProf = BinProf { stack :: ![String], report :: IORef (Map.Map [String] Int) } +data ProfKey = StringKey !String | TypeableKey !TypeRep deriving (Eq, Ord) -initBinProf = BinProf <$> pure ["TOP"] <*> newIORef (Map.empty) +instance Show ProfKey where + show (StringKey s) = s + show (TypeableKey tr) = show tr -addStack :: String -> BinProf -> BinProf -addStack s (BinProf ss i) = (BinProf (s:ss) i) +data BinProf = BinProf { stack :: ![ProfKey], report :: IORef (Map.Map [ProfKey] Int) } + +initBinProf = BinProf <$> pure [StringKey "TOP"] <*> newIORef (Map.empty) + +addStack :: TypeRep -> BinProf -> BinProf +addStack s (BinProf ss i) = (BinProf (TypeableKey s:ss) i) recordSample :: Int -> BinProf -> IO () recordSample weight (BinProf ss i) = modifyIORef i (Map.insertWith (+) ss weight) @@ -259,15 +265,15 @@ class Typeable a => Binary a where putNoStack bh a = do p <- tellBin bh; put_ bh a; return p put_ :: forall a . (Binary a, Typeable a) => BinHandle -> a -> IO () -put_ bh = withCC (show (typeRep (Proxy @a))) bh putNoStack_ +put_ bh = putNoStack_ (withCC ((typeRep (Proxy @a))) bh) -withCC :: String -> BinHandle -> (BinHandle -> k) -> k -withCC c bh k = - if c == head (stack (prof bh)) +withCC :: TypeRep -> BinHandle -> BinHandle +withCC c bh = + if TypeableKey c == head (stack (prof bh)) then - k bh + bh else - k (bh { prof = addStack c (prof bh) }) + (bh { prof = addStack c (prof bh) }) putAt :: Binary a => BinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBin bh p; put_ bh x; return () @@ -312,7 +318,7 @@ writeBinMem (BinMem _ ix_r _ arr_r bp) fn = do unsafeWithForeignPtr arr $ \p -> hPutBuf h p ix hClose h -profileBinMem :: BinHandle -> IO (Map.Map [String] Int) +profileBinMem :: BinHandle -> IO (Map.Map [ProfKey] Int) profileBinMem (BinMem _ _ _ _ bp) = readIORef (report bp) readBinMem :: HasCallStack => FilePath -> IO BinHandle View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b9ce372a38510482910ea20bae04a153fc7a5892 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b9ce372a38510482910ea20bae04a153fc7a5892 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 15:44:11 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Mon, 18 Mar 2024 11:44:11 -0400 Subject: [Git][ghc/ghc][wip/T22859] 38 commits: base: Use strerror_r instead of strerror Message-ID: <65f8614b5ee97_320623c990af01242be@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - 7f9cdce4 by Teo Camarasu at 2024-03-18T15:14:47+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/9.10.1-notes.rst - docs/users_guide/9.8.1-notes.rst - docs/users_guide/exts/type_abstractions.rst - ghc/ghc-bin.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ab9de86d91015e3675d26b75f5ad21250dcd852...7f9cdce47e6c30b40540cdb2d9c91bada4d187dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ab9de86d91015e3675d26b75f5ad21250dcd852...7f9cdce47e6c30b40540cdb2d9c91bada4d187dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 17:37:33 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Mon, 18 Mar 2024 13:37:33 -0400 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] adjustor: Fence for generated code Message-ID: <65f87bdd14b50_3b76e5ef8968385cb@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: c9f1189f by Sven Tennie at 2024-03-18T18:36:34+01:00 adjustor: Fence for generated code - - - - - 1 changed file: - rts/adjustor/LibffiAdjustor.c Changes: ===================================== rts/adjustor/LibffiAdjustor.c ===================================== @@ -187,5 +187,16 @@ createAdjustor (int cconv, barf("createAdjustor: failed to allocate memory"); } +#if defined(riscv64_HOST_ARCH) + // Synchronize the memory and instruction cache to prevent illegal + // instruction exceptions. fence.i works per hart. I'm not sure what happens + // when the generated code is called on another hart. Probably, the fence on + // read/write is good enough for that. However, if there are illegal + // instruction exceptions, this is the place to look at (maybe, that the + // fence.i needs to be moved closely before the call.) + asm volatile ("fence rw, rw" : : : "memory"); + asm volatile ("fence.i" ::: "memory"); +#endif + return (void*)code; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9f1189f524bd1b19bb4410082e2b669155dec67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9f1189f524bd1b19bb4410082e2b669155dec67 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 17:53:43 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 18 Mar 2024 13:53:43 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/shortcut_bug Message-ID: <65f87fa71d0fd_3b76e514ae02440525@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/shortcut_bug You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 17:54:27 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 18 Mar 2024 13:54:27 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] NCG: Fix a bug in jump shortcutting. Message-ID: <65f87fd3c2fe6_3b76e5163247c407e7@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 0134d5aa by Andreas Klebinger at 2024-03-18T18:40:10+01:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,14 +301,14 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ Just id | TBlock id <- [t]] jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> [Just id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,12 +672,12 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [Just id | Just (DestBlockId id) <- ids] _ -> [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0134d5aa841287d8ee3813ee07cefdeb1dafe6cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0134d5aa841287d8ee3813ee07cefdeb1dafe6cc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 17:59:54 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 18 Mar 2024 13:59:54 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] NCG: Fix a bug in jump shortcutting. Message-ID: <65f8811a5f472_3b76e51bb4e4042566@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 09d7049b by Andreas Klebinger at 2024-03-18T18:45:43+01:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,14 +301,14 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ Just id | TBlock id <- [t]] jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> [Just id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [Just (mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09d7049b442caad786b42786b9d518c24401fe83 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09d7049b442caad786b42786b9d518c24401fe83 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 18:16:53 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 18 Mar 2024 14:16:53 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] NCG: Fix a bug in jump shortcutting. Message-ID: <65f88515c96d8_3b76e51f7dd88430de@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 8a28bdc1 by Andreas Klebinger at 2024-03-18T19:02:42+01:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,14 +301,14 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ Just id | TBlock id <- [t]] jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> [Just id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a28bdc178ff3828d93c491e0270d4b1d17959dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a28bdc178ff3828d93c491e0270d4b1d17959dc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 18:46:42 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 18 Mar 2024 14:46:42 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24552 Message-ID: <65f88c12aa7af_3b76e52d92dec45743@gitlab.mail> Apoorv Ingle pushed new branch wip/T24552 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24552 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 19:41:53 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 18 Mar 2024 15:41:53 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f899012949b_3b76e54a299b060583@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 57c490e6 by Fendor at 2024-03-18T15:41:43-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 7d88de7d by Alan Zimmerman at 2024-03-18T15:41:44-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 6 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47b06a3a877222c316ece5e279bf7c4b39aa9529...7d88de7d87ea424d1142ab6cae8658c6f676e057 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47b06a3a877222c316ece5e279bf7c4b39aa9529...7d88de7d87ea424d1142ab6cae8658c6f676e057 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 22:03:45 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 18 Mar 2024 18:03:45 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65f8ba4155216_3b76e585896187527d@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: 33e5ce45 by Apoorv Ingle at 2024-03-18T16:59:51-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches. It now matches the expected semantics. The desugaring for match via `matchWrapper` was overly complex (and wrong) which was introduced while working on expanding `do`-blocks (#18324) - - - - - 4 changed files: - compiler/GHC/HsToCore/Match.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -843,16 +834,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,16 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude hiding (Maybe, Nothing,Just) +import qualified Prelude as P + +data Maybe a = Nothing_ | Just_ a + +pattern Nothing :: Maybe a +pattern Nothing <- Nothing_ where Nothing = Nothing_ + +pattern Just :: a -> Maybe a +pattern Just x <- Just_ x where Just = Just_ + +main = print $ do Just x <- [Nothing, Just ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33e5ce45e3b3342b93deeade11c1759c387664b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33e5ce45e3b3342b93deeade11c1759c387664b6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 18 23:02:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 18 Mar 2024 19:02:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f8c80c11f75_3b76e59fd40e08538b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e882d9ca by Fendor at 2024-03-18T19:02:24-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 289acbf8 by Alan Zimmerman at 2024-03-18T19:02:24-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 6 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d88de7d87ea424d1142ab6cae8658c6f676e057...289acbf8bfda82f9e0f25403540facb21f0b8041 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d88de7d87ea424d1142ab6cae8658c6f676e057...289acbf8bfda82f9e0f25403540facb21f0b8041 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 02:32:58 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 18 Mar 2024 22:32:58 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f8f95aced03_1c1d4940a2c20305e1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8f4e883d by Fendor at 2024-03-18T22:32:43-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - fb64a428 by Alan Zimmerman at 2024-03-18T22:32:44-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 6 changed files: - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/289acbf8bfda82f9e0f25403540facb21f0b8041...fb64a4282009f5707290d4d5c04a818b542467a3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/289acbf8bfda82f9e0f25403540facb21f0b8041...fb64a4282009f5707290d4d5c04a818b542467a3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 05:43:19 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 01:43:19 -0400 Subject: [Git][ghc/ghc][master] Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f925f7bffc2_1c1d4993bb5104614b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - 1 changed file: - compiler/GHC/Iface/Type.hs Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/73be65abafcd4db8e3913415ec866f6e89881f22 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/73be65abafcd4db8e3913415ec866f6e89881f22 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 05:44:06 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 01:44:06 -0400 Subject: [Git][ghc/ghc][master] EPA: Address more 9.10.1-alpha1 regressions from recent changes Message-ID: <65f926263b93e_1c1d499551f3c511ea@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 5 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd8209eb8e447a5ae1d736f034f4a3986e0727f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd8209eb8e447a5ae1d736f034f4a3986e0727f7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 09:18:01 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Tue, 19 Mar 2024 05:18:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/binary-iaarg-instance Message-ID: <65f95849968a4_1c1d49f50cb5c68614@gitlab.mail> Hannes Siebenhandl pushed new branch wip/binary-iaarg-instance at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/binary-iaarg-instance You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 09:39:47 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 05:39:47 -0400 Subject: [Git][ghc/ghc][wip/T22859] 9 commits: Remove duplicate code normalising slashes Message-ID: <65f95d6332fe3_2621dcae48cc10124@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - d0f2d5c5 by Teo Camarasu at 2024-03-19T09:39:34+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/PrimOps.cmm - rts/RtsSymbols.c - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h - rts/include/rts/storage/TSO.h - rts/include/stg/MiscClosures.h - testsuite/driver/testlib.py - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/parser/should_fail/T21843a.stderr - testsuite/tests/parser/should_fail/T21843b.stderr - testsuite/tests/parser/should_fail/T21843c.stderr - testsuite/tests/parser/should_fail/T21843d.stderr - testsuite/tests/parser/should_fail/T21843e.stderr - testsuite/tests/parser/should_fail/T21843f.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7f9cdce47e6c30b40540cdb2d9c91bada4d187dd...d0f2d5c51b2d05d98c330eac8bcbccaf54a33956 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7f9cdce47e6c30b40540cdb2d9c91bada4d187dd...d0f2d5c51b2d05d98c330eac8bcbccaf54a33956 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 09:47:39 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 19 Mar 2024 05:47:39 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/rts-linker-direct-symbol-lookup Message-ID: <65f95f3b97466_2621dcc20bc81036de@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/rts-linker-direct-symbol-lookup You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 10:26:37 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 06:26:37 -0400 Subject: [Git][ghc/ghc][wip/T22859] Implement user-defined allocation limit handlers Message-ID: <65f9685d2d1e3_2621dc1ccc24c1060c2@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 52b27a8c by Teo Camarasu at 2024-03-19T10:26:23+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 16 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/PrimOps.cmm - rts/RtsSymbols.c - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h - rts/include/rts/storage/TSO.h - rts/include/stg/MiscClosures.h - testsuite/tests/interface-stability/ghc-experimental-exports.stdout Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3952,6 +3952,15 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp effect = ReadWriteEffect out_of_line = True +primop SetOtherThreadAllocationCounter "setOtherThreadAllocationCounter#" GenPrimOp + Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld + { Sets the allocation counter for the another thread to the given value. + This doesn't take allocations into the current nursery chunk into account. + Therefore it is only accurate if the other thread is not currently running. } + with + effect = ReadWriteEffect + out_of_line = True + primtype StackSnapshot# { Haskell representation of a @StgStack*@ that was created (cloned) with a function in "GHC.Stack.CloneStack". Please check the ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1746,6 +1746,7 @@ emitPrimOp cfg primop = TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + SetOtherThreadAllocationCounter -> alwaysExternal KeepAliveOp -> alwaysExternal CastWord32ToFloatOp -> alwaysExternal CastWord64ToDoubleOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1167,6 +1167,7 @@ genPrim prof bound ty op = case op of WhereFromOp -> unhandledPrimop op -- should be easily implementable with o.f.n SetThreadAllocationCounter -> unhandledPrimop op + SetOtherThreadAllocationCounter -> unhandledPrimop op ------------------------------- Vector ----------------------------------------- -- For now, vectors are unsupported on the JS backend. Simply put, they do not ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,10 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.Base +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.Foreign.C.Types +import GHC.Internal.IO (unsafePerformIO) +import GHC.Internal.Int (Int64(..)) + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler + +-- | Retrieves the allocation counter for the another thread. +foreign import prim "stg_getOtherThreadAllocationCounterzh" getOtherThreadAllocationCounter# + :: ThreadId# + -> State# RealWorld + -> (# State# RealWorld, Int64# #) + +getAllocationCounterFor :: ThreadId -> IO Int64 +getAllocationCounterFor (ThreadId t#) = IO $ \s -> + case getOtherThreadAllocationCounter# t# s of (# s', i# #) -> (# s', I64# i# #) + +setAllocationCounterFor :: Int64 -> ThreadId -> IO () +setAllocationCounterFor (I64# i#) (ThreadId t#) = IO $ \s -> + case setOtherThreadAllocationCounter# i# t# s of s' -> (# s', () #) + + +-- | Enable allocation limit processing the thread @t at . +enableAllocationLimitFor :: ThreadId -> IO () +enableAllocationLimitFor (ThreadId t) = do + rts_enableThreadAllocationLimit t + +-- | Disable allocation limit processing the thread @t at . +disableAllocationLimitFor :: ThreadId -> IO () +disableAllocationLimitFor (ThreadId t) = do + rts_disableThreadAllocationLimit t + +foreign import ccall unsafe "rts_enableThreadAllocationLimit" + rts_enableThreadAllocationLimit :: ThreadId# -> IO () + +foreign import ccall unsafe "rts_disableThreadAllocationLimit" + rts_disableThreadAllocationLimit :: ThreadId# -> IO () ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziIOziException_allocationLimitExceeded_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/PrimOps.cmm ===================================== @@ -2923,6 +2923,11 @@ stg_getThreadAllocationCounterzh () return (StgTSO_alloc_limit(CurrentTSO) - TO_I64(offset)); } +stg_getOtherThreadAllocationCounterzh ( gcptr t ) +{ + return (StgTSO_alloc_limit(t)); +} + stg_setThreadAllocationCounterzh ( I64 counter ) { // Allocation in the current block will be subtracted by @@ -2935,6 +2940,12 @@ stg_setThreadAllocationCounterzh ( I64 counter ) return (); } +stg_setOtherThreadAllocationCounterzh ( I64 counter, gcptr t ) +{ + StgTSO_alloc_limit(t) = counter; + return (); +} + #define KEEP_ALIVE_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,c) \ w_ info_ptr, \ ===================================== rts/RtsSymbols.c ===================================== @@ -914,7 +914,9 @@ extern char **environ; SymI_HasDataProto(stg_traceMarkerzh) \ SymI_HasDataProto(stg_traceBinaryEventzh) \ SymI_HasDataProto(stg_getThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_getOtherThreadAllocationCounterzh) \ SymI_HasDataProto(stg_setThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_setOtherThreadAllocationCounterzh) \ SymI_HasProto(getMonotonicNSec) \ SymI_HasProto(lockFile) \ SymI_HasProto(unlockFile) \ ===================================== rts/Schedule.c ===================================== @@ -94,6 +94,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1113,19 +1117,35 @@ schedulePostRunThread (Capability *cap, StgTSO *t) } } - // - // If the current thread's allocation limit has run out, send it - // the AllocationLimitExceeded exception. + // Handle the current thread's allocation limit running out, if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Throw the AllocationLimitExceeded exception. + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3347,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ ===================================== rts/include/rts/storage/TSO.h ===================================== @@ -157,9 +157,10 @@ typedef struct StgTSO_ { /* * The allocation limit for this thread, which is updated as the * thread allocates. If the value drops below zero, and - * TSO_ALLOC_LIMIT is set in flags, we raise an exception in the - * thread, and give the thread a little more space to handle the - * exception before we raise the exception again. + * TSO_ALLOC_LIMIT is set in flags, then a handler is triggerd. + * Either we raise an exception in the thread, and give the thread + * a little more space to handle the exception before we raise the + * exception again; or we run a user defined handler. * * This is an integer, because we might update it in a place where * it isn't convenient to raise the exception, so we want it to ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -588,7 +588,9 @@ RTS_FUN_DECL(stg_traceEventzh); RTS_FUN_DECL(stg_traceBinaryEventzh); RTS_FUN_DECL(stg_traceMarkerzh); RTS_FUN_DECL(stg_getThreadAllocationCounterzh); +RTS_FUN_DECL(stg_getOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_setThreadAllocationCounterzh); +RTS_FUN_DECL(stg_setOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_castWord64ToDoublezh); RTS_FUN_DECL(stg_castDoubleToWord64zh); ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -8638,6 +8638,16 @@ module Prelude.Experimental where data Unit# = ... getSolo :: forall a. Solo a -> a +module System.Mem.Experimental where + -- Safety: None + type AllocationLimitKillBehaviour :: * + data AllocationLimitKillBehaviour = KillOnAllocationLimit | DontKillOnAllocationLimit + disableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + enableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + getAllocationCounterFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO GHC.Internal.Int.Int64 + setAllocationCounterFor :: GHC.Internal.Int.Int64 -> GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> GHC.Internal.Maybe.Maybe (GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO ()) -> GHC.Types.IO () + -- Instances: instance GHC.Classes.Eq GHC.Types.Bool -- Defined in ‘GHC.Classes’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52b27a8c01e9712ab7c5c36319474580062d93fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52b27a8c01e9712ab7c5c36319474580062d93fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 11:35:25 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Tue, 19 Mar 2024 07:35:25 -0400 Subject: [Git][ghc/ghc][wip/binary-iaarg-instance] Compact serialisation of IfaceAppArgs Message-ID: <65f9787dc6a06_2621dc3c809441208c0@gitlab.mail> Hannes Siebenhandl pushed to branch wip/binary-iaarg-instance at Glasgow Haskell Compiler / GHC Commits: 0aadb090 by Fendor at 2024-03-19T12:35:11+01:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 1 changed file: - compiler/GHC/Iface/Type.hs Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -716,6 +716,12 @@ ifaceVisAppArgsLength = go 0 | isVisibleForAllTyFlag argf = go (n+1) rest | otherwise = go n rest +ifaceAppArgsLength :: IfaceAppArgs -> Int +ifaceAppArgsLength = go 0 + where + go !n IA_Nil = n + go !n (IA_Arg _ _ ts) = go (n + 1) ts + {- Note [Suppressing invisible arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2072,21 +2078,27 @@ instance Binary IfaceTyLit where _ -> panic ("get IfaceTyLit " ++ show tag) instance Binary IfaceAppArgs where - put_ bh tk = - case tk of - IA_Arg t a ts -> putByte bh 0 >> put_ bh t >> put_ bh a >> put_ bh ts - IA_Nil -> putByte bh 1 + put_ bh tk = do + -- Int is variable length encoded so only + -- one byte for small lists. + put_ bh (ifaceAppArgsLength tk) + go tk + where + go IA_Nil = pure () + go (IA_Arg a b t) = do + put_ bh a + put_ bh b + go t - get bh = - do c <- getByte bh - case c of - 0 -> do - t <- get bh - a <- get bh - ts <- get bh - return $! IA_Arg t a ts - 1 -> return IA_Nil - _ -> panic ("get IfaceAppArgs " ++ show c) + get bh = do + n <- get bh :: IO Int + go n + where + go 0 = return IA_Nil + go c = do + a <- get bh + b <- get bh + IA_Arg a b <$> go (c - 1) ------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0aadb09036d0c66f30e99298039f10c5cb85cc26 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0aadb09036d0c66f30e99298039f10c5cb85cc26 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 11:48:54 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 19 Mar 2024 07:48:54 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24559 Message-ID: <65f97ba6af5e5_2621dc43bef58121168@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24559 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24559 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 11:53:23 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 07:53:23 -0400 Subject: [Git][ghc/ghc][wip/T22859] Implement user-defined allocation limit handlers Message-ID: <65f97cb3c8710_2621dc46a0834124464@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 64ee0149 by Teo Camarasu at 2024-03-19T11:53:07+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 20 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/PrimOps.cmm - rts/RtsSymbols.c - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h - rts/include/rts/storage/TSO.h - rts/include/stg/MiscClosures.h - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/interface-stability/ghc-experimental-exports.stdout Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3952,6 +3952,15 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp effect = ReadWriteEffect out_of_line = True +primop SetOtherThreadAllocationCounter "setOtherThreadAllocationCounter#" GenPrimOp + Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld + { Sets the allocation counter for the another thread to the given value. + This doesn't take allocations into the current nursery chunk into account. + Therefore it is only accurate if the other thread is not currently running. } + with + effect = ReadWriteEffect + out_of_line = True + primtype StackSnapshot# { Haskell representation of a @StgStack*@ that was created (cloned) with a function in "GHC.Stack.CloneStack". Please check the ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1746,6 +1746,7 @@ emitPrimOp cfg primop = TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + SetOtherThreadAllocationCounter -> alwaysExternal KeepAliveOp -> alwaysExternal CastWord32ToFloatOp -> alwaysExternal CastWord64ToDoubleOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1167,6 +1167,7 @@ genPrim prof bound ty op = case op of WhereFromOp -> unhandledPrimop op -- should be easily implementable with o.f.n SetThreadAllocationCounter -> unhandledPrimop op + SetOtherThreadAllocationCounter -> unhandledPrimop op ------------------------------- Vector ----------------------------------------- -- For now, vectors are unsupported on the JS backend. Simply put, they do not ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,10 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.Base +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.Foreign.C.Types +import GHC.Internal.IO (unsafePerformIO) +import GHC.Internal.Int (Int64(..)) + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler + +-- | Retrieves the allocation counter for the another thread. +foreign import prim "stg_getOtherThreadAllocationCounterzh" getOtherThreadAllocationCounter# + :: ThreadId# + -> State# RealWorld + -> (# State# RealWorld, Int64# #) + +getAllocationCounterFor :: ThreadId -> IO Int64 +getAllocationCounterFor (ThreadId t#) = IO $ \s -> + case getOtherThreadAllocationCounter# t# s of (# s', i# #) -> (# s', I64# i# #) + +setAllocationCounterFor :: Int64 -> ThreadId -> IO () +setAllocationCounterFor (I64# i#) (ThreadId t#) = IO $ \s -> + case setOtherThreadAllocationCounter# i# t# s of s' -> (# s', () #) + + +-- | Enable allocation limit processing the thread @t at . +enableAllocationLimitFor :: ThreadId -> IO () +enableAllocationLimitFor (ThreadId t) = do + rts_enableThreadAllocationLimit t + +-- | Disable allocation limit processing the thread @t at . +disableAllocationLimitFor :: ThreadId -> IO () +disableAllocationLimitFor (ThreadId t) = do + rts_disableThreadAllocationLimit t + +foreign import ccall unsafe "rts_enableThreadAllocationLimit" + rts_enableThreadAllocationLimit :: ThreadId# -> IO () + +foreign import ccall unsafe "rts_disableThreadAllocationLimit" + rts_disableThreadAllocationLimit :: ThreadId# -> IO () ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziIOziException_allocationLimitExceeded_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/PrimOps.cmm ===================================== @@ -2923,6 +2923,11 @@ stg_getThreadAllocationCounterzh () return (StgTSO_alloc_limit(CurrentTSO) - TO_I64(offset)); } +stg_getOtherThreadAllocationCounterzh ( gcptr t ) +{ + return (StgTSO_alloc_limit(t)); +} + stg_setThreadAllocationCounterzh ( I64 counter ) { // Allocation in the current block will be subtracted by @@ -2935,6 +2940,12 @@ stg_setThreadAllocationCounterzh ( I64 counter ) return (); } +stg_setOtherThreadAllocationCounterzh ( I64 counter, gcptr t ) +{ + StgTSO_alloc_limit(t) = counter; + return (); +} + #define KEEP_ALIVE_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,c) \ w_ info_ptr, \ ===================================== rts/RtsSymbols.c ===================================== @@ -914,7 +914,9 @@ extern char **environ; SymI_HasDataProto(stg_traceMarkerzh) \ SymI_HasDataProto(stg_traceBinaryEventzh) \ SymI_HasDataProto(stg_getThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_getOtherThreadAllocationCounterzh) \ SymI_HasDataProto(stg_setThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_setOtherThreadAllocationCounterzh) \ SymI_HasProto(getMonotonicNSec) \ SymI_HasProto(lockFile) \ SymI_HasProto(unlockFile) \ ===================================== rts/Schedule.c ===================================== @@ -94,6 +94,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1113,19 +1117,35 @@ schedulePostRunThread (Capability *cap, StgTSO *t) } } - // - // If the current thread's allocation limit has run out, send it - // the AllocationLimitExceeded exception. + // Handle the current thread's allocation limit running out, if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Throw the AllocationLimitExceeded exception. + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3347,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ ===================================== rts/include/rts/storage/TSO.h ===================================== @@ -157,9 +157,10 @@ typedef struct StgTSO_ { /* * The allocation limit for this thread, which is updated as the * thread allocates. If the value drops below zero, and - * TSO_ALLOC_LIMIT is set in flags, we raise an exception in the - * thread, and give the thread a little more space to handle the - * exception before we raise the exception again. + * TSO_ALLOC_LIMIT is set in flags, then a handler is triggerd. + * Either we raise an exception in the thread, and give the thread + * a little more space to handle the exception before we raise the + * exception again; or we run a user defined handler. * * This is an integer, because we might update it in a place where * it isn't convenient to raise the exception, so we want it to ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -588,7 +588,9 @@ RTS_FUN_DECL(stg_traceEventzh); RTS_FUN_DECL(stg_traceBinaryEventzh); RTS_FUN_DECL(stg_traceMarkerzh); RTS_FUN_DECL(stg_getThreadAllocationCounterzh); +RTS_FUN_DECL(stg_getOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_setThreadAllocationCounterzh); +RTS_FUN_DECL(stg_setOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_castWord64ToDoublezh); RTS_FUN_DECL(stg_castDoubleToWord64zh); ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6689,6 +6690,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6658,6 +6659,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4588,6 +4588,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6838,6 +6839,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6689,6 +6690,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -8638,6 +8638,16 @@ module Prelude.Experimental where data Unit# = ... getSolo :: forall a. Solo a -> a +module System.Mem.Experimental where + -- Safety: None + type AllocationLimitKillBehaviour :: * + data AllocationLimitKillBehaviour = KillOnAllocationLimit | DontKillOnAllocationLimit + disableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + enableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + getAllocationCounterFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO GHC.Internal.Int.Int64 + setAllocationCounterFor :: GHC.Internal.Int.Int64 -> GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> GHC.Internal.Maybe.Maybe (GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO ()) -> GHC.Types.IO () + -- Instances: instance GHC.Classes.Eq GHC.Types.Bool -- Defined in ‘GHC.Classes’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64ee01494af677371fbc33e13c2d830ea9d5eacd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64ee01494af677371fbc33e13c2d830ea9d5eacd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 12:17:12 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 08:17:12 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f982484550f_2621dc52d57081262c0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - ebaaf32c by Matthew Pickering at 2024-03-19T08:16:58-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 7059ffa8 by Matthew Pickering at 2024-03-19T08:16:58-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 14a7e8f4 by Bryan Richter at 2024-03-19T08:16:58-04:00 testsuite: Disable T21336a on wasm - - - - - 15 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - libraries/base/tests/IO/T21336/all.T - libraries/ghc-boot/GHC/Settings/Utils.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout - utils/ghc-pkg/Main.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3611,7 +3611,8 @@ compilerInfo dflags ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), ("LibDir", topDir dflags), - -- The path of the global package database used by GHC + -- This is always an absolute path, unlike "Relative Global Package DB" which is + -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ] where ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -112,8 +112,14 @@ initSettings top_dir = do ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" - let globalpkgdb_path = installed "package.conf.d" - ghc_usage_msg_path = installed "ghc-usage.txt" + + -- The package database is either a relative path to the location of the settings file + -- OR an absolute path. + -- In case the path is absolute then top_dir abs_path == abs_path + -- the path is relative then top_dir rel_path == top_dir rel_path + globalpkgdb_path <- installed <$> getSetting "Relative Global Package DB" + + let ghc_usage_msg_path = installed "ghc-usage.txt" ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities ===================================== hadrian/bindist/Makefile ===================================== @@ -141,6 +141,7 @@ lib/settings : config.mk @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@ @echo ',("RTS expects libdw", "$(GhcRtsWithLibdw)")' >> $@ + @echo ',("Relative Global Package DB", "package.conf.d")' >> $@ @echo "]" >> $@ # We need to install binaries relative to libraries. ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -13,8 +13,6 @@ import Hadrian.Oracles.TextFile import Oracles.Setting (topDirectory, setting, Setting(..)) import Packages import Settings.Program (programContext) -import Hadrian.Oracles.Path -import System.Directory (makeAbsolute) testConfigFile :: Action FilePath testConfigFile = buildRoot <&> (-/- "test/ghcconfig") @@ -81,15 +79,12 @@ testRTSSettings = do file <- testConfigFile words <$> lookupValueOrError Nothing file "GhcRTSWays" -absoluteBuildRoot :: Action FilePath -absoluteBuildRoot = (fixAbsolutePathOnWindows =<< liftIO . makeAbsolute =<< buildRoot) - -- | Directory to look for binaries. -- We assume that required programs are present in the same binary directory -- in which ghc is stored and that they have their conventional name. getBinaryDirectory :: String -> Action FilePath getBinaryDirectory "stage0" = takeDirectory <$> setting SystemGhc -getBinaryDirectory "stage1" = liftM2 (-/-) absoluteBuildRoot (pure "stage1-test/bin/") +getBinaryDirectory "stage1" = liftM2 (-/-) topDirectory (stageBinPath stage0InTree) getBinaryDirectory "stage2" = liftM2 (-/-) topDirectory (stageBinPath Stage1) getBinaryDirectory "stage3" = liftM2 (-/-) topDirectory (stageBinPath Stage2) getBinaryDirectory "stage-cabal" = do @@ -101,7 +96,7 @@ getBinaryDirectory compiler = pure $ takeDirectory compiler -- | Get the path to the given @--test-compiler at . getCompilerPath :: String -> Action FilePath getCompilerPath "stage0" = setting SystemGhc -getCompilerPath "stage1" = liftM2 (-/-) absoluteBuildRoot (pure ("stage1-test/bin/ghc" <.> exe)) +getCompilerPath "stage1" = liftM2 (-/-) topDirectory (fullPath stage0InTree ghc) getCompilerPath "stage2" = liftM2 (-/-) topDirectory (fullPath Stage1 ghc) getCompilerPath "stage3" = liftM2 (-/-) topDirectory (fullPath Stage2 ghc) getCompilerPath "stage-cabal" = do ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -234,8 +234,8 @@ generateRules = do forM_ allStages $ \stage -> do let prefix = root -/- stageString stage -/- "lib" - go gen file = generate file (semiEmptyTarget stage) gen - (prefix -/- "settings") %> go generateSettings + go gen file = generate file (semiEmptyTarget (succStage stage)) gen + (prefix -/- "settings") %> \out -> go (generateSettings out) out where file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out @@ -355,21 +355,26 @@ templateRules = do ghcWrapper :: Stage -> Expr String ghcWrapper (Stage0 {}) = error "Stage0 GHC does not require a wrapper script to run." ghcWrapper stage = do - dbPath <- expr $ () <$> topDirectory <*> packageDbPath (PackageDbLoc stage Final) ghcPath <- expr $ () <$> topDirectory <*> programPath (vanillaContext (predStage stage) ghc) return $ unwords $ map show $ [ ghcPath ] - ++ (if stage == Stage1 - then ["-no-global-package-db" - , "-package-env=-" - , "-package-db " ++ dbPath - ] - else []) ++ [ "$@" ] -generateSettings :: Expr String -generateSettings = do +generateSettings :: FilePath -> Expr String +generateSettings settingsFile = do ctx <- getContext + stage <- getStage + + package_db_path <- expr $ do + let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final) + case stage of + Stage0 {} -> error "Unable to generate settings for stage0" + Stage1 -> get_pkg_db Stage1 + Stage2 -> get_pkg_db Stage1 + Stage3 -> get_pkg_db Stage2 + + let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path + settings <- traverse sequence $ [ ("C compiler command", queryTarget ccPath) , ("C compiler flags", queryTarget ccFlags) @@ -421,6 +426,7 @@ generateSettings = do , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -124,28 +124,6 @@ testRules = do testsuiteDeps - -- we need to create wrappers to test the stage1 compiler - -- as the stage1 compiler needs the stage2 libraries - -- to have any hope of passing tests. - root -/- "stage1-test/bin/*" %> \path -> do - - bin_path <- stageBinPath stage0InTree - let prog = takeBaseName path - stage0prog = bin_path -/- prog <.> exe - need [stage0prog] - abs_prog_path <- liftIO (IO.canonicalizePath stage0prog) - -- Use the stage1 package database - pkgDb <- liftIO . IO.makeAbsolute =<< packageDbPath (PackageDbLoc Stage1 Final) - if prog `elem` ["ghc","runghc"] then do - let flags = [ "-no-global-package-db", "-no-user-package-db", "-hide-package", "ghc" , "-package-env","-","-package-db",pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else if prog == "ghc-pkg" then do - let flags = ["--no-user-package-db", "--global-package-db", pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else createFileLink abs_prog_path path - -- Rules for building check-ppr, check-exact and -- check-ppr-annotations with the compiler we are going to test -- (in-tree or out-of-tree). @@ -344,18 +322,6 @@ needTestsuitePackages stg = do need =<< mapM (uncurry pkgFile) pkgs cross <- flag CrossCompiling when (not cross) $ needIservBins stg - root <- buildRoot - -- require the shims for testing stage1 - when (stg == stage0InTree) $ do - -- Windows not supported as the wrapper scripts don't work on windows.. we could - -- support it with a separate .bat or C wrapper code path but seems overkill when no-one will - -- probably ever try and do this. - when windowsHost $ do - putFailure $ unlines [ "Testing stage1 compiler with windows is currently unsupported," - , "if you desire to do this then please open a ticket"] - fail "Testing stage1 is not supported" - - need =<< sequence [(\f -> root -/- "stage1-test/bin" -/- takeFileName f) <$> (pkgFile stage0InTree p) | (Stage0 InTreeLibs,p) <- exepkgs] -- stage 1 ghc lives under stage0/bin, -- stage 2 ghc lives under stage1/bin, etc ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -3,6 +3,10 @@ test('T21336a', [ unless(opsys('linux') or opsys('freebsd'), skip) , js_broken(22261) , fragile(22022) + # More than fragile, the test is failing consistently on wasm. See #22022. + # It would be nice to see if the test is NOT fragile on the other + # architectures, but right now I don't know how to check. + , when(arch('wasm32'), skip) , extra_files(['FinalizerExceptionHandler.hs']) ], compile_and_run, ['']) ===================================== libraries/ghc-boot/GHC/Settings/Utils.hs ===================================== @@ -8,6 +8,7 @@ import qualified Data.Map as Map import GHC.BaseDir import GHC.Platform.ArchOS +import System.FilePath maybeRead :: Read a => String -> Maybe a maybeRead str = case reads str of @@ -42,6 +43,12 @@ getTargetArchOS settingsFile settings = ArchOS <$> readRawSetting settingsFile settings "target arch" <*> readRawSetting settingsFile settings "target os" +getGlobalPackageDb :: FilePath -> RawSettings -> Either String FilePath +getGlobalPackageDb settingsFile settings = do + rel_db <- getRawSetting settingsFile settings "Relative Global Package DB" + return (dropFileName settingsFile rel_db) + + getRawSetting :: FilePath -> RawSettings -> String -> Either String String ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -28,7 +28,7 @@ import qualified GHC.Unit.Database as GhcPkg import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) -import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) +import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy, getGlobalPackageDb, RawSettings) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) import qualified GHC.Data.ShortText as ST @@ -582,6 +582,21 @@ allPackagesInStack = concatMap packages stackUpTo :: FilePath -> PackageDBStack -> PackageDBStack stackUpTo to_modify = dropWhile ((/= to_modify) . location) +readFromSettingsFile :: FilePath + -> (FilePath -> RawSettings -> Either String b) + -> IO (Either String b) +readFromSettingsFile settingsFile f = do + settingsStr <- readFile settingsFile + pure $ do + mySettings <- case maybeReadFuzzy settingsStr of + Just s -> pure $ Map.fromList s + -- It's excusable to not have a settings file (for now at + -- least) but completely inexcusable to have a malformed one. + Nothing -> Left $ "Can't parse settings file " ++ show settingsFile + case f settingsFile mySettings of + Right archOS -> Right archOS + Left e -> Left e + getPkgDatabases :: Verbosity -> GhcPkg.DbOpenMode mode DbModifySelector -> Bool -- use the user db @@ -605,24 +620,38 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do -- location is passed to the binary using the --global-package-db flag by the -- wrapper script. let err_msg = "missing --global-package-db option, location of global package database unknown\n" - global_conf <- + (top_dir, global_conf) <- case [ f | FlagGlobalConfig f <- my_flags ] of -- See Note [Base Dir] for more information on the base dir / top dir. [] -> do mb_dir <- getBaseDir case mb_dir of Nothing -> die err_msg Just dir -> do - r <- lookForPackageDBIn dir - case r of - Nothing -> die ("Can't find package database in " ++ dir) - Just path -> return path - fs -> return (last fs) - - -- The value of the $topdir variable used in some package descriptions - -- Note that the way we calculate this is slightly different to how it - -- is done in ghc itself. We rely on the convention that the global - -- package db lives in ghc's libdir. - top_dir <- absolutePath (takeDirectory global_conf) + -- Look for where it is given in the settings file, if marked there. + let settingsFile = dir "settings" + exists_settings_file <- doesFileExist settingsFile + erel_db <- + if exists_settings_file + then readFromSettingsFile settingsFile getGlobalPackageDb + else pure (Left ("Settings file doesn't exist: " ++ settingsFile)) + + case erel_db of + Right rel_db -> return (dir, dir rel_db) + -- If the version of GHC doesn't have this field or the settings file + -- doesn't exist for some reason, look in the libdir. + Left err -> do + r <- lookForPackageDBIn dir + case r of + Nothing -> die (unlines [err, ("Fallback: Can't find package database in " ++ dir)]) + Just path -> return (dir, path) + fs -> do + -- The value of the $topdir variable used in some package descriptions + -- Note that the way we calculate this is slightly different to how it + -- is done in ghc itself. We rely on the convention that the global + -- package db lives in ghc's libdir. + let pkg_db = last fs + top_dir <- absolutePath (takeDirectory pkg_db) + return (top_dir, pkg_db) let no_user_db = FlagNoUserDb `elem` my_flags @@ -641,16 +670,11 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do warn $ "WARNING: settings file doesn't exist " ++ show settingsFile warn "cannot know target platform so guessing target == host (native compiler)." pure hostPlatformArchOS - True -> do - settingsStr <- readFile settingsFile - mySettings <- case maybeReadFuzzy settingsStr of - Just s -> pure $ Map.fromList s - -- It's excusable to not have a settings file (for now at - -- least) but completely inexcusable to have a malformed one. - Nothing -> die $ "Can't parse settings file " ++ show settingsFile - case getTargetArchOS settingsFile mySettings of - Right archOS -> pure archOS + True -> + readFromSettingsFile settingsFile getTargetArchOS >>= \case + Right v -> pure v Left e -> die e + let subdir = uniqueSubdir targetArchOS getFirstSuccess :: [IO a] -> IO (Maybe a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb64a4282009f5707290d4d5c04a818b542467a3...14a7e8f4e8e040a6409d16b54b3aee4902240cc0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb64a4282009f5707290d4d5c04a818b542467a3...14a7e8f4e8e040a6409d16b54b3aee4902240cc0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 13:32:05 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 19 Mar 2024 09:32:05 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] NCG: Fix a bug in jump shortcutting. Message-ID: <65f993d5df925_2621dc714f2c4131911@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 700e393b by Andreas Klebinger at 2024-03-19T14:17:49+01:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 12 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,14 +301,14 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [Just id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ Just id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ Just id | TBlock id <- [t]] jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> [Just id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} + +bar() { + return (2); +} \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/700e393bd3c2cb4d6e15101f1bbdf7522871ee7b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/700e393bd3c2cb4d6e15101f1bbdf7522871ee7b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 14:42:26 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 19 Mar 2024 10:42:26 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24562 Message-ID: <65f9a4524b837_2621dc918e3dc17213d@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24562 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24562 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 15:30:45 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 19 Mar 2024 11:30:45 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65f9afa539744_2621dca9dbb8824372e@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: fee59d05 by Apoorv Ingle at 2024-03-19T10:28:59-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches. It now matches the expected semantics. The desugaring for match via `matchWrapper` was overly complex (and wrong) which was introduced while working on expanding `do`-blocks (#18324) The bug was that we were filtering out the default wild fail patterns, rather than just discarding the warnings. This patch ensures that we just discards warnings. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -843,16 +834,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -369,8 +369,10 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + spurious warnings and type checker errors, we make sure we drop those spurious warnings + with `discard_warnings_if_skip_pmc` in `HsToCore.Match.matchWrapper` as + appear in the pattern match check within a `do`-expansion generated match. + (see testcase Typeable1.hs) * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we attach to that constraint? It should be a good one, because it'll show up in error ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,16 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude hiding (Maybe, Nothing,Just) +import qualified Prelude as P + +data Maybe a = Nothing_ | Just_ a + +pattern Nothing :: Maybe a +pattern Nothing <- Nothing_ where Nothing = Nothing_ + +pattern Just :: a -> Maybe a +pattern Just x <- Just_ x where Just = Just_ + +main = print $ do Just x <- [Nothing, Just ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fee59d054a514a6a3e3393f05890d73ebafb5e41 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fee59d054a514a6a3e3393f05890d73ebafb5e41 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 15:38:53 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 19 Mar 2024 11:38:53 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65f9b18d48e82_2621dcad1844025172c@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: 04d319c5 by Apoorv Ingle at 2024-03-19T10:38:44-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches. It now matches the expected semantics. The desugaring for match via `matchWrapper` was overly complex (and wrong) which was introduced while working on expanding `do`-blocks (#18324) The bug was that we were filtering out the default wild fail patterns, rather than just discarding the warnings. This patch ensures that we just discards warnings. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -843,16 +834,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -368,9 +368,11 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + After desugaring such patterns are, it is marked as irrefutable! To avoid such + spurious warnings and type checker errors, we make sure we drop those spurious warnings + with `discard_warnings_if_skip_pmc` in `HsToCore.Match.matchWrapper` as they + appear in the pattern match check within an expression associated with a `do`-block expansion. + (see testcase Typeable1.hs) * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we attach to that constraint? It should be a good one, because it'll show up in error ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,16 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude hiding (Maybe, Nothing,Just) +import qualified Prelude as P + +data Maybe a = Nothing_ | Just_ a + +pattern Nothing :: Maybe a +pattern Nothing <- Nothing_ where Nothing = Nothing_ + +pattern Just :: a -> Maybe a +pattern Just x <- Just_ x where Just = Just_ + +main = print $ do Just x <- [Nothing, Just ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04d319c58be7f7dc3242934bc57feee4b761c356 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04d319c58be7f7dc3242934bc57feee4b761c356 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 15:40:58 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 19 Mar 2024 11:40:58 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65f9b20a85fd5_2621dcafc4cfc252065@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: a3e7be02 by Apoorv Ingle at 2024-03-19T10:40:22-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches. It now matches the expected semantics. The desugaring for match via `matchWrapper` was overly complex (and wrong) which was introduced while working on expanding `do`-blocks (#18324) The bug was that we were filtering out the default wild fail patterns, rather than just discarding the warnings. This patch ensures that we just discards warnings. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -843,16 +834,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -368,9 +368,11 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + After desugaring, such patterns are marked as irrefutable! To avoid such + spurious warnings and type checker errors, we make sure we drop those spurious warnings + with `discard_warnings_if_skip_pmc` in `HsToCore.Match.matchWrapper` as they + appear in the pattern match check within an expression associated with a `do`-block expansion. + (see testcase Typeable1.hs) * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we attach to that constraint? It should be a good one, because it'll show up in error ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,16 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude hiding (Maybe, Nothing,Just) +import qualified Prelude as P + +data Maybe a = Nothing_ | Just_ a + +pattern Nothing :: Maybe a +pattern Nothing <- Nothing_ where Nothing = Nothing_ + +pattern Just :: a -> Maybe a +pattern Just x <- Just_ x where Just = Just_ + +main = print $ do Just x <- [Nothing, Just ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3e7be026bfd23bd1b7409328336c71c285573d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3e7be026bfd23bd1b7409328336c71c285573d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 15:41:52 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 19 Mar 2024 11:41:52 -0400 Subject: [Git][ghc/ghc][wip/T24552] 3 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65f9b24062fc1_2621dcb0ed584252562@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 7ca570c2 by Apoorv Ingle at 2024-03-19T15:41:38+00:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches. It now matches the expected semantics. The desugaring for match via `matchWrapper` was overly complex (and wrong) which was introduced while working on expanding `do`-blocks (#18324) The bug was that we were filtering out the default wild fail patterns, rather than just discarding the warnings. This patch ensures that we just discards warnings. - - - - - 11 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Gen/Do.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -843,16 +834,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -368,9 +368,11 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + After desugaring, such patterns are marked as irrefutable! To avoid such + spurious warnings and type checker errors, we make sure we drop those spurious warnings + with `discard_warnings_if_skip_pmc` in `HsToCore.Match.matchWrapper` as they + appear in the pattern match check within an expression associated with a `do`-block expansion. + (see testcase Typeable1.hs) * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we attach to that constraint? It should be a good one, because it'll show up in error ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,16 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude hiding (Maybe, Nothing,Just) +import qualified Prelude as P + +data Maybe a = Nothing_ | Just_ a + +pattern Nothing :: Maybe a +pattern Nothing <- Nothing_ where Nothing = Nothing_ + +pattern Just :: a -> Maybe a +pattern Just x <- Just_ x where Just = Just_ + +main = print $ do Just x <- [Nothing, Just ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a3e7be026bfd23bd1b7409328336c71c285573d5...7ca570c2095709727c039b9856a4017c48d070b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a3e7be026bfd23bd1b7409328336c71c285573d5...7ca570c2095709727c039b9856a4017c48d070b3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 16:08:13 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 12:08:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Escape multiple arguments in the settings file Message-ID: <65f9b86d3a05f_2621dcbf5a84c2693ba@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8cd0c4c2 by Fendor at 2024-03-19T12:07:49-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - 088dc86e by Matthew Pickering at 2024-03-19T12:07:49-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 057ca7a2 by Matthew Pickering at 2024-03-19T12:07:49-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 114a7218 by Matthew Craven at 2024-03-19T12:07:50-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - 175ef046 by Matthew Craven at 2024-03-19T12:07:50-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - c1897a7b by Fendor at 2024-03-19T12:07:52-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - c0d34bea by Krzysztof Gogolewski at 2024-03-19T12:07:53-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - fb436256 by Ben Gamari at 2024-03-19T12:07:53-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 8f753fd9 by Bryan Richter at 2024-03-19T12:07:54-04:00 testsuite: Disable T21336a on wasm - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Stg/Utils.hs - compiler/GHC/StgToCmm/DataCon.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14a7e8f4e8e040a6409d16b54b3aee4902240cc0...8f753fd9d5a34f1f09166feea8ee898eedae3d51 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14a7e8f4e8e040a6409d16b54b3aee4902240cc0...8f753fd9d5a34f1f09166feea8ee898eedae3d51 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 16:15:56 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 12:15:56 -0400 Subject: [Git][ghc/ghc][wip/T24150] 92 commits: testsuite: fix T23540 fragility on 32-bit platforms Message-ID: <65f9ba3c68833_2621dcc3fd6b028004c@gitlab.mail> Teo Camarasu pushed to branch wip/T24150 at Glasgow Haskell Compiler / GHC Commits: 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 29a06cc9 by Teo Camarasu at 2024-03-19T16:15:11+00:00 rts: Allocate non-moving segments with megablocks Non-moving segments are 8 blocks long and need to be aligned. Previously we serviced allocations by grabbing 15 blocks, finding an aligned 8 block group in it and returning the rest. This proved to lead to high levels of fragmentation as a de-allocating a segment caused an 8 block gap to form, and this could not be reused for allocation. This patch introduces a segment allocator based around using entire megablocks to service segment allocations in bulk. When there are no free segments, we grab an entire megablock and fill it with aligned segments. As the megablock is free, we can easily guarantee alignment. Any unused segments are placed on a free list. It only makes sense to free segments in bulk when all of the segments in a megablock are freeable. After sweeping, we grab the free list, sort it, and find all groups of segments where they cover the megablock and free them. This introduces a period of time when free segments are not available to the mutator, but the risk that this would lead to excessive allocation is low. Right after sweep, we should have an abundance of partially full segments, and this pruning step is relatively quick. In implementing this we drop the logic that kept NONMOVING_MAX_FREE segments on the free list. We also introduce an eventlog event to log the amount of pruned/retained free segments. See Note [Segment allocation strategy] Resolves #24150 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/LateCC.hs - + compiler/GHC/Core/LateCC/OverloadedCalls.hs - + compiler/GHC/Core/LateCC/TopLevelBinds.hs - + compiler/GHC/Core/LateCC/Types.hs - + compiler/GHC/Core/LateCC/Utils.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bag.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/70f445cd492816a8f89ff842e8c84dc8972c728b...29a06cc9cc000fa4f829441c044f32880cd3849a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/70f445cd492816a8f89ff842e8c84dc8972c728b...29a06cc9cc000fa4f829441c044f32880cd3849a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 16:18:52 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 12:18:52 -0400 Subject: [Git][ghc/ghc][wip/T24150] rts: Allocate non-moving segments with megablocks Message-ID: <65f9baecca339_2621dcc59ffa428215f@gitlab.mail> Teo Camarasu pushed to branch wip/T24150 at Glasgow Haskell Compiler / GHC Commits: 0a3717b5 by Teo Camarasu at 2024-03-19T16:18:07+00:00 rts: Allocate non-moving segments with megablocks Non-moving segments are 8 blocks long and need to be aligned. Previously we serviced allocations by grabbing 15 blocks, finding an aligned 8 block group in it and returning the rest. This proved to lead to high levels of fragmentation as a de-allocating a segment caused an 8 block gap to form, and this could not be reused for allocation. This patch introduces a segment allocator based around using entire megablocks to service segment allocations in bulk. When there are no free segments, we grab an entire megablock and fill it with aligned segments. As the megablock is free, we can easily guarantee alignment. Any unused segments are placed on a free list. It only makes sense to free segments in bulk when all of the segments in a megablock are freeable. After sweeping, we grab the free list, sort it, and find all groups of segments where they cover the megablock and free them. This introduces a period of time when free segments are not available to the mutator, but the risk that this would lead to excessive allocation is low. Right after sweep, we should have an abundance of partially full segments, and this pruning step is relatively quick. In implementing this we drop the logic that kept NONMOVING_MAX_FREE segments on the free list. We also introduce an eventlog event to log the amount of pruned/retained free segments. See Note [Segment allocation strategy] Resolves #24150 - - - - - 15 changed files: - rts/RtsStartup.c - rts/Trace.c - rts/Trace.h - rts/eventlog/EventLog.c - rts/eventlog/EventLog.h - rts/gen_event_types.py - rts/include/rts/storage/Block.h - rts/include/stg/SMP.h - rts/sm/BlockAlloc.c - rts/sm/GC.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingAllocate.c - rts/sm/Sanity.c - testsuite/tests/rts/atomicinc.c Changes: ===================================== rts/RtsStartup.c ===================================== @@ -454,7 +454,7 @@ hs_exit_(bool wait_foreign) uint32_t g, i; // N.B. atomic_dec returns the new value. - StgInt init_count = (StgInt)atomic_dec(&hs_init_count); + StgInt init_count = (StgInt)atomic_dec(&hs_init_count, 1); if (init_count > 0) { // ignore until it's the last one return; ===================================== rts/Trace.c ===================================== @@ -926,6 +926,12 @@ void traceNonmovingHeapCensus(uint16_t blk_size, postNonmovingHeapCensus(blk_size, census); } +void traceNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments) +{ + if (eventlog_enabled && TRACE_nonmoving_gc) + postNonmovingPrunedSegments(pruned_segments, free_segments); +} + void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG) { #if defined(DEBUG) ===================================== rts/Trace.h ===================================== @@ -331,6 +331,7 @@ void traceConcSweepEnd(void); void traceConcUpdRemSetFlush(Capability *cap); void traceNonmovingHeapCensus(uint16_t blk_size, const struct NonmovingAllocCensus *census); +void traceNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments); void traceIPE(const InfoProvEnt *ipe); void flushTrace(void); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1154,6 +1154,15 @@ void postNonmovingHeapCensus(uint16_t blk_size, RELEASE_LOCK(&eventBufMutex); } +void postNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments) +{ + ACQUIRE_LOCK(&eventBufMutex); + postEventHeader(&eventBuf, EVENT_NONMOVING_PRUNED_SEGMENTS); + postWord32(&eventBuf, pruned_segments); + postWord32(&eventBuf, free_segments); + RELEASE_LOCK(&eventBufMutex); +} + void closeBlockMarker (EventsBuf *ebuf) { if (ebuf->marker) ===================================== rts/eventlog/EventLog.h ===================================== @@ -196,6 +196,7 @@ void postConcUpdRemSetFlush(Capability *cap); void postConcMarkEnd(StgWord32 marked_obj_count); void postNonmovingHeapCensus(uint16_t blk_size, const struct NonmovingAllocCensus *census); +void postNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments); #if defined(TICKY_TICKY) void postTickyCounterDefs(StgEntCounter *p); ===================================== rts/gen_event_types.py ===================================== @@ -132,6 +132,7 @@ event_types = [ EventType(205, 'CONC_SWEEP_END', [], 'End concurrent sweep phase'), EventType(206, 'CONC_UPD_REM_SET_FLUSH', [CapNo], 'Update remembered set flushed'), EventType(207, 'NONMOVING_HEAP_CENSUS', [Word16, Word32, Word32, Word32], 'Nonmoving heap census'), + EventType(208, 'NONMOVING_PRUNED_SEGMENTS', [Word32, Word32], 'Report the amount of segments pruned and remaining on the free list.'), # Ticky-ticky profiling EventType(210, 'TICKY_COUNTER_DEF', VariableLength, 'Ticky-ticky entry counter definition'), ===================================== rts/include/rts/storage/Block.h ===================================== @@ -323,6 +323,10 @@ bdescr *allocGroupOnNode(uint32_t node, W_ n); // bdescr *allocAlignedGroupOnNode(uint32_t node, W_ n); +// Allocate a MBlock worth of `n` block sized chunks aligned at `n`-block boundry. +// This returns a linked list of `bdescr` of length `BLOCKS_PER_MBLOCK / n`. +bdescr *allocMBlockAlignedGroupOnNode(uint32_t node, W_ n); + EXTERN_INLINE bdescr* allocBlockOnNode(uint32_t node); EXTERN_INLINE bdescr* allocBlockOnNode(uint32_t node) { ===================================== rts/include/stg/SMP.h ===================================== @@ -82,13 +82,13 @@ EXTERN_INLINE StgWord cas_seq_cst_relaxed(StgVolatilePtr p, StgWord o, StgWord n EXTERN_INLINE StgWord atomic_inc(StgVolatilePtr p, StgWord n); /* - * Atomic decrement + * Atomic subtraction by the provided quantity. * - * atomic_dec(p) { - * return --(*p); + * atomic_dec(p, n) { + * return ((*p) -= n); * } */ -EXTERN_INLINE StgWord atomic_dec(StgVolatilePtr p); +EXTERN_INLINE StgWord atomic_dec(StgVolatilePtr p, StgWord n); /* * Busy-wait nop: this is a hint to the CPU that we are currently in a @@ -479,9 +479,9 @@ atomic_inc(StgVolatilePtr p, StgWord incr) } EXTERN_INLINE StgWord -atomic_dec(StgVolatilePtr p) +atomic_dec(StgVolatilePtr p, StgWord decr) { - return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST); + return __atomic_sub_fetch(p, decr, __ATOMIC_SEQ_CST); } /* @@ -628,9 +628,9 @@ atomic_inc(StgVolatilePtr p, StgWord incr) } INLINE_HEADER StgWord -atomic_dec(StgVolatilePtr p) +atomic_dec(StgVolatilePtr p, StgWord decr) { - return --(*p); + return ((*p) -= decr); } #endif ===================================== rts/sm/BlockAlloc.c ===================================== @@ -394,6 +394,53 @@ split_block_low (bdescr *bd, W_ n) } +// A variant of `split_block_high` where we keep both blocks. +// The returned block has size `n`, which is split off `bd`. +static bdescr * +split_block_high_no_free (bdescr *bd, W_ n) +{ + ASSERT(bd->blocks > n); + + bdescr* ret = bd + bd->blocks - n; // take n blocks off the end + ret->blocks = n; + ret->start = ret->free = bd->start + (bd->blocks - n)*BLOCK_SIZE_W; + ret->link = NULL; + + bd->blocks -= n; + + setup_tail(ret); + setup_tail(bd); + + return ret; +} + +// Allocate a MBlock worth of `n` block sized chunks aligned at `n`-block boundry. +// This returns a linked list of `bdescr` of length `BLOCKS_PER_MBLOCK / n`. +// We assume relevant locks are held. +bdescr * +allocMBlockAlignedGroupOnNode(uint32_t node, W_ n) +{ + bdescr *bd = allocGroupOnNode(node, BLOCKS_PER_MBLOCK); + + // Free unaligned blocks, as we can't use these. + ASSERT(bd->blocks == BLOCKS_PER_MBLOCK); + bd = split_block_high(bd, bd->blocks - bd->blocks % n); + ASSERT(bd->blocks % n == 0); + + bdescr *last = NULL; + bdescr *chunk = NULL; + // Chain the aligned groups together into a linked-list + while (bd->blocks > n) { + chunk = split_block_high_no_free(bd, n); + chunk->link = last; + last = chunk; + } + bd->link = chunk; + + return bd; +} + + /* Find a fitting block for the allocation request in the given free list. Returns: - not NULL: when an exact match was found in the free list. ===================================== rts/sm/GC.c ===================================== @@ -1313,7 +1313,7 @@ dec_running (void) ACQUIRE_LOCK(&gc_running_mutex); #endif - StgWord r = atomic_dec(&gc_running_threads); + StgWord r = atomic_dec(&gc_running_threads, 1); #if defined(THREADED_RTS) if (r == 0) { ===================================== rts/sm/NonMoving.c ===================================== @@ -248,6 +248,8 @@ static void nonmovingBumpEpoch(void) { * * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. * + * - Note [Segment allocation strategy] explains our segment allocation strategy. + * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage * collector for functional programs on multicore processors. SIGPLAN Not. 51, @@ -560,6 +562,22 @@ static void nonmovingBumpEpoch(void) { * * See #23340 * + * Note [Segment allocation strategy] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Non-moving segments must be aligned. In order, to efficiently service these + * allocations, we allocate segments in bulk + * We allocate an entire megablocks worth of segments at once. + * All unused segments are placed on the `nonmovingHeap.free` list. + * + * Symmetrically we only de-allocate segments if all the segments in a megablock are free-able, ie, + * are on `nonmovingHeap.free`. We prune the free list in `nonmovingPruneFreeSegmentList`, + * called during concurrent sweep phase. + * Note that during pruning of the free list, free segments are not available for use by the + * mutator. This might lead to extra allocation of segments. But the risk is low as just after sweep + * there is usually a large amount of partially full segments, and pruning the free list is quite + * quick. + * + * See #24150 */ memcount nonmoving_segment_live_words = 0; @@ -578,19 +596,6 @@ static void nonmovingExitConcurrentWorker(void); // Add a segment to the free list. void nonmovingPushFreeSegment(struct NonmovingSegment *seg) { - // See Note [Live data accounting in nonmoving collector]. - if (RELAXED_LOAD(&nonmovingHeap.n_free) > NONMOVING_MAX_FREE) { - bdescr *bd = Bdescr((StgPtr) seg); - ACQUIRE_SM_LOCK; - ASSERT(oldest_gen->n_blocks >= bd->blocks); - ASSERT(oldest_gen->n_words >= BLOCK_SIZE_W * bd->blocks); - oldest_gen->n_blocks -= bd->blocks; - oldest_gen->n_words -= BLOCK_SIZE_W * bd->blocks; - freeGroup(bd); - RELEASE_SM_LOCK; - return; - } - SET_SEGMENT_STATE(seg, FREE); while (true) { struct NonmovingSegment *old = nonmovingHeap.free; @@ -601,6 +606,110 @@ void nonmovingPushFreeSegment(struct NonmovingSegment *seg) __sync_add_and_fetch(&nonmovingHeap.n_free, 1); } +static int +cmp_segment_ptr (const void *x, const void *y) +{ + const struct NonMovingSegment *p1 = *(const struct NonMovingSegment**)x; + const struct NonMovingSegment *p2 = *(const struct NonMovingSegment**)y; + if (p1 > p2) return +1; + else if (p1 < p2) return -1; + else return 0; +} + +// Prune the free list of segments that can be freed. +// Segments can be freed if all segments from a mblock are on the free list. +void nonmovingPruneFreeSegmentList(void) +{ + trace(TRACE_nonmoving_gc, "Pruning free segment list."); + // Atomically grab the entire free list. + struct NonmovingSegment *free; + size_t length; + while (true) { + free = ACQUIRE_LOAD(&nonmovingHeap.free); + length = ACQUIRE_LOAD(&nonmovingHeap.n_free); + if (cas((StgVolatilePtr) &nonmovingHeap.free, + (StgWord) free, + (StgWord) NULL) == (StgWord) free) { + atomic_dec((StgVolatilePtr) &nonmovingHeap.n_free, length); + break; + } + // Save the current free list so the sanity checker can see these segments. + nonmovingHeap.saved_free = free; + } + + // Sort the free list by address. + struct NonmovingSegment **sorted = stgMallocBytes(sizeof(struct NonmovingSegment*) * length, "sorted free segment list"); + for(size_t i = 0; ilink; + } + // we should have reached the end of the free list + ASSERT(free == NULL); + + qsort(sorted, length, sizeof(struct NonmovingSegment*), cmp_segment_ptr); + + // Walk the sorted list and either: + // - free segments if the entire megablock is free + // - put it back on the free list + size_t new_length = 0; + size_t free_in_megablock = 0; + // iterate through segments by megablock + for(size_t i = 0; ilink = last; + new_length++; + } + } else { + // the megablock is free, so let's free all the segments. + ACQUIRE_SM_LOCK; + for(size_t j = 0; j < free_in_megablock;j++){ + bdescr *bd = Bdescr((StgPtr)sorted[i+j]); + freeGroup(bd); + } + RELEASE_SM_LOCK; + } + } + stgFree(sorted); + // If we have any segments left over, then put them back on the free list. + if(free) { + struct NonmovingSegment* tail = free; + while(tail->link) { + tail = tail->link; + } + while (true) { + struct NonmovingSegment* rest = ACQUIRE_LOAD(&nonmovingHeap.free); + tail->link = rest; + if (cas((StgVolatilePtr) &nonmovingHeap.free, + (StgWord) rest, + (StgWord) free) == (StgWord) rest) { + __sync_add_and_fetch(&nonmovingHeap.n_free, new_length); + break; + } + } + } + size_t pruned_segments = length - new_length; + // See Note [Live data accounting in nonmoving collector]. + oldest_gen->n_blocks -= pruned_segments * NONMOVING_SEGMENT_BLOCKS; + oldest_gen->n_words -= pruned_segments * NONMOVING_SEGMENT_SIZE; + nonmovingHeap.saved_free = NULL; + debugTrace(DEBUG_nonmoving_gc, + "Pruned %d free segments, leaving %d on the free segment list.", + pruned_segments, new_length); + traceNonmovingPrunedSegments(pruned_segments, new_length); + trace(TRACE_nonmoving_gc, "Finished pruning free segment list."); + +} + void nonmovingInitAllocator(struct NonmovingAllocator* alloc, uint16_t block_size) { *alloc = (struct NonmovingAllocator) @@ -1216,6 +1325,7 @@ concurrent_marking: nonmovingSweepStableNameTable(); nonmovingSweep(); + nonmovingPruneFreeSegmentList(); ASSERT(nonmovingHeap.sweep_list == NULL); debugTrace(DEBUG_nonmoving_gc, "Finished sweeping."); traceConcSweepEnd(); ===================================== rts/sm/NonMoving.h ===================================== @@ -119,16 +119,16 @@ extern uint8_t nonmoving_alloca_dense_cnt; // NONMOVING_SEGMENT_SIZE (in bytes) extern uint8_t nonmoving_alloca_cnt; -// maximum number of free segments to hold on to -#define NONMOVING_MAX_FREE 16 - struct NonmovingHeap { struct NonmovingAllocator *allocators; - // free segment list. This is a cache where we keep up to - // NONMOVING_MAX_FREE segments to avoid thrashing the block allocator. + // free segment list. This is a cache where we keep segments + // belonging to megablocks that are only partially free. // Note that segments in this list are still counted towards // oldest_gen->n_blocks. struct NonmovingSegment *free; + // saved free segment list, so the sanity checker can + // see the segments while the free list is being pruned. + struct NonmovingSegment *saved_free; // how many segments in free segment list? accessed atomically. unsigned int n_free; @@ -172,6 +172,7 @@ void nonmovingCollect(StgWeak **dead_weaks, bool concurrent); void nonmovingPushFreeSegment(struct NonmovingSegment *seg); +void nonmovingPruneFreeSegmentList(void); INLINE_HEADER unsigned long log2_ceil(unsigned long x) { ===================================== rts/sm/NonMovingAllocate.c ===================================== @@ -65,19 +65,42 @@ static struct NonmovingSegment *nonmovingAllocSegment(enum AllocLockMode mode, u struct NonmovingSegment *ret; ret = nonmovingPopFreeSegment(); - // Nothing in the free list, allocate a new segment... + // Nothing in the free list, allocate a new segment. + // We allocate a full megablock, and add spare segments to our free list. if (ret == NULL) { acquire_alloc_lock(mode); - bdescr *bd = allocAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); - // See Note [Live data accounting in nonmoving collector]. - oldest_gen->n_blocks += bd->blocks; - oldest_gen->n_words += BLOCK_SIZE_W * bd->blocks; + // Another thread might have allocated while we were waiting for the lock. + ret = nonmovingPopFreeSegment(); + if (ret != NULL) { + release_alloc_lock(mode); + // Check alignment + ASSERT(((uintptr_t)ret % NONMOVING_SEGMENT_SIZE) == 0); + return ret; + } + + bdescr *bd = allocMBlockAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); release_alloc_lock(mode); - for (StgWord32 i = 0; i < bd->blocks; ++i) { + W_ alloc_blocks = BLOCKS_PER_MBLOCK - (BLOCKS_PER_MBLOCK % NONMOVING_SEGMENT_BLOCKS); + + // See Note [Live data accounting in nonmoving collector]. + oldest_gen->n_blocks += alloc_blocks; + oldest_gen->n_words += BLOCK_SIZE_W * alloc_blocks; + + for (StgWord32 i = 0; i < alloc_blocks; ++i) { initBdescr(&bd[i], oldest_gen, oldest_gen); bd[i].flags = BF_NONMOVING; } + + // Push all but the last segment to the free segment list. + while(bd->link) { + bdescr *next_bd = bd->link; + bd->link = NULL; + nonmovingPushFreeSegment((struct NonmovingSegment *)bd->start); + bd = next_bd; + } + + // Use the last segment to service the allocation. ret = (struct NonmovingSegment *)bd->start; } ===================================== rts/sm/Sanity.c ===================================== @@ -1238,6 +1238,7 @@ countNonMovingHeap(struct NonmovingHeap *heap) } ret += countNonMovingSegments(heap->sweep_list); ret += countNonMovingSegments(heap->free); + ret += countNonMovingSegments(heap->saved_free); return ret; } ===================================== testsuite/tests/rts/atomicinc.c ===================================== @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) CHECK(j == 1); CHECK(i == 1); - j = atomic_dec(&i); + j = atomic_dec(&i,1); CHECK(j == 0); CHECK(i == 0); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a3717b519e51ba8354f245874379fd6b4ff88c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a3717b519e51ba8354f245874379fd6b4ff88c0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 16:26:27 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 12:26:27 -0400 Subject: [Git][ghc/ghc][wip/T24150] rts: Allocate non-moving segments with megablocks Message-ID: <65f9bcb32f9b9_2621dccd5332c290372@gitlab.mail> Teo Camarasu pushed to branch wip/T24150 at Glasgow Haskell Compiler / GHC Commits: 1757ae34 by Teo Camarasu at 2024-03-19T16:26:04+00:00 rts: Allocate non-moving segments with megablocks Non-moving segments are 8 blocks long and need to be aligned. Previously we serviced allocations by grabbing 15 blocks, finding an aligned 8 block group in it and returning the rest. This proved to lead to high levels of fragmentation as a de-allocating a segment caused an 8 block gap to form, and this could not be reused for allocation. This patch introduces a segment allocator based around using entire megablocks to service segment allocations in bulk. When there are no free segments, we grab an entire megablock and fill it with aligned segments. As the megablock is free, we can easily guarantee alignment. Any unused segments are placed on a free list. It only makes sense to free segments in bulk when all of the segments in a megablock are freeable. After sweeping, we grab the free list, sort it, and find all groups of segments where they cover the megablock and free them. This introduces a period of time when free segments are not available to the mutator, but the risk that this would lead to excessive allocation is low. Right after sweep, we should have an abundance of partially full segments, and this pruning step is relatively quick. In implementing this we drop the logic that kept NONMOVING_MAX_FREE segments on the free list. We also introduce an eventlog event to log the amount of pruned/retained free segments. See Note [Segment allocation strategy] Resolves #24150 - - - - - 16 changed files: - + docs/users_guide/9.12.1-notes.rst - rts/RtsStartup.c - rts/Trace.c - rts/Trace.h - rts/eventlog/EventLog.c - rts/eventlog/EventLog.h - rts/gen_event_types.py - rts/include/rts/storage/Block.h - rts/include/stg/SMP.h - rts/sm/BlockAlloc.c - rts/sm/GC.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingAllocate.c - rts/sm/Sanity.c - testsuite/tests/rts/atomicinc.c Changes: ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -0,0 +1,91 @@ +.. _release-9-12-1: + +Version 9.12.1 +============== +The significant changes to the various parts of the compiler are listed in the +following sections. See the `migration guide +`_ on the GHC Wiki +for specific guidance on migrating programs to this release. + +Language +~~~~~~~~ + +Compiler +~~~~~~~~ + +JavaScript backend +~~~~~~~~~~~~~~~~~~ + +WebAssembly backend +~~~~~~~~~~~~~~~~~~~ + +GHCi +~~~~ + +Runtime system +~~~~~~~~~~~~~~ + +- Reduce fragmentation incurred by the nonmoving GC's segment allocator. In one application this reduced resident set size by 26%. See :ghc-ticket:`24150`. + + +``base`` library +~~~~~~~~~~~~~~~~ + +``ghc-prim`` library +~~~~~~~~~~~~~~~~~~~~ + +``ghc`` library +~~~~~~~~~~~~~~~ + +``ghc-heap`` library +~~~~~~~~~~~~~~~~~~~~ + +``ghc-experimental`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``template-haskell`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Included libraries +~~~~~~~~~~~~~~~~~~ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== rts/RtsStartup.c ===================================== @@ -454,7 +454,7 @@ hs_exit_(bool wait_foreign) uint32_t g, i; // N.B. atomic_dec returns the new value. - StgInt init_count = (StgInt)atomic_dec(&hs_init_count); + StgInt init_count = (StgInt)atomic_dec(&hs_init_count, 1); if (init_count > 0) { // ignore until it's the last one return; ===================================== rts/Trace.c ===================================== @@ -926,6 +926,12 @@ void traceNonmovingHeapCensus(uint16_t blk_size, postNonmovingHeapCensus(blk_size, census); } +void traceNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments) +{ + if (eventlog_enabled && TRACE_nonmoving_gc) + postNonmovingPrunedSegments(pruned_segments, free_segments); +} + void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG) { #if defined(DEBUG) ===================================== rts/Trace.h ===================================== @@ -331,6 +331,7 @@ void traceConcSweepEnd(void); void traceConcUpdRemSetFlush(Capability *cap); void traceNonmovingHeapCensus(uint16_t blk_size, const struct NonmovingAllocCensus *census); +void traceNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments); void traceIPE(const InfoProvEnt *ipe); void flushTrace(void); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1154,6 +1154,15 @@ void postNonmovingHeapCensus(uint16_t blk_size, RELEASE_LOCK(&eventBufMutex); } +void postNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments) +{ + ACQUIRE_LOCK(&eventBufMutex); + postEventHeader(&eventBuf, EVENT_NONMOVING_PRUNED_SEGMENTS); + postWord32(&eventBuf, pruned_segments); + postWord32(&eventBuf, free_segments); + RELEASE_LOCK(&eventBufMutex); +} + void closeBlockMarker (EventsBuf *ebuf) { if (ebuf->marker) ===================================== rts/eventlog/EventLog.h ===================================== @@ -196,6 +196,7 @@ void postConcUpdRemSetFlush(Capability *cap); void postConcMarkEnd(StgWord32 marked_obj_count); void postNonmovingHeapCensus(uint16_t blk_size, const struct NonmovingAllocCensus *census); +void postNonmovingPrunedSegments(uint32_t pruned_segments, uint32_t free_segments); #if defined(TICKY_TICKY) void postTickyCounterDefs(StgEntCounter *p); ===================================== rts/gen_event_types.py ===================================== @@ -132,6 +132,7 @@ event_types = [ EventType(205, 'CONC_SWEEP_END', [], 'End concurrent sweep phase'), EventType(206, 'CONC_UPD_REM_SET_FLUSH', [CapNo], 'Update remembered set flushed'), EventType(207, 'NONMOVING_HEAP_CENSUS', [Word16, Word32, Word32, Word32], 'Nonmoving heap census'), + EventType(208, 'NONMOVING_PRUNED_SEGMENTS', [Word32, Word32], 'Report the amount of segments pruned and remaining on the free list.'), # Ticky-ticky profiling EventType(210, 'TICKY_COUNTER_DEF', VariableLength, 'Ticky-ticky entry counter definition'), ===================================== rts/include/rts/storage/Block.h ===================================== @@ -323,6 +323,10 @@ bdescr *allocGroupOnNode(uint32_t node, W_ n); // bdescr *allocAlignedGroupOnNode(uint32_t node, W_ n); +// Allocate a MBlock worth of `n` block sized chunks aligned at `n`-block boundry. +// This returns a linked list of `bdescr` of length `BLOCKS_PER_MBLOCK / n`. +bdescr *allocMBlockAlignedGroupOnNode(uint32_t node, W_ n); + EXTERN_INLINE bdescr* allocBlockOnNode(uint32_t node); EXTERN_INLINE bdescr* allocBlockOnNode(uint32_t node) { ===================================== rts/include/stg/SMP.h ===================================== @@ -82,13 +82,13 @@ EXTERN_INLINE StgWord cas_seq_cst_relaxed(StgVolatilePtr p, StgWord o, StgWord n EXTERN_INLINE StgWord atomic_inc(StgVolatilePtr p, StgWord n); /* - * Atomic decrement + * Atomic subtraction by the provided quantity. * - * atomic_dec(p) { - * return --(*p); + * atomic_dec(p, n) { + * return ((*p) -= n); * } */ -EXTERN_INLINE StgWord atomic_dec(StgVolatilePtr p); +EXTERN_INLINE StgWord atomic_dec(StgVolatilePtr p, StgWord n); /* * Busy-wait nop: this is a hint to the CPU that we are currently in a @@ -479,9 +479,9 @@ atomic_inc(StgVolatilePtr p, StgWord incr) } EXTERN_INLINE StgWord -atomic_dec(StgVolatilePtr p) +atomic_dec(StgVolatilePtr p, StgWord decr) { - return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST); + return __atomic_sub_fetch(p, decr, __ATOMIC_SEQ_CST); } /* @@ -628,9 +628,9 @@ atomic_inc(StgVolatilePtr p, StgWord incr) } INLINE_HEADER StgWord -atomic_dec(StgVolatilePtr p) +atomic_dec(StgVolatilePtr p, StgWord decr) { - return --(*p); + return ((*p) -= decr); } #endif ===================================== rts/sm/BlockAlloc.c ===================================== @@ -394,6 +394,53 @@ split_block_low (bdescr *bd, W_ n) } +// A variant of `split_block_high` where we keep both blocks. +// The returned block has size `n`, which is split off `bd`. +static bdescr * +split_block_high_no_free (bdescr *bd, W_ n) +{ + ASSERT(bd->blocks > n); + + bdescr* ret = bd + bd->blocks - n; // take n blocks off the end + ret->blocks = n; + ret->start = ret->free = bd->start + (bd->blocks - n)*BLOCK_SIZE_W; + ret->link = NULL; + + bd->blocks -= n; + + setup_tail(ret); + setup_tail(bd); + + return ret; +} + +// Allocate a MBlock worth of `n` block sized chunks aligned at `n`-block boundry. +// This returns a linked list of `bdescr` of length `BLOCKS_PER_MBLOCK / n`. +// We assume relevant locks are held. +bdescr * +allocMBlockAlignedGroupOnNode(uint32_t node, W_ n) +{ + bdescr *bd = allocGroupOnNode(node, BLOCKS_PER_MBLOCK); + + // Free unaligned blocks, as we can't use these. + ASSERT(bd->blocks == BLOCKS_PER_MBLOCK); + bd = split_block_high(bd, bd->blocks - bd->blocks % n); + ASSERT(bd->blocks % n == 0); + + bdescr *last = NULL; + bdescr *chunk = NULL; + // Chain the aligned groups together into a linked-list + while (bd->blocks > n) { + chunk = split_block_high_no_free(bd, n); + chunk->link = last; + last = chunk; + } + bd->link = chunk; + + return bd; +} + + /* Find a fitting block for the allocation request in the given free list. Returns: - not NULL: when an exact match was found in the free list. ===================================== rts/sm/GC.c ===================================== @@ -1313,7 +1313,7 @@ dec_running (void) ACQUIRE_LOCK(&gc_running_mutex); #endif - StgWord r = atomic_dec(&gc_running_threads); + StgWord r = atomic_dec(&gc_running_threads, 1); #if defined(THREADED_RTS) if (r == 0) { ===================================== rts/sm/NonMoving.c ===================================== @@ -248,6 +248,8 @@ static void nonmovingBumpEpoch(void) { * * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. * + * - Note [Segment allocation strategy] explains our segment allocation strategy. + * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage * collector for functional programs on multicore processors. SIGPLAN Not. 51, @@ -560,6 +562,22 @@ static void nonmovingBumpEpoch(void) { * * See #23340 * + * Note [Segment allocation strategy] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Non-moving segments must be aligned. In order, to efficiently service these + * allocations, we allocate segments in bulk + * We allocate an entire megablocks worth of segments at once. + * All unused segments are placed on the `nonmovingHeap.free` list. + * + * Symmetrically we only de-allocate segments if all the segments in a megablock are free-able, ie, + * are on `nonmovingHeap.free`. We prune the free list in `nonmovingPruneFreeSegmentList`, + * called during concurrent sweep phase. + * Note that during pruning of the free list, free segments are not available for use by the + * mutator. This might lead to extra allocation of segments. But the risk is low as just after sweep + * there is usually a large amount of partially full segments, and pruning the free list is quite + * quick. + * + * See #24150 */ memcount nonmoving_segment_live_words = 0; @@ -578,19 +596,6 @@ static void nonmovingExitConcurrentWorker(void); // Add a segment to the free list. void nonmovingPushFreeSegment(struct NonmovingSegment *seg) { - // See Note [Live data accounting in nonmoving collector]. - if (RELAXED_LOAD(&nonmovingHeap.n_free) > NONMOVING_MAX_FREE) { - bdescr *bd = Bdescr((StgPtr) seg); - ACQUIRE_SM_LOCK; - ASSERT(oldest_gen->n_blocks >= bd->blocks); - ASSERT(oldest_gen->n_words >= BLOCK_SIZE_W * bd->blocks); - oldest_gen->n_blocks -= bd->blocks; - oldest_gen->n_words -= BLOCK_SIZE_W * bd->blocks; - freeGroup(bd); - RELEASE_SM_LOCK; - return; - } - SET_SEGMENT_STATE(seg, FREE); while (true) { struct NonmovingSegment *old = nonmovingHeap.free; @@ -601,6 +606,110 @@ void nonmovingPushFreeSegment(struct NonmovingSegment *seg) __sync_add_and_fetch(&nonmovingHeap.n_free, 1); } +static int +cmp_segment_ptr (const void *x, const void *y) +{ + const struct NonMovingSegment *p1 = *(const struct NonMovingSegment**)x; + const struct NonMovingSegment *p2 = *(const struct NonMovingSegment**)y; + if (p1 > p2) return +1; + else if (p1 < p2) return -1; + else return 0; +} + +// Prune the free list of segments that can be freed. +// Segments can be freed if all segments from a mblock are on the free list. +void nonmovingPruneFreeSegmentList(void) +{ + trace(TRACE_nonmoving_gc, "Pruning free segment list."); + // Atomically grab the entire free list. + struct NonmovingSegment *free; + size_t length; + while (true) { + free = ACQUIRE_LOAD(&nonmovingHeap.free); + length = ACQUIRE_LOAD(&nonmovingHeap.n_free); + if (cas((StgVolatilePtr) &nonmovingHeap.free, + (StgWord) free, + (StgWord) NULL) == (StgWord) free) { + atomic_dec((StgVolatilePtr) &nonmovingHeap.n_free, length); + break; + } + // Save the current free list so the sanity checker can see these segments. + nonmovingHeap.saved_free = free; + } + + // Sort the free list by address. + struct NonmovingSegment **sorted = stgMallocBytes(sizeof(struct NonmovingSegment*) * length, "sorted free segment list"); + for(size_t i = 0; ilink; + } + // we should have reached the end of the free list + ASSERT(free == NULL); + + qsort(sorted, length, sizeof(struct NonmovingSegment*), cmp_segment_ptr); + + // Walk the sorted list and either: + // - free segments if the entire megablock is free + // - put it back on the free list + size_t new_length = 0; + size_t free_in_megablock = 0; + // iterate through segments by megablock + for(size_t i = 0; ilink = last; + new_length++; + } + } else { + // the megablock is free, so let's free all the segments. + ACQUIRE_SM_LOCK; + for(size_t j = 0; j < free_in_megablock;j++){ + bdescr *bd = Bdescr((StgPtr)sorted[i+j]); + freeGroup(bd); + } + RELEASE_SM_LOCK; + } + } + stgFree(sorted); + // If we have any segments left over, then put them back on the free list. + if(free) { + struct NonmovingSegment* tail = free; + while(tail->link) { + tail = tail->link; + } + while (true) { + struct NonmovingSegment* rest = ACQUIRE_LOAD(&nonmovingHeap.free); + tail->link = rest; + if (cas((StgVolatilePtr) &nonmovingHeap.free, + (StgWord) rest, + (StgWord) free) == (StgWord) rest) { + __sync_add_and_fetch(&nonmovingHeap.n_free, new_length); + break; + } + } + } + size_t pruned_segments = length - new_length; + // See Note [Live data accounting in nonmoving collector]. + oldest_gen->n_blocks -= pruned_segments * NONMOVING_SEGMENT_BLOCKS; + oldest_gen->n_words -= pruned_segments * NONMOVING_SEGMENT_SIZE; + nonmovingHeap.saved_free = NULL; + debugTrace(DEBUG_nonmoving_gc, + "Pruned %d free segments, leaving %d on the free segment list.", + pruned_segments, new_length); + traceNonmovingPrunedSegments(pruned_segments, new_length); + trace(TRACE_nonmoving_gc, "Finished pruning free segment list."); + +} + void nonmovingInitAllocator(struct NonmovingAllocator* alloc, uint16_t block_size) { *alloc = (struct NonmovingAllocator) @@ -1216,6 +1325,7 @@ concurrent_marking: nonmovingSweepStableNameTable(); nonmovingSweep(); + nonmovingPruneFreeSegmentList(); ASSERT(nonmovingHeap.sweep_list == NULL); debugTrace(DEBUG_nonmoving_gc, "Finished sweeping."); traceConcSweepEnd(); ===================================== rts/sm/NonMoving.h ===================================== @@ -119,16 +119,16 @@ extern uint8_t nonmoving_alloca_dense_cnt; // NONMOVING_SEGMENT_SIZE (in bytes) extern uint8_t nonmoving_alloca_cnt; -// maximum number of free segments to hold on to -#define NONMOVING_MAX_FREE 16 - struct NonmovingHeap { struct NonmovingAllocator *allocators; - // free segment list. This is a cache where we keep up to - // NONMOVING_MAX_FREE segments to avoid thrashing the block allocator. + // free segment list. This is a cache where we keep segments + // belonging to megablocks that are only partially free. // Note that segments in this list are still counted towards // oldest_gen->n_blocks. struct NonmovingSegment *free; + // saved free segment list, so the sanity checker can + // see the segments while the free list is being pruned. + struct NonmovingSegment *saved_free; // how many segments in free segment list? accessed atomically. unsigned int n_free; @@ -172,6 +172,7 @@ void nonmovingCollect(StgWeak **dead_weaks, bool concurrent); void nonmovingPushFreeSegment(struct NonmovingSegment *seg); +void nonmovingPruneFreeSegmentList(void); INLINE_HEADER unsigned long log2_ceil(unsigned long x) { ===================================== rts/sm/NonMovingAllocate.c ===================================== @@ -65,19 +65,42 @@ static struct NonmovingSegment *nonmovingAllocSegment(enum AllocLockMode mode, u struct NonmovingSegment *ret; ret = nonmovingPopFreeSegment(); - // Nothing in the free list, allocate a new segment... + // Nothing in the free list, allocate a new segment. + // We allocate a full megablock, and add spare segments to our free list. if (ret == NULL) { acquire_alloc_lock(mode); - bdescr *bd = allocAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); - // See Note [Live data accounting in nonmoving collector]. - oldest_gen->n_blocks += bd->blocks; - oldest_gen->n_words += BLOCK_SIZE_W * bd->blocks; + // Another thread might have allocated while we were waiting for the lock. + ret = nonmovingPopFreeSegment(); + if (ret != NULL) { + release_alloc_lock(mode); + // Check alignment + ASSERT(((uintptr_t)ret % NONMOVING_SEGMENT_SIZE) == 0); + return ret; + } + + bdescr *bd = allocMBlockAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); release_alloc_lock(mode); - for (StgWord32 i = 0; i < bd->blocks; ++i) { + W_ alloc_blocks = BLOCKS_PER_MBLOCK - (BLOCKS_PER_MBLOCK % NONMOVING_SEGMENT_BLOCKS); + + // See Note [Live data accounting in nonmoving collector]. + oldest_gen->n_blocks += alloc_blocks; + oldest_gen->n_words += BLOCK_SIZE_W * alloc_blocks; + + for (StgWord32 i = 0; i < alloc_blocks; ++i) { initBdescr(&bd[i], oldest_gen, oldest_gen); bd[i].flags = BF_NONMOVING; } + + // Push all but the last segment to the free segment list. + while(bd->link) { + bdescr *next_bd = bd->link; + bd->link = NULL; + nonmovingPushFreeSegment((struct NonmovingSegment *)bd->start); + bd = next_bd; + } + + // Use the last segment to service the allocation. ret = (struct NonmovingSegment *)bd->start; } ===================================== rts/sm/Sanity.c ===================================== @@ -1238,6 +1238,7 @@ countNonMovingHeap(struct NonmovingHeap *heap) } ret += countNonMovingSegments(heap->sweep_list); ret += countNonMovingSegments(heap->free); + ret += countNonMovingSegments(heap->saved_free); return ret; } ===================================== testsuite/tests/rts/atomicinc.c ===================================== @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) CHECK(j == 1); CHECK(i == 1); - j = atomic_dec(&i); + j = atomic_dec(&i,1); CHECK(j == 0); CHECK(i == 0); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1757ae3489776d8178783d869dbdb5e91cbff626 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1757ae3489776d8178783d869dbdb5e91cbff626 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 16:29:09 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 12:29:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24567 Message-ID: <65f9bd5581788_2621dcce69dd8294076@gitlab.mail> Teo Camarasu pushed new branch wip/T24567 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24567 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 16:30:54 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 19 Mar 2024 12:30:54 -0400 Subject: [Git][ghc/ghc][wip/T24567] Add preamble to 9.10 release notes Message-ID: <65f9bdbdf1e8c_2621dccf5ddac297146@gitlab.mail> Teo Camarasu pushed to branch wip/T24567 at Glasgow Haskell Compiler / GHC Commits: 7fea9b43 by Teo Camarasu at 2024-03-19T16:30:44+00:00 Add preamble to 9.10 release notes Resolves #24567 - - - - - 1 changed file: - docs/users_guide/9.10.1-notes.rst Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -2,6 +2,10 @@ Version 9.10.1 ============== +The significant changes to the various parts of the compiler are listed in the +following sections. See the `migration guide +`_ on the GHC Wiki +for specific guidance on migrating programs to this release. Language ~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7fea9b43c5b541797f81ec70b4d949e2cca4d1eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7fea9b43c5b541797f81ec70b4d949e2cca4d1eb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 17:14:26 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 19 Mar 2024 13:14:26 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] 2 commits: working Message-ID: <65f9c7f29fa42_2621dce3cdcd83070bc@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: 806e8243 by Matthew Pickering at 2024-03-19T16:31:08+00:00 working - - - - - 9f3dddd5 by Fendor at 2024-03-19T17:13:52+00:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 18 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Decl.hs - compiler/GHC/Iface/Env.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Recomp/Binary.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Var.hs - compiler/GHC/Utils/Binary.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -952,13 +952,13 @@ data CoSel -- See Note [SelCo] | SelForAll -- Decomposes (forall a. co) - deriving( Eq, Data.Data ) + deriving( Eq, Data.Data, Ord ) data FunSel -- See Note [SelCo] = SelMult -- Multiplicity | SelArg -- Argument of function | SelRes -- Result of function - deriving( Eq, Data.Data ) + deriving( Eq, Data.Data, Ord ) type CoercionN = Coercion -- always nominal type CoercionR = Coercion -- always representational ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -121,7 +121,7 @@ toIfaceTvBndr :: TyVar -> IfaceTvBndr toIfaceTvBndr = toIfaceTvBndrX emptyVarSet toIfaceTvBndrX :: VarSet -> TyVar -> IfaceTvBndr -toIfaceTvBndrX fr tyvar = ( occNameFS (getOccName tyvar) +toIfaceTvBndrX fr tyvar = ( LexicalFastString (occNameFS (getOccName tyvar)) , toIfaceTypeX fr (tyVarKind tyvar) ) @@ -133,7 +133,7 @@ toIfaceIdBndr = toIfaceIdBndrX emptyVarSet toIfaceIdBndrX :: VarSet -> CoVar -> IfaceIdBndr toIfaceIdBndrX fr covar = ( toIfaceType (idMult covar) - , occNameFS (getOccName covar) + , LexicalFastString (occNameFS (getOccName covar)) , toIfaceTypeX fr (varType covar) ) @@ -218,11 +218,11 @@ toIfaceTypeX fr (TyConApp tc tys) arity = tyConArity tc n_tys = length tys -toIfaceTyVar :: TyVar -> FastString -toIfaceTyVar = occNameFS . getOccName +toIfaceTyVar :: TyVar -> LexicalFastString +toIfaceTyVar = LexicalFastString . occNameFS . getOccName -toIfaceCoVar :: CoVar -> FastString -toIfaceCoVar = occNameFS . getOccName +toIfaceCoVar :: CoVar -> LexicalFastString +toIfaceCoVar = LexicalFastString . occNameFS . getOccName ---------------- toIfaceTyCon :: TyCon -> IfaceTyCon @@ -264,7 +264,7 @@ toIfaceTyCon_name n = IfaceTyCon n info toIfaceTyLit :: TyLit -> IfaceTyLit toIfaceTyLit (NumTyLit x) = IfaceNumTyLit x -toIfaceTyLit (StrTyLit x) = IfaceStrTyLit x +toIfaceTyLit (StrTyLit x) = IfaceStrTyLit (LexicalFastString x) toIfaceTyLit (CharTyLit x) = IfaceCharTyLit x ---------------- @@ -296,7 +296,7 @@ toIfaceCoercionX fr co go (InstCo co arg) = IfaceInstCo (go co) (go arg) go (KindCo c) = IfaceKindCo (go c) go (SubCo co) = IfaceSubCo (go co) - go (AxiomRuleCo co cs) = IfaceAxiomRuleCo (coaxrName co) (map go cs) + go (AxiomRuleCo co cs) = IfaceAxiomRuleCo (LexicalFastString (coaxrName co)) (map go cs) go (AxiomInstCo c i cs) = IfaceAxiomInstCo (coAxiomName c) i (map go cs) go (UnivCo p r t1 t2) = IfaceUnivCo (go_prov p) r (toIfaceTypeX fr t1) @@ -433,7 +433,7 @@ toIfaceSrcBang :: HsSrcBang -> IfaceSrcBang toIfaceSrcBang (HsSrcBang _ unpk bang) = IfSrcBang unpk bang toIfaceLetBndr :: Id -> IfaceLetBndr -toIfaceLetBndr id = IfLetBndr (occNameFS (getOccName id)) +toIfaceLetBndr id = IfLetBndr (LexicalFastString (occNameFS (getOccName id))) (toIfaceType (idType id)) (toIfaceIdInfo (idInfo id)) (idJoinPointHood id) @@ -444,7 +444,7 @@ toIfaceTopBndr :: Id -> IfaceTopBndrInfo toIfaceTopBndr id = if isExternalName name then IfGblTopBndr name - else IfLclTopBndr (occNameFS (getOccName id)) (toIfaceType (idType id)) + else IfLclTopBndr (LexicalFastString (occNameFS (getOccName id))) (toIfaceType (idType id)) (toIfaceIdInfo (idInfo id)) (toIfaceIdDetails (idDetails id)) where name = getName id @@ -555,7 +555,7 @@ toIfaceExpr (Lam x b) = IfaceLam (toIfaceBndr x, toIfaceOneShot x) (toIfac toIfaceExpr (App f a) = toIfaceApp f [a] toIfaceExpr (Case s x ty as) | null as = IfaceECase (toIfaceExpr s) (toIfaceType ty) - | otherwise = IfaceCase (toIfaceExpr s) (getOccFS x) (map toIfaceAlt as) + | otherwise = IfaceCase (toIfaceExpr s) (LexicalFastString (getOccFS x)) (map toIfaceAlt as) toIfaceExpr (Let b e) = IfaceLet (toIfaceBind b) (toIfaceExpr e) toIfaceExpr (Cast e co) = IfaceCast (toIfaceExpr e) (toIfaceCoercion co) toIfaceExpr (Tick t e) = IfaceTick (toIfaceTickish t) (toIfaceExpr e) @@ -610,7 +610,7 @@ toIfaceTopBind b = --------------------- toIfaceAlt :: CoreAlt -> IfaceAlt -toIfaceAlt (Alt c bs r) = IfaceAlt (toIfaceCon c) (map getOccFS bs) (toIfaceExpr r) +toIfaceAlt (Alt c bs r) = IfaceAlt (toIfaceCon c) (map (LexicalFastString . getOccFS) bs) (toIfaceExpr r) --------------------- toIfaceCon :: AltCon -> IfaceConAlt @@ -655,7 +655,7 @@ toIfaceVar v -- Foreign calls have special syntax | isExternalName name = IfaceExt name - | otherwise = IfaceLcl (occNameFS $ nameOccName name) + | otherwise = IfaceLcl (LexicalFastString (occNameFS $ nameOccName name)) where name = idName v ty = idType v ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -283,13 +283,16 @@ instance Ord NonDetFastString where -- `lexicalCompareFS` (i.e. which compares FastStrings on their String -- representation). Hence it is deterministic from one run to the other. newtype LexicalFastString - = LexicalFastString FastString + = LexicalFastString { getLexicalFastString :: FastString } deriving newtype (Eq, Show) deriving stock Data instance Ord LexicalFastString where compare (LexicalFastString fs1) (LexicalFastString fs2) = lexicalCompareFS fs1 fs2 +instance NFData LexicalFastString where + rnf (LexicalFastString f) = rnf f + -- ----------------------------------------------------------------------------- -- Construction ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -1,10 +1,10 @@ -{-# LANGUAGE BinaryLiterals, ScopedTypeVariables #-} +{-# LANGUAGE BinaryLiterals, ScopedTypeVariables, RecursiveDo #-} -- -- (c) The University of Glasgow 2002-2006 -- -{-# OPTIONS_GHC -O2 #-} +{-# OPTIONS_GHC -O0 -ddump-simpl -ddump-to-file #-} -- We always optimise this, otherwise performance of a non-optimised -- compiler is severely affected @@ -180,7 +180,7 @@ getWithUserData name_cache bh = do -- (getDictFastString dict) data ReadIfaceTable out = ReadIfaceTable - { getTable :: HasCallStack => BinHandle -> IO out + { getTable :: HasCallStack => IORef BinHandle -> BinHandle -> IO out } data WriteIfaceTable = WriteIfaceTable @@ -191,27 +191,38 @@ getTables' :: HasCallStack => NameCache -> BinHandle -> IO BinHandle getTables' name_cache bh = do fsCache <- initReadFsCachedBinary nameCache <- initReadNameCachedBinary name_cache - ifaceCache <- initReadIfaceTyConTable +-- ifaceCache <- initReadIfaceTyConTable + ifaceTypeCache <- initReadIfaceTypeTable + bhRef <- newIORef (error "used too soon") -- 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 <- Binary.forwardGet bh (getTable fsCache bh) + dict <- Binary.forwardGet bh (getTable fsCache bhRef bh) let fsDecoder = mkReader $ getDictFastString dict bh_fs = addDecoder (mkCache (Proxy @FastString) fsDecoder) bh - symtab <- Binary.forwardGet bh_fs (getTable nameCache bh_fs) + symtab <- Binary.forwardGet bh_fs (getTable nameCache bhRef bh_fs) let nameCache' = mkReader $ getSymtabName symtab bh_name = addDecoder (mkCache (Proxy :: Proxy Name) nameCache') bh_fs - ifaceSymTab <- Binary.forwardGet bh_fs (getTable ifaceCache bh_name) +-- ifaceSymTab <- Binary.forwardGet bh_fs (getTable ifaceCache bh_name) + +-- let ifaceDecoder = mkReader $ getGenericSymtab ifaceSymTab + +-- bh_name2 = addDecoder (mkCache (Proxy :: Proxy IfaceTyCon) ifaceDecoder) bh_name + + pprTraceM "getTables" empty + ifaceSymTab2 <- Binary.forwardGet bh_name (getTable ifaceTypeCache bhRef bh_name) + let ifaceDecoder2 = mkReader $ getGenericSymtab ifaceSymTab2 + let bh_type = addDecoder (mkCache (Proxy :: Proxy IfaceType) (pprTrace "forced" (text "f") ifaceDecoder2)) bh_name + writeIORef bhRef bh_type + return bh_type - let ifaceDecoder = mkReader $ getGenericSymtab ifaceSymTab - pure $ addDecoder (mkCache (Proxy :: Proxy IfaceTyCon) ifaceDecoder) bh_name -- | Write an interface file writeBinIface :: HasCallStack => Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () @@ -269,7 +280,7 @@ initReadFsCachedBinary :: (HasCallStack) => IO (ReadIfaceTable (SymbolTable Fast initReadFsCachedBinary = do return $ ReadIfaceTable - { getTable = getDictionary + { getTable = \_ -> getDictionary } initWriteFsTable :: (HasCallStack) => IO (WriteIfaceTable, CachedBinary FastString) @@ -298,7 +309,7 @@ initReadNameCachedBinary :: (HasCallStack) => NameCache -> IO (ReadIfaceTable (S initReadNameCachedBinary cache = do return $ ReadIfaceTable - { getTable = \bh -> getSymbolTable bh cache + { getTable = \_ bh -> getSymbolTable bh cache } initWriteNameTable :: (HasCallStack) => IO (WriteIfaceTable, CachedBinary Name) @@ -331,6 +342,14 @@ initReadIfaceTyConTable = do { getTable = getGenericSymbolTable getIfaceTyCon } +initReadIfaceTypeTable :: HasCallStack => IO (ReadIfaceTable (SymbolTable IfaceType)) +initReadIfaceTypeTable = do + pure $ + ReadIfaceTable + { getTable = getGenericSymbolTable getIfaceType + } + + initWriteIfaceTyConTable :: HasCallStack => IO (WriteIfaceTable, CachedBinary IfaceTyCon) initWriteIfaceTyConTable = do sym_tab <- initGenericSymbolTable @@ -341,6 +360,16 @@ initWriteIfaceTyConTable = do , mkWriter $ putGenericSymTab sym_tab ) +initWriteIfaceType :: HasCallStack => IO (WriteIfaceTable, CachedBinary IfaceType) +initWriteIfaceType = do + sym_tab <- initGenericSymbolTable + pure + ( WriteIfaceTable + { putTable = putGenericSymbolTable sym_tab putIfaceType + } + , mkWriter $ putGenericSymTab sym_tab + ) + -- | Write name/symbol tables -- -- 1. setup the given BinHandle with Name/FastString table handling @@ -392,20 +421,23 @@ putWithTables' :: HasCallStack => BinHandle -> (BinHandle -> IO b) -> IO (Int,In putWithTables' bh' put_payload = do (fsTbl, fsWriter) <- initWriteFsTable (nameTbl, nameWriter) <- initWriteNameTable - (ifaceTyConTbl, ifaceTyConWriter) <- initWriteIfaceTyConTable +-- (ifaceTyConTbl, ifaceTyConWriter) <- initWriteIfaceTyConTable + (ifaceTypeTbl, ifaceTypeWriter) <- initWriteIfaceType let userData = withMyUserData [ mkCache (Proxy @FastString) fsWriter , mkCache (Proxy @Name) nameWriter - , mkCache (Proxy @IfaceTyCon) ifaceTyConWriter + -- , mkCache (Proxy @IfaceTyCon) ifaceTyConWriter + , mkCache (Proxy @IfaceType) ifaceTypeWriter ] let bh = setUserData bh' userData (fs_count,(name_count,(_, r))) <- forwardPut bh (const (putTable fsTbl bh)) $ do forwardPut bh (const (putTable nameTbl bh)) $ do - forwardPut bh (const (putTable ifaceTyConTbl bh)) $ do - put_payload bh + -- forwardPut bh (const (putTable ifaceTyConTbl bh)) $ do + forwardPut bh (const (putTable ifaceTypeTbl bh)) $ do + put_payload bh return (name_count, fs_count, r) ===================================== compiler/GHC/Iface/Decl.hs ===================================== @@ -147,7 +147,7 @@ tyConToIfaceDecl env tycon | Just fam_flav <- famTyConFlav_maybe tycon = ( tc_env1 , IfaceFamily { ifName = getName tycon, - ifResVar = if_res_var, + ifResVar = LexicalFastString <$> if_res_var, ifFamFlav = to_if_fam_flav fam_flav, ifBinders = if_binders, ifResKind = if_res_kind, @@ -256,7 +256,7 @@ tyConToIfaceDecl env tycon (con_env2, ex_tvs') = tidyVarBndrs con_env1 ex_tvs user_bndrs' = map (tidyUserForAllTyBinder con_env2) user_bndrs - to_eq_spec (tv,ty) = (tidyTyVar con_env2 tv, tidyToIfaceType con_env2 ty) + to_eq_spec (tv,ty) = ((tidyTyVar con_env2 tv), tidyToIfaceType con_env2 ty) -- By this point, we have tidied every universal and existential -- tyvar. Because of the dcUserForAllTyBinders invariant @@ -288,7 +288,7 @@ classToIfaceDecl env clas ifClassCtxt = tidyToIfaceContext env1 sc_theta, ifATs = map toIfaceAT clas_ats, ifSigs = map toIfaceClassOp op_stuff, - ifMinDef = toIfaceBooleanFormula $ fmap getOccFS (classMinimalDef clas) + ifMinDef = toIfaceBooleanFormula $ fmap (LexicalFastString . getOccFS) (classMinimalDef clas) } (env1, tc_binders) = tidyTyConBinders env (tyConBinders tycon) @@ -334,7 +334,7 @@ tidyTyConBinder env@(_, subst) tvb@(Bndr tv vis) tidyTyConBinders :: TidyEnv -> [TyConBinder] -> (TidyEnv, [TyConBinder]) tidyTyConBinders = mapAccumL tidyTyConBinder -tidyTyVar :: TidyEnv -> TyVar -> FastString +tidyTyVar :: TidyEnv -> TyVar -> LexicalFastString tidyTyVar (_, subst) tv = toIfaceTyVar (lookupVarEnv subst tv `orElse` tv) toIfaceBooleanFormula :: BooleanFormula IfLclName -> IfaceBooleanFormula ===================================== compiler/GHC/Iface/Env.hs ===================================== @@ -190,10 +190,10 @@ setNameModule (Just m) n = ************************************************************************ -} -tcIfaceLclId :: FastString -> IfL Id +tcIfaceLclId :: LexicalFastString -> IfL Id tcIfaceLclId occ = do { lcl <- getLclEnv - ; case lookupFsEnv (if_id_env lcl) occ of + ; case lookupFsEnv (if_id_env lcl) (getLexicalFastString occ) of Just ty_var -> return ty_var Nothing -> failIfM $ vcat @@ -209,10 +209,10 @@ extendIfaceIdEnv ids in env { if_id_env = id_env' } -tcIfaceTyVar :: FastString -> IfL TyVar +tcIfaceTyVar :: LexicalFastString -> IfL TyVar tcIfaceTyVar occ = do { lcl <- getLclEnv - ; case lookupFsEnv (if_tv_env lcl) occ of + ; case lookupFsEnv (if_tv_env lcl) (getLexicalFastString occ) of Just ty_var -> return ty_var Nothing -> failIfM (text "Iface type variable out of scope: " <+> ppr occ) } @@ -220,15 +220,15 @@ tcIfaceTyVar occ lookupIfaceTyVar :: IfaceTvBndr -> IfL (Maybe TyVar) lookupIfaceTyVar (occ, _) = do { lcl <- getLclEnv - ; return (lookupFsEnv (if_tv_env lcl) occ) } + ; return (lookupFsEnv (if_tv_env lcl) (getLexicalFastString occ)) } lookupIfaceVar :: IfaceBndr -> IfL (Maybe TyCoVar) lookupIfaceVar (IfaceIdBndr (_, occ, _)) = do { lcl <- getLclEnv - ; return (lookupFsEnv (if_id_env lcl) occ) } + ; return (lookupFsEnv (if_id_env lcl) (getLexicalFastString occ)) } lookupIfaceVar (IfaceTvBndr (occ, _)) = do { lcl <- getLclEnv - ; return (lookupFsEnv (if_tv_env lcl) occ) } + ; return (lookupFsEnv (if_tv_env lcl) (getLexicalFastString occ)) } extendIfaceTyVarEnv :: [TyVar] -> IfL a -> IfL a extendIfaceTyVarEnv tyvars ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -43,7 +43,7 @@ import System.Directory ( createDirectoryIfMissing ) import System.FilePath ( takeDirectory ) import GHC.Iface.Ext.Types -import GHC.Iface.Syntax (putIfaceTyCon, IfaceTyCon, getIfaceTyCon) +import GHC.Iface.Syntax (putIfaceTyCon, IfaceTyCon, getIfaceTyCon, getIfaceType, IfaceType, putIfaceType ) import Data.Proxy data HieSymbolTable = HieSymbolTable @@ -107,7 +107,8 @@ writeHieFile hie_file_path hiefile = do hie_dict_map = dict_map_ref } -- put the main thing - let bh = addDecoder (mkCache (Proxy @IfaceTyCon) (mkWriter putIfaceTyCon)) $ + let bh = -- addDecoder (mkCache (Proxy @IfaceTyCon) (mkWriter putIfaceTyCon)) $ + addDecoder (mkCache (Proxy @IfaceType) (mkWriter putIfaceType)) $ setUserData bh0 $ newWriteState (putName hie_symtab) (putName hie_symtab) (putFastString hie_dict) @@ -224,7 +225,8 @@ readHieFileContents bh0 name_cache = do let bh1 = setUserData bh0 $ newReadState (error "getSymtabName") (getDictFastString dict) symtab <- get_symbol_table bh1 - let bh1' = addDecoder (mkCache (Proxy @IfaceTyCon) (mkReader getIfaceTyCon)) + let bh1' = -- addDecoder (mkCache (Proxy @IfaceTyCon) (mkReader getIfaceTyCon)) + addDecoder (mkCache (Proxy @IfaceType) (mkReader getIfaceType)) $ setUserData bh1 $ newReadState (getSymTabName symtab) (getDictFastString dict) ===================================== compiler/GHC/Iface/Ext/Utils.hs ===================================== @@ -11,7 +11,7 @@ import GHC.Prelude import GHC.Core.Map.Type import GHC.Driver.DynFlags ( DynFlags ) import GHC.Driver.Ppr -import GHC.Data.FastString ( FastString, mkFastString ) +import GHC.Data.FastString ( FastString, mkFastString , LexicalFastString(..)) import GHC.Iface.Type import GHC.Types.Name hiding (varName) import GHC.Types.Name.Set @@ -156,15 +156,15 @@ getEvidenceTree refmap var = go emptyNameSet var hieTypeToIface :: HieTypeFix -> IfaceType hieTypeToIface = foldType go where - go (HTyVarTy n) = IfaceTyVar $ occNameFS $ getOccName n + go (HTyVarTy n) = IfaceTyVar $ (LexicalFastString (occNameFS $ getOccName n)) go (HAppTy a b) = IfaceAppTy a (hieToIfaceArgs b) go (HLitTy l) = IfaceLitTy l - go (HForAllTy ((n,k),af) t) = let b = (occNameFS $ getOccName n, k) + go (HForAllTy ((n,k),af) t) = let b = (LexicalFastString (occNameFS $ getOccName n), k) in IfaceForAllTy (Bndr (IfaceTvBndr b) af) t go (HFunTy w a b) = IfaceFunTy visArgTypeLike w a b go (HQualTy pred b) = IfaceFunTy invisArgTypeLike many_ty pred b go (HCastTy a) = a - go HCoercionTy = IfaceTyVar "" + go HCoercionTy = IfaceTyVar (LexicalFastString "") go (HTyConApp a xs) = IfaceTyConApp a (hieToIfaceArgs xs) -- This isn't fully faithful - we can't produce the 'Inferred' case ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -1216,8 +1216,8 @@ addFingerprints hsc_env iface0 getOcc (IfLclTopBndr fs _ _ details) = case details of IfRecSelId { ifRecSelFirstCon = first_con } - -> mkRecFieldOccFS (getOccFS first_con) fs - _ -> mkVarOccFS fs + -> mkRecFieldOccFS (getOccFS first_con) (getLexicalFastString fs) + _ -> mkVarOccFS (getLexicalFastString fs) binding_key (IfaceNonRec b _) = IfaceNonRec (getOcc b) () binding_key (IfaceRec bs) = IfaceRec (map (\(b, _) -> (getOcc b, ())) bs) ===================================== compiler/GHC/Iface/Recomp/Binary.hs ===================================== @@ -36,8 +36,10 @@ computeFingerprint put_nonbinding_name a = do put_ bh a fingerprintBinMem bh where - set_user_data bh = addDecoder (mkCache (Proxy @IfaceTyCon) $ mkWriter putIfaceTyCon) - $ setUserData bh $ newWriteState put_nonbinding_name putNameLiterally putFS + set_user_data bh = + addDecoder (mkCache (Proxy @IfaceType) $ mkWriter putIfaceType) $ + -- addDecoder (mkCache (Proxy @IfaceTyCon) $ mkWriter putIfaceTyCon) $ + setUserData bh $ newWriteState put_nonbinding_name putNameLiterally putFS -- | Used when we want to fingerprint a structure without depending on the -- fingerprints of external Names that it refers to. ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -632,6 +632,7 @@ data IfaceExpr | IfaceFCall ForeignCall IfaceType | IfaceTick IfaceTickish IfaceExpr -- from Tick tickish E + data IfaceTickish = IfaceHpcTick Module Int -- from HpcTick x | IfaceSCC CostCentre Bool Bool -- from ProfNote @@ -1026,7 +1027,7 @@ pprIfaceDecl ss (IfaceClass { ifName = clas pprMinDef minDef = ppUnless (isTrue minDef) $ -- hide empty definitions text "{-# MINIMAL" <+> pprBooleanFormula - (\_ def -> cparen (isLexSym def) (ppr def)) 0 minDef <+> + (\_ def -> cparen (isLexSym def) (ppr def)) 0 (fmap getLexicalFastString minDef) <+> text "#-}" -- See Note [Suppressing binder signatures] in GHC.Iface.Type ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Iface.Type ( ifTyConBinderVar, ifTyConBinderName, -- Binary utilities - putIfaceTyCon, getIfaceTyCon, + putIfaceTyCon, getIfaceTyCon, putIfaceType, getIfaceType, -- Equality testing isIfaceLiftedTypeKind, @@ -96,6 +96,7 @@ import qualified Data.Semigroup as Semi import Control.DeepSeq import Data.Proxy import Control.Monad ((<$!>)) +import Control.Arrow (first) {- ************************************************************************ @@ -105,7 +106,7 @@ import Control.Monad ((<$!>)) ************************************************************************ -} -type IfLclName = FastString -- A local name in iface syntax +type IfLclName = LexicalFastString -- A local name in iface syntax type IfExtName = Name -- An External or WiredIn Name can appear in Iface syntax -- (However Internal or System Names never should) @@ -113,6 +114,8 @@ type IfExtName = Name -- An External or WiredIn Name can appear in Iface synta data IfaceBndr -- Local (non-top-level) binders = IfaceIdBndr {-# UNPACK #-} !IfaceIdBndr | IfaceTvBndr {-# UNPACK #-} !IfaceTvBndr + deriving (Eq, Ord) + type IfaceIdBndr = (IfaceType, IfLclName, IfaceType) type IfaceTvBndr = (IfLclName, IfaceKind) @@ -181,6 +184,7 @@ data IfaceType -- In an experiment, removing IfaceTupleTy resulted in a 0.75% regression -- in interface file size (in GHC's boot libraries). -- See !3987. + deriving (Eq, Ord) type IfaceMult = IfaceType @@ -189,9 +193,9 @@ type IfaceContext = [IfacePredType] data IfaceTyLit = IfaceNumTyLit Integer - | IfaceStrTyLit FastString + | IfaceStrTyLit LexicalFastString | IfaceCharTyLit Char - deriving (Eq) + deriving (Eq, Ord) type IfaceTyConBinder = VarBndr IfaceBndr TyConBndrVis type IfaceForAllBndr = VarBndr IfaceBndr ForAllTyFlag @@ -233,6 +237,7 @@ data IfaceAppArgs -- arguments in @{...}. IfaceAppArgs -- The rest of the arguments + deriving (Eq, Ord) instance Semi.Semigroup IfaceAppArgs where IA_Nil <> xs = xs @@ -394,7 +399,7 @@ adding no inline top-level constants for the two most common cases. data IfaceMCoercion = IfaceMRefl - | IfaceMCo IfaceCoercion + | IfaceMCo IfaceCoercion deriving (Eq, Ord) data IfaceCoercion = IfaceReflCo IfaceType @@ -419,11 +424,13 @@ data IfaceCoercion | IfaceSubCo IfaceCoercion | IfaceFreeCoVar CoVar -- See Note [Free tyvars in IfaceType] | IfaceHoleCo CoVar -- ^ See Note [Holes in IfaceCoercion] + deriving (Eq, Ord) data IfaceUnivCoProv = IfacePhantomProv IfaceCoercion | IfaceProofIrrelProv IfaceCoercion | IfacePluginProv String + deriving (Eq, Ord) {- Note [Holes in IfaceCoercion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -595,11 +602,11 @@ type IfaceTySubst = FastStringEnv IfaceType -- Note [Substitution on IfaceType] mkIfaceTySubst :: [(IfLclName,IfaceType)] -> IfaceTySubst -- See Note [Substitution on IfaceType] -mkIfaceTySubst eq_spec = mkFsEnv eq_spec +mkIfaceTySubst eq_spec = mkFsEnv (map (first getLexicalFastString) eq_spec) inDomIfaceTySubst :: IfaceTySubst -> IfaceTvBndr -> Bool -- See Note [Substitution on IfaceType] -inDomIfaceTySubst subst (fs, _) = isJust (lookupFsEnv subst fs) +inDomIfaceTySubst subst (fs, _) = isJust (lookupFsEnv subst (getLexicalFastString fs)) substIfaceType :: IfaceTySubst -> IfaceType -> IfaceType -- See Note [Substitution on IfaceType] @@ -655,7 +662,7 @@ substIfaceAppArgs env args substIfaceTyVar :: IfaceTySubst -> IfLclName -> IfaceType substIfaceTyVar env tv - | Just ty <- lookupFsEnv env tv = ty + | Just ty <- lookupFsEnv env (getLexicalFastString tv) = ty | otherwise = IfaceTyVar tv @@ -701,6 +708,12 @@ ifaceVisAppArgsLength = go 0 | isVisibleForAllTyFlag argf = go (n+1) rest | otherwise = go n rest +ifaceAppArgsLength :: IfaceAppArgs -> Int +ifaceAppArgsLength = go 0 + where + go !n IA_Nil = n + go !n (IA_Arg _ _ ts) = go (n + 1) ts + {- Note [Suppressing invisible arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1158,7 +1171,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind - = let subs' = extendFsEnv subs var substituted_ty + = let subs' = extendFsEnv subs (getLexicalFastString var) substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, -- and recurse, discarding the forall in go subs' True ty @@ -1166,7 +1179,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty go subs rank1 (IfaceForAllTy bndr ty) = IfaceForAllTy (go_ifacebndr subs bndr) (go subs rank1 ty) - go subs _ ty@(IfaceTyVar tv) = case lookupFsEnv subs tv of + go subs _ ty@(IfaceTyVar tv) = case lookupFsEnv subs (getLexicalFastString tv) of Just s -> s Nothing -> ty @@ -1594,7 +1607,7 @@ pprTyTcApp ctxt_prec tc tys = , IA_Arg (IfaceLitTy (IfaceStrTyLit n)) Required (IA_Arg ty Required IA_Nil) <- tys -> maybeParen ctxt_prec funPrec - $ char '?' <> ftext n <> text "::" <> ppr_ty topPrec ty + $ char '?' <> ftext (getLexicalFastString n) <> text "::" <> ppr_ty topPrec ty | IfaceTupleTyCon arity sort <- ifaceTyConSort info , not debug @@ -1976,11 +1989,14 @@ instance Outputable IfaceCoercion where ppr = pprIfaceCoercion instance Binary IfaceTyCon where - putNoStack_ bh tyCon = case findUserDataCache Proxy bh of - tbl -> putEntry tbl bh tyCon + putNoStack_ bh tyCon = putIfaceTyCon bh tyCon - get bh = case findUserDataCache Proxy bh of - tbl -> getEntry tbl bh + --case findUserDataCache Proxy bh of + -- tbl -> putEntry tbl bh tyCon + + get bh = getIfaceTyCon bh + --case findUserDataCache Proxy bh of + -- tbl -> getEntry tbl bh putIfaceTyCon :: HasCallStack => BinHandle -> IfaceTyCon -> IO () putIfaceTyCon bh (IfaceTyCon n i) = put_ bh n >> put_ bh i @@ -2030,21 +2046,27 @@ instance Binary IfaceTyLit where _ -> panic ("get IfaceTyLit " ++ show tag) instance Binary IfaceAppArgs where - putNoStack_ bh tk = - case tk of - IA_Arg t a ts -> putByte bh 0 >> put_ bh t >> put_ bh a >> put_ bh ts - IA_Nil -> putByte bh 1 + putNoStack_ bh tk = do + -- Int is variable length encoded so only + -- one byte for small lists. + put_ bh (ifaceAppArgsLength tk) + go tk + where + go IA_Nil = pure () + go (IA_Arg a b t) = do + put_ bh a + put_ bh b + go t - get bh = - do c <- getByte bh - case c of - 0 -> do - t <- get bh - a <- get bh - ts <- get bh - return $! IA_Arg t a ts - 1 -> return IA_Nil - _ -> panic ("get IfaceAppArgs " ++ show c) + get bh = do + n <- get bh :: IO Int + go n + where + go 0 = return IA_Nil + go c = do + a <- get bh + b <- get bh + IA_Arg a b <$> go (c - 1) ------------------- @@ -2099,38 +2121,46 @@ ppr_parend_preds :: [IfacePredType] -> SDoc ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds))) instance Binary IfaceType where - putNoStack_ _ (IfaceFreeTyVar tv) - = pprPanic "Can't serialise IfaceFreeTyVar" (ppr tv) + putNoStack_ bh tyCon = case findUserDataCache Proxy bh of + tbl -> putEntry tbl bh tyCon - putNoStack_ bh (IfaceForAllTy aa ab) = do - putByte bh 0 - put_ bh aa - put_ bh ab - putNoStack_ bh (IfaceTyVar ad) = do - putByte bh 1 - put_ bh ad - putNoStack_ bh (IfaceAppTy ae af) = do - putByte bh 2 - put_ bh ae - put_ bh af - putNoStack_ bh (IfaceFunTy af aw ag ah) = do - putByte bh 3 - put_ bh af - put_ bh aw - put_ bh ag - put_ bh ah - putNoStack_ bh (IfaceTyConApp tc tys) - = do { putByte bh 5; put_ bh tc; put_ bh tys } - putNoStack_ bh (IfaceCastTy a b) - = do { putByte bh 6; put_ bh a; put_ bh b } - putNoStack_ bh (IfaceCoercionTy a) - = do { putByte bh 7; put_ bh a } - putNoStack_ bh (IfaceTupleTy s i tys) - = do { putByte bh 8; put_ bh s; put_ bh i; put_ bh tys } - putNoStack_ bh (IfaceLitTy n) - = do { putByte bh 9; put_ bh n } + get bh = case findUserDataCache Proxy bh of + tbl -> getEntry tbl bh - get bh = do + +putIfaceType _ (IfaceFreeTyVar tv) + = pprPanic "Can't serialise IfaceFreeTyVar" (ppr tv) + +putIfaceType bh (IfaceForAllTy aa ab) = do + putByte bh 0 + put_ bh aa + put_ bh ab +putIfaceType bh (IfaceTyVar ad) = do + putByte bh 1 + put_ bh ad +putIfaceType bh (IfaceAppTy ae af) = do + putByte bh 2 + put_ bh ae + put_ bh af +putIfaceType bh (IfaceFunTy af aw ag ah) = do + putByte bh 3 + put_ bh af + put_ bh aw + put_ bh ag + put_ bh ah +putIfaceType bh (IfaceTyConApp tc tys) + = do { putByte bh 5; put_ bh tc; put_ bh tys } +putIfaceType bh (IfaceCastTy a b) + = do { putByte bh 6; put_ bh a; put_ bh b } +putIfaceType bh (IfaceCoercionTy a) + = do { putByte bh 7; put_ bh a } +putIfaceType bh (IfaceTupleTy s i tys) + = do { putByte bh 8; put_ bh s; put_ bh i; put_ bh tys } +putIfaceType bh (IfaceLitTy n) + = do { putByte bh 9; put_ bh n } + +getIfaceType :: HasCallStack => BinHandle -> IO IfaceType +getIfaceType bh = do h <- getByte bh case h of 0 -> do aa <- get bh ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -733,7 +733,7 @@ tc_iface_decl parent _ (IfaceFamily {ifName = tc_name, { res_kind' <- tcIfaceType res_kind -- Note [Synonym kind loop] ; rhs <- forkM (mk_doc tc_name) $ tc_fam_flav tc_name fam_flav - ; res_name <- traverse (newIfaceName . mkTyVarOccFS) res + ; res_name <- traverse (newIfaceName . mkTyVarOccFS . getLexicalFastString) res ; let tycon = mkFamilyTyCon tc_name binders' res_kind' res_name rhs parent inj ; return (ATyCon tycon) } where @@ -782,7 +782,7 @@ tc_iface_decl _parent ignore_prags ; fds <- mapM tc_fd rdr_fds ; traceIf (text "tc-iface-class3" <+> ppr tc_name) ; let mindef_occ = fromIfaceBooleanFormula if_mindef - ; mindef <- traverse (lookupIfaceTop . mkVarOccFS) mindef_occ + ; mindef <- traverse (lookupIfaceTop . mkVarOccFS . getLexicalFastString) mindef_occ ; cls <- fixM $ \ cls -> do { ats <- mapM (tc_at cls) rdr_ats ; traceIf (text "tc-iface-class4" <+> ppr tc_name) @@ -936,8 +936,8 @@ mk_top_id (IfLclTopBndr raw_name iface_type info details) = do ; let occ = case details' of RecSelId { sel_tycon = parent } -> let con_fs = getOccFS $ recSelFirstConName parent - in mkRecFieldOccFS con_fs raw_name - _ -> mkVarOccFS raw_name + in mkRecFieldOccFS con_fs (getLexicalFastString raw_name) + _ -> mkVarOccFS (getLexicalFastString raw_name) ; name <- newIfaceName occ } info' <- tcIdInfo False TopLevel name ty info let new_id = mkGlobalId details' name ty info' @@ -1441,7 +1441,7 @@ tcIfaceCtxt sts = mapM tcIfaceType sts ----------------------------------------- tcIfaceTyLit :: IfaceTyLit -> IfL TyLit tcIfaceTyLit (IfaceNumTyLit n) = return (NumTyLit n) -tcIfaceTyLit (IfaceStrTyLit n) = return (StrTyLit n) +tcIfaceTyLit (IfaceStrTyLit n) = return (StrTyLit (getLexicalFastString n)) tcIfaceTyLit (IfaceCharTyLit n) = return (CharTyLit n) {- @@ -1485,7 +1485,7 @@ tcIfaceCo = go go (IfaceFreeCoVar c) = pprPanic "tcIfaceCo:IfaceFreeCoVar" (ppr c) go (IfaceHoleCo c) = pprPanic "tcIfaceCo:IfaceHoleCo" (ppr c) - go_var :: FastString -> IfL CoVar + go_var :: LexicalFastString -> IfL CoVar go_var = tcIfaceLclId tcIfaceUnivCoProv :: IfaceUnivCoProv -> IfL UnivCoProvenance @@ -1561,7 +1561,7 @@ tcIfaceExpr (IfaceECase scrut ty) tcIfaceExpr (IfaceCase scrut case_bndr alts) = do scrut' <- tcIfaceExpr scrut - case_bndr_name <- newIfaceName (mkVarOccFS case_bndr) + case_bndr_name <- newIfaceName (mkVarOccFS (getLexicalFastString case_bndr)) let scrut_ty = exprType scrut' case_mult = ManyTy @@ -1580,7 +1580,7 @@ tcIfaceExpr (IfaceCase scrut case_bndr alts) = do return (Case scrut' case_bndr' (coreAltsType alts') alts') tcIfaceExpr (IfaceLet (IfaceNonRec (IfLetBndr fs ty info ji) rhs) body) - = do { name <- newIfaceName (mkVarOccFS fs) + = do { name <- newIfaceName (mkVarOccFS (getLexicalFastString fs)) ; ty' <- tcIfaceType ty ; id_info <- tcIdInfo False {- Don't ignore prags; we are inside one! -} NotTopLevel name ty' info @@ -1598,7 +1598,7 @@ tcIfaceExpr (IfaceLet (IfaceRec pairs) body) ; return (Let (Rec pairs') body') } } where tc_rec_bndr (IfLetBndr fs ty _ ji) - = do { name <- newIfaceName (mkVarOccFS fs) + = do { name <- newIfaceName (mkVarOccFS (getLexicalFastString fs)) ; ty' <- tcIfaceType ty ; return (mkLocalId name ManyTy ty' `asJoinId_maybe` ji) } tc_pair (IfLetBndr _ _ info _, rhs) id @@ -1655,12 +1655,12 @@ tcIfaceAlt scrut mult (tycon, inst_tys) (IfaceAlt (IfaceDataAlt data_occ) arg_st (failIfM (ppr scrut $$ ppr con $$ ppr tycon $$ ppr (tyConDataCons tycon))) ; tcIfaceDataAlt mult con inst_tys arg_strs rhs } -tcIfaceDataAlt :: Mult -> DataCon -> [Type] -> [FastString] -> IfaceExpr +tcIfaceDataAlt :: Mult -> DataCon -> [Type] -> [IfLclName] -> IfaceExpr -> IfL CoreAlt tcIfaceDataAlt mult con inst_tys arg_strs rhs = do { uniqs <- getUniquesM ; let (ex_tvs, arg_ids) - = dataConRepFSInstPat arg_strs uniqs mult con inst_tys + = dataConRepFSInstPat (map getLexicalFastString arg_strs) uniqs mult con inst_tys ; rhs' <- extendIfaceEnvs ex_tvs $ extendIfaceIdEnv arg_ids $ @@ -2031,7 +2031,7 @@ tcIfaceCoAxiomRule :: IfLclName -> IfL CoAxiomRule -- - axioms for type-level literals (Nat and Symbol), -- enumerated in typeNatCoAxiomRules tcIfaceCoAxiomRule n - | Just ax <- lookupUFM typeNatCoAxiomRules n + | Just ax <- lookupUFM typeNatCoAxiomRules (getLexicalFastString n) = return ax | otherwise = pprPanic "tcIfaceCoAxiomRule" (ppr n) @@ -2075,7 +2075,7 @@ tcIfaceImplicit n = do bindIfaceId :: IfaceIdBndr -> (Id -> IfL a) -> IfL a bindIfaceId (w, fs, ty) thing_inside - = do { name <- newIfaceName (mkVarOccFS fs) + = do { name <- newIfaceName (mkVarOccFS (getLexicalFastString fs)) ; ty' <- tcIfaceType ty ; w' <- tcIfaceType w ; let id = mkLocalIdOrCoVar name w' ty' @@ -2118,7 +2118,7 @@ bindIfaceForAllBndr (Bndr (IfaceIdBndr tv) vis) thing_inside bindIfaceTyVar :: IfaceTvBndr -> (TyVar -> IfL a) -> IfL a bindIfaceTyVar (occ,kind) thing_inside - = do { name <- newIfaceName (mkTyVarOccFS occ) + = do { name <- newIfaceName (mkTyVarOccFS (getLexicalFastString occ)) ; tyvar <- mk_iface_tyvar name kind ; extendIfaceTyVarEnv [tyvar] (thing_inside tyvar) } ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -148,7 +148,7 @@ import qualified Data.Semigroup as Semi ********************************************************************* -} data LeftOrRight = CLeft | CRight - deriving( Eq, Data ) + deriving( Eq, Data, Ord ) pickLR :: LeftOrRight -> (a,a) -> a pickLR CLeft (l,_) = l ===================================== compiler/GHC/Types/Var.hs ===================================== @@ -720,7 +720,7 @@ Currently there are nine different uses of 'VarBndr': data VarBndr var argf = Bndr var argf -- See Note [The VarBndr type and its uses] - deriving( Data ) + deriving( Data, Eq, Ord) -- | Variable Binder -- ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -64,6 +64,8 @@ module GHC.Utils.Binary -- * Lazy Binary I/O lazyGet, lazyPut, + lazyGet', + lazyPut', lazyGetMaybe, lazyPutMaybe, @@ -100,7 +102,7 @@ import GHC.Utils.Fingerprint import GHC.Types.SrcLoc import GHC.Types.Unique import qualified GHC.Data.Strict as Strict -import GHC.Utils.Outputable( JoinPointHood(..) ) +import GHC.Utils.Outputable( JoinPointHood(..) , Outputable(..), text) import Control.DeepSeq import Foreign hiding (shiftL, shiftR, void) @@ -134,6 +136,9 @@ import qualified Data.Map.Strict as Map import Data.Tuple (swap) import Unsafe.Coerce (unsafeCoerce) import qualified Data.Map.Strict as Map +import Data.List (sortBy) +import Data.Ord (comparing) +import Data.Maybe type BinArray = ForeignPtr Word8 @@ -1079,25 +1084,33 @@ forwardGet bh get_A = do -- ----------------------------------------------------------------------------- -- Lazy reading/writing -lazyPut :: HasCallStack => Binary a => BinHandle -> a -> IO () -lazyPut bh a = do +lazyPut :: Binary a => BinHandle -> a -> IO () +lazyPut = lazyPut' putNoStack_ +lazyGet :: Binary a => BinHandle -> IO a +lazyGet = lazyGet' Nothing get + +lazyPut' :: HasCallStack => (BinHandle -> a -> IO ()) -> BinHandle -> a -> IO () +lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBin @(Bin ()) bh putNoStack_ bh pre_a -- save a slot for the ptr - putNoStack_ bh a -- dump the object + f bh a -- dump the object q <- tellBin @() bh -- q = ptr to after object putAt bh pre_a q -- fill in slot before a with ptr to q seekBin bh q -- finally carry on writing at q -lazyGet :: HasCallStack => Binary a => BinHandle -> IO a -lazyGet bh = do +lazyGet' :: HasCallStack => Maybe (IORef BinHandle) -> (BinHandle -> IO a) -> BinHandle -> IO a +lazyGet' mbh f bh = do p <- get @(Bin ()) bh -- a BinPtr p_a <- tellBin bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh off_r variable in the child thread, for thread -- safety. + inner_bh <- maybe (pure bh) readIORef mbh off_r <- newFastMutInt 0 - getAt bh { _off_r = off_r } p_a + let bh' = inner_bh { _off_r = off_r } + seekBin bh' p_a + f bh' seekBin bh p -- skip over the object for now return a @@ -1205,26 +1218,34 @@ initGenericSymbolTable = do putGenericSymbolTable :: forall a. GenericSymbolTable a -> (BinHandle -> a -> IO ()) -> BinHandle -> IO Int putGenericSymbolTable gen_sym_tab serialiser bh = do - table_count <- readFastMutInt symtab_next - symtab_map <- readIORef symtab_map - putGenericSymbolTable bh table_count symtab_map - pure table_count + putGenericSymbolTable bh where symtab_map = gen_symtab_map gen_sym_tab symtab_next = gen_symtab_next gen_sym_tab - putGenericSymbolTable :: HasCallStack => BinHandle -> Int -> Map.Map a Int -> IO () - putGenericSymbolTable bh name_count symtab = do - put_ bh name_count - let genElements = elems (array (0,name_count-1) (fmap swap $ Map.toList symtab)) - mapM_ (\n -> serialiser bh n) genElements - -getGenericSymbolTable :: forall a. (BinHandle -> IO a) -> BinHandle -> IO (SymbolTable a) -getGenericSymbolTable deserialiser bh = do - sz <- get bh :: IO Int + putGenericSymbolTable :: HasCallStack => BinHandle -> IO Int + putGenericSymbolTable bh = do + let loop bound = do + d <- readIORef symtab_map + table_count <- readFastMutInt symtab_next + let vs = sortBy (comparing fst) (map swap ([(a,b) | (a,b) <- Map.toList d, b >= bound])) + case vs of + [] -> return table_count + todo -> do + print (map fst todo) + mapM_ (\n -> lazyPut' serialiser bh n) (map snd vs) + loop table_count + snd <$> + (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + loop 0) + +getGenericSymbolTable :: forall a. (BinHandle -> IO a) -> IORef BinHandle -> BinHandle -> IO (SymbolTable a) +getGenericSymbolTable deserialiser bhRef bh = do + sz <- forwardGet bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do - f <- deserialiser bh + f <- lazyGet' (Just bhRef) deserialiser bh writeArray mut_arr i f + pprTraceM "gotten" (ppr sz) unsafeFreeze mut_arr putGenericSymTab :: (Ord a, Binary a) => GenericSymbolTable a -> BinHandle -> a -> IO () @@ -1250,6 +1271,9 @@ getGenericSymtab symtab bh = do data SomeCache = forall a . SomeCache (TypeRep, CachedBinary a) +instance Outputable SomeCache where + ppr (SomeCache (tr,_)) = text (show tr) + mkCache :: Typeable a => Proxy a -> CachedBinary a -> SomeCache mkCache p cb = SomeCache (typeRep p, cb) @@ -1282,7 +1306,7 @@ withMyUserData caches = noUserData findUserDataCache :: (HasCallStack, Typeable a) => Proxy a -> BinHandle -> CachedBinary a findUserDataCache query bh = go (ud_my_user_data $ getUserData bh) where - go [] = panic $ "Failed to find cache for key " ++ show query + go [] = panic $ "Failed to find cache for key " ++ show (typeRep query) go (SomeCache (x, y) : xs) | x == typeRep query = unsafeCoerce y | otherwise = go xs ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -113,6 +113,8 @@ stage0Packages = do , transformers , unlit , hp2ps + , ghc_debug_convention + , ghc_debug_stub , if windowsHost then win32 else unix ] ++ [ terminfo | not windowsHost, not cross ] @@ -160,8 +162,6 @@ stage1Packages = do , unlit , xhtml , if winTarget then win32 else unix - , ghc_debug_convention - , ghc_debug_stub ] , when (not cross) [ haddock ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -100,6 +100,7 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter" , notStage0 `cabalFlag` "ghc-debug" + , stage0 `cabalFlag` "ghc-debug" , ifM stage0 -- We build a threaded stage 1 if the bootstrapping compiler -- supports it. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9ce372a38510482910ea20bae04a153fc7a5892...9f3dddd5a8bfbeae21638f2865e1136c2fa5d9a1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9ce372a38510482910ea20bae04a153fc7a5892...9f3dddd5a8bfbeae21638f2865e1136c2fa5d9a1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 17:51:24 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 19 Mar 2024 13:51:24 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 4 commits: No wait that was right and that was the previous interface Message-ID: <65f9d09ca8b_2621dcf45d62030803c@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 56fb5416 by Rodrigo Mesquita at 2024-03-19T16:24:22+00:00 No wait that was right and that was the previous interface - - - - - 9e78dc4a by Rodrigo Mesquita at 2024-03-19T16:24:30+00:00 Start writing test - - - - - e28f0a71 by Rodrigo Mesquita at 2024-03-19T16:24:30+00:00 modify some things - - - - - d408a07a by Rodrigo Mesquita at 2024-03-19T17:50:57+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex - - - - - 16 changed files: - + NOTES - + T23415/Makefile - + T23415/main.hs - + T23415/make_shared_libs.sh - + T23415/run_test.sh - + T23415/test.c - libraries/ghci/GHCi/ObjLink.hs - rts/Linker.c - rts/LinkerInternals.h - rts/include/rts/Linker.h - rts/linker/Elf.c - rts/linker/Elf.h - + rts/linker/LoadNativeObjPosix.c - + rts/linker/LoadNativeObjPosix.h - rts/linker/PEi386.c - rts/rts.cabal Changes: ===================================== NOTES ===================================== @@ -0,0 +1,2 @@ +all linker calls need to be locked linker_mutex to lock global linker datastructures +dl_mutex is subsumed by linker_mutex, get rid of it entirely ===================================== T23415/Makefile ===================================== @@ -0,0 +1,10 @@ +.PHONY: run build clean + +run: + sh run_test.sh + +build: + sh make_shared_libs.sh + +clean: + rm -f lib*.out main main.o main.hi test.o tags ===================================== T23415/main.hs ===================================== @@ -0,0 +1,25 @@ +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +foreign import ccall unsafe "loadLibXXXObjs" loadLibsObjs :: IO Int +foreign import ccall unsafe "loadLibSymbols" loadLibSymbols :: IO Int + +hsLoadObjs = do + cwd <- getCurrentDirectory + forM_ [0..499] $ \i -> + loadDLL (cwd "lib" ++ show i ++ ".out") + +hsLoadSymbols = do + forM_ [0..499] $ \i -> + forM_ [0..99] $ \j -> + lookupSymbol ("lib" ++ show i ++ "_" ++ show j) + +main = do + -- print =<< loadLibsObjs + -- print =<< loadLibSymbols + + initObjLinker RetainCAFs + hsLoadObjs + hsLoadSymbols ===================================== T23415/make_shared_libs.sh ===================================== @@ -0,0 +1,20 @@ +#!/bin/sh + +example_dylib=$(basename -- $(find $(ghc --print-libdir) -name libHS* -not -name *.a | head -n1)) +dylib_ext="${example_dylib##*.}" +# we try .out instead of using the correct extension. + +i=0 +while [ $i -lt 500 ]; do + j=0 + while [ $j -lt 100 ]; do + echo "int lib${i}_$j(void) { return $i; }" >> "lib$i.c" + j=$(( j + 1 )) + done + cc -o "lib$i.o" -c "lib$i.c" -fPIC + cc -shared "lib$i.o" -o "lib$i.out" # "lib$i.$dylib_ext" + rm "lib$i.c" "lib$i.o" + i=$(( i + 1 )) +done + + ===================================== T23415/run_test.sh ===================================== @@ -0,0 +1,6 @@ +#!/bin/sh + +GHC=/Users/romes/ghc-dev/ghc/_build/stage1/bin/ghc + +$GHC --interactive test.c main.hs -package directory -package ghci -package filepath + ===================================== T23415/test.c ===================================== @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +int loadLibXXXObjs(void) { + + for (int i=0; i<500; i++) { + char path[16]; + char* err; + sprintf(path, "lib%d.out", i); + // loadNativeObj(path, &err); + addDLL(path); + } + + return 0; +} + +int loadLibSymbols(void) { + initLinker(); + for (int i=0; i<500; i++) { + char path[16]; + sprintf(path, "lib%d", i); + printf("loading %s\n", path); + lookupSymbol(path); + } + return 0; +} ===================================== libraries/ghci/GHCi/ObjLink.hs ===================================== @@ -74,7 +74,7 @@ lookupSymbolInDLL :: Ptr LoadedDLL -> String -> IO (Maybe (Ptr a)) lookupSymbolInDLL dll str_in = do let str = prefixUnderscore str_in withCAString str $ \c_str -> do - addr <- c_lookupSymbolInDLL dll c_str + addr <- c_lookupSymbolInNativeObj dll c_str if addr == nullPtr then return Nothing else return (Just addr) @@ -112,7 +112,7 @@ loadDLL str0 = do -- (maybe_handle, maybe_errmsg) <- withFilePath (normalise str) $ \dll -> alloca $ \errmsg_ptr -> (,) - <$> c_addDLL dll errmsg_ptr + <$> c_loadNativeObj dll errmsg_ptr <*> peek errmsg_ptr if maybe_handle == nullPtr @@ -176,8 +176,8 @@ resolveObjs = do -- Foreign declarations to RTS entry points which does the real work; -- --------------------------------------------------------------------------- -foreign import ccall unsafe "loadNativeObj" c_addDLL :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) -foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInDLL :: Ptr LoadedDLL -> CString -> IO (Ptr a) +foreign import ccall unsafe "loadNativeObj" c_loadNativeObj :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) +foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInNativeObj :: Ptr LoadedDLL -> CString -> IO (Ptr a) foreign import ccall unsafe "initLinker_" c_initLinker_ :: CInt -> IO () foreign import ccall unsafe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) foreign import ccall unsafe "loadArchive" c_loadArchive :: CFilePath -> IO Int ===================================== rts/Linker.c ===================================== @@ -77,6 +77,10 @@ # include #endif +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) +# include "linker/LoadNativeObjPosix.h" +#endif + #if defined(dragonfly_HOST_OS) #include #endif @@ -419,9 +423,6 @@ static int linker_init_done = 0 ; static void *dl_prog_handle; static regex_t re_invalid; static regex_t re_realso; -#if defined(THREADED_RTS) -Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section -#endif #endif void initLinker (void) @@ -455,9 +456,6 @@ initLinker_ (int retain_cafs) #if defined(THREADED_RTS) initMutex(&linker_mutex); -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - initMutex(&dl_mutex); -#endif #endif symhash = allocStrHashTable(); @@ -520,9 +518,6 @@ exitLinker( void ) { if (linker_init_done == 1) { regfree(&re_invalid); regfree(&re_realso); -#if defined(THREADED_RTS) - closeMutex(&dl_mutex); -#endif } #endif if (linker_init_done == 1) { @@ -578,8 +573,8 @@ static void * internal_dlsym(const char *symbol) { void *v; - // We acquire dl_mutex as concurrent dl* calls may alter dlerror - ACQUIRE_LOCK(&dl_mutex); + // concurrent dl* calls may alter dlerror + ASSERT_LOCK_HELD(&linker_mutex); // clears dlerror dlerror(); @@ -587,7 +582,6 @@ internal_dlsym(const char *symbol) { // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } @@ -597,12 +591,10 @@ internal_dlsym(const char *symbol) { v = dlsym(nc->dlopen_handle, symbol); if (dlerror() == NULL) { IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); - RELEASE_LOCK(&dl_mutex); return v; } } } - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); # define SPECIAL_SYMBOL(sym) \ @@ -645,34 +637,30 @@ internal_dlsym(const char *symbol) { void *lookupSymbolInNativeObj(void *handle, const char *symbol_name) { + ASSERT_LOCK_HELD(&linker_mutex); + #if defined(OBJFORMAT_MACHO) CHECK(symbol_name[0] == '_'); symbol_name = symbol_name+1; #endif - - ACQUIRE_LOCK(&dl_mutex); // dlsym alters dlerror void *result = dlsym(handle, symbol_name); - RELEASE_LOCK(&dl_mutex); return result; } # endif -// A backwards-compatibility shim wrapping `loadNativeObj`. -void *addDLL(pathchar* dll_name, const char **errmsg_ptr) +const char *addDLL(pathchar* dll_name) { # if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - void *dll_handle; - if (!(dll_handle = loadNativeObj(dll_name, &errmsg_ptr))) { - ASSERT(*errmsg_ptr != NULL); + char *errmsg; + if (loadNativeObj(dll_name, &errmsg)) { return NULL; + } else { + ASSERT(errmsg != NULL); + return errmsg; } - return dll_handle; # elif defined(OBJFORMAT_PEi386) - // FIXME: romes:question: why was this FIXME here, is it the NULL? - *errmsg_ptr = addDLL_PEi386(dll_name, NULL); - // ROMES:question: Does the caller know that they have to free the error message pointed to by the given argument pointer? - return NULL; + return addDLL_PEi386(dll_name); # else barf("addDLL: not implemented on this platform"); @@ -1104,9 +1092,10 @@ void freeObjectCode (ObjectCode *oc) if (oc->type == DYNAMIC_OBJECT) { #if defined(OBJFORMAT_ELF) - ACQUIRE_LOCK(&dl_mutex); + // ROMES:TODO: This previously acquired dl_mutex. Check that acquiring linker_mutex here is fine. + ACQUIRE_LOCK(&linker_mutex); freeNativeCode_ELF(oc); - RELEASE_LOCK(&dl_mutex); + RELEASE_LOCK(&linker_mutex); #else barf("freeObjectCode: This shouldn't happen"); #endif @@ -1876,68 +1865,15 @@ void * loadNativeObj (pathchar *path, char **errmsg) { IF_DEBUG(linker, debugBelch("loadNativeObj: path = '%s'\n", path)); ACQUIRE_LOCK(&linker_mutex); - void *r = loadNativeObj_ELF(path, errmsg); + void *r = loadNativeObj_POSIX(path, errmsg); - if (r) { - RELEASE_LOCK(&linker_mutex); - return r; - } - - // GHC #2615 - // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) - // contain linker scripts rather than ELF-format object code. This - // code handles the situation by recognizing the real object code - // file name given in the linker script. - // - // If an "invalid ELF header" error occurs, it is assumed that the - // .so file contains a linker script instead of ELF object code. - // In this case, the code looks for the GROUP ( ... ) linker - // directive. If one is found, the first file name inside the - // parentheses is treated as the name of a dynamic library and the - // code attempts to dlopen that file. If this is also unsuccessful, - // an error message is returned. - -#define NMATCH 5 - regmatch_t match[NMATCH]; - FILE* fp; - size_t match_length; -#define MAXLINE 1000 - char line[MAXLINE]; - int result; - - // see if the error message is due to an invalid ELF header - IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); - result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); - IF_DEBUG(linker, debugBelch("result = %i\n", result)); - if (result == 0) { - // success -- try to read the named file as a linker script - match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), - MAXLINE-1); - strncpy(line, (*errmsg+(match[1].rm_so)),match_length); - line[match_length] = '\0'; // make sure string is null-terminated - IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); - if ((fp = __rts_fopen(line, "r")) == NULL) { - RELEASE_LOCK(&linker_mutex); - // return original error if open fails - return NULL; - } - // try to find a GROUP or INPUT ( ... ) command - while (fgets(line, MAXLINE, fp) != NULL) { - IF_DEBUG(linker, debugBelch("input line = %s", line)); - if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { - // success -- try to dlopen the first named file - IF_DEBUG(linker, debugBelch("match%s\n","")); - line[match[2].rm_eo] = '\0'; - stgFree((void*)*errmsg); // Free old message before creating new one - r = loadNativeObj_ELF(line+match[2].rm_so, errmsg); - break; - } - // if control reaches here, no GROUP or INPUT ( ... ) directive - // was found and the original error message is returned to the - // caller - } - fclose(fp); +#if defined(OBJFORMAT_ELF) + if (!r) { + // Check if native object may be a linker script and try loading a native + // object from it + r = loadNativeObjFromLinkerScript_ELF(errmsg); } +#endif RELEASE_LOCK(&linker_mutex); return r; ===================================== rts/LinkerInternals.h ===================================== @@ -412,10 +412,6 @@ extern Elf_Word shndx_table_uninit_label; #if defined(THREADED_RTS) extern Mutex linker_mutex; - -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -extern Mutex dl_mutex; -#endif #endif /* THREADED_RTS */ /* Type of an initializer */ ===================================== rts/include/rts/Linker.h ===================================== @@ -93,7 +93,7 @@ HsInt unloadNativeObj( void *handle ); void *lookupSymbolInNativeObj(void *handle, const char *symbol_name); /* load a dynamic library */ -void *addDLL(pathchar* dll_name, const char **errmsg); +const char *addDLL(pathchar* dll_name); void *lookupSymbolInDLL(void *handle, const char *symbol_name); ===================================== rts/linker/Elf.c ===================================== @@ -2069,193 +2069,6 @@ int ocRunFini_ELF( ObjectCode *oc ) return true; } -/* - * Shared object loading - */ - -#if defined(HAVE_DLINFO) -struct piterate_cb_info { - ObjectCode *nc; - void *l_addr; /* base virtual address of the loaded code */ -}; - -static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size STG_UNUSED, void *data) { - struct piterate_cb_info *s = (struct piterate_cb_info *) data; - - // This logic mimicks _dl_addr_inside_object from glibc - // For reference: - // int - // internal_function - // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) - // { - // int n = l->l_phnum; - // const ElfW(Addr) reladdr = addr - l->l_addr; - // - // while (--n >= 0) - // if (l->l_phdr[n].p_type == PT_LOAD - // && reladdr - l->l_phdr[n].p_vaddr >= 0 - // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) - // return 1; - // return 0; - // } - - if ((void*) info->dlpi_addr == s->l_addr) { - int n = info->dlpi_phnum; - while (--n >= 0) { - if (info->dlpi_phdr[n].p_type == PT_LOAD) { - NativeCodeRange* ncr = - stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); - ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); - ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); - - ncr->next = s->nc->nc_ranges; - s->nc->nc_ranges = ncr; - } - } - } - return 0; -} -#endif /* defined(HAVE_DLINFO) */ - -static void copyErrmsg(char** errmsg_dest, char* errmsg) { - if (errmsg == NULL) errmsg = "loadNativeObj_ELF: unknown error"; - *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_ELF"); - strcpy(*errmsg_dest, errmsg); -} - -// need dl_mutex -void freeNativeCode_ELF (ObjectCode *nc) { - dlclose(nc->dlopen_handle); - - NativeCodeRange *ncr = nc->nc_ranges; - while (ncr) { - NativeCodeRange* last_ncr = ncr; - ncr = ncr->next; - stgFree(last_ncr); - } -} - -void * loadNativeObj_ELF (pathchar *path, char **errmsg) -{ - ObjectCode* nc; - void *hdl, *retval; - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF %" PATH_FMT "\n", path)); - - retval = NULL; - ACQUIRE_LOCK(&dl_mutex); - - // When dlopen() loads a profiled dynamic library, it calls the - // ctors which will call registerCcsList() to append the defined - // CostCentreStacks to CCS_LIST. This execution path starting from - // addDLL() was only protected by dl_mutex previously. However, - // another thread may be doing other things with the RTS linker - // that transitively calls refreshProfilingCCSs() which also - // accesses CCS_LIST, and those execution paths are protected by - // linker_mutex. So there's a risk of data race that may lead to - // segfaults (#24423), and we need to ensure the ctors are also - // protected by ccs_mutex. -#if defined(PROFILING) - ACQUIRE_LOCK(&ccs_mutex); -#endif - // ROMES:TODO: The above comment suggests the data race is caused by the two - // concurrent paths being locked by different mutexes (dl_mutex vs - // linker_mutex), but it seems that loadNativeObj will obtain a lock on - // linker_mutex before proceeding to here (in loadNativeObj_ELF) where it - // will obtain a lock on dl_mutex). But ccs_mutex seems like something - // else entirely? - - /* If we load the same object multiple times, just return the - * already-loaded handle. Note that this is broken if unloadNativeObj - * is used, as we don’t do any reference counting; see #24345. - */ - ObjectCode *existing_oc = lookupObjectByPath(path); - if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { - if (existing_oc->type == DYNAMIC_OBJECT) { - retval = existing_oc->dlopen_handle; - goto success; - } - copyErrmsg(errmsg, "loadNativeObj_ELF: already loaded as non-dynamic object"); - goto dlopen_fail; - } - - nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); - - foreignExportsLoadingObject(nc); - // ROMES:TODO: We previously did RTLD_LAZY in addDLL, but now we do RTLD_NOW. What's the diff? - // hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); - hdl = dlopen(path, RTLD_NOW|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ - nc->dlopen_handle = hdl; - nc->status = OBJECT_READY; - foreignExportsFinishedLoadingObject(); - - // ROMES:TODO: Could it make sense to do this profiling lock and unlock in foreignExportsLoadingObject/foreignExportsFinishedLoadingObject -#if defined(PROFILING) - RELEASE_LOCK(&ccs_mutex); -#endif - - if (hdl == NULL) { - /* dlopen failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlopen_fail; - } - -#if defined(HAVE_DLINFO) - struct link_map *map; - if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { - /* dlinfo failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlinfo_fail; - } - - hdl = NULL; // pass handle ownership to nc - - struct piterate_cb_info piterate_info = { - .nc = nc, - .l_addr = (void *) map->l_addr - }; - dl_iterate_phdr(loadNativeObjCb_, &piterate_info); - if (!nc->nc_ranges) { - copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); - goto dl_iterate_phdr_fail; - } - nc->unloadable = true; -#else - nc->nc_ranges = NULL; - nc->unloadable = false; -#endif /* defined (HAVE_DLINFO) */ - - insertOCSectionIndices(nc); - - nc->next_loaded_object = loaded_objects; - loaded_objects = nc; - - retval = nc->dlopen_handle; - -#if defined(PROFILING) - // collect any new cost centres that were defined in the loaded object. - refreshProfilingCCSs(); -#endif - - goto success; - -dl_iterate_phdr_fail: - // already have dl_mutex - freeNativeCode_ELF(nc); -dlinfo_fail: - if (hdl) dlclose(hdl); -dlopen_fail: -success: - - RELEASE_LOCK(&dl_mutex); - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF result=%p\n", retval)); - - return retval; -} - - /* * PowerPC & X86_64 ELF specifics */ @@ -2305,4 +2118,70 @@ int ocAllocateExtras_ELF( ObjectCode *oc ) #endif /* NEED_SYMBOL_EXTRAS */ +void * loadNativeObjFromLinkerScript_ELF(char **errmsg) +{ + // GHC #2615 + // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) + // contain linker scripts rather than ELF-format object code. This + // code handles the situation by recognizing the real object code + // file name given in the linker script. + // + // If an "invalid ELF header" error occurs, it is assumed that the + // .so file contains a linker script instead of ELF object code. + // In this case, the code looks for the GROUP ( ... ) linker + // directive. If one is found, the first file name inside the + // parentheses is treated as the name of a dynamic library and the + // code attempts to dlopen that file. If this is also unsuccessful, + // an error message is returned. + +#define NMATCH 5 + regmatch_t match[NMATCH]; + FILE* fp; + size_t match_length; +#define MAXLINE 1000 + char line[MAXLINE]; + int result; + void* r = NULL; + + ASSERT_LOCK_HELD(&linker_mutex) + + // see if the error message is due to an invalid ELF header + IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); + result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); + IF_DEBUG(linker, debugBelch("result = %i\n", result)); + if (result == 0) { + // success -- try to read the named file as a linker script + match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), + MAXLINE-1); + strncpy(line, (*errmsg+(match[1].rm_so)),match_length); + line[match_length] = '\0'; // make sure string is null-terminated + IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); + if ((fp = __rts_fopen(line, "r")) == NULL) { + // return original error if open fails + return NULL; + } + // try to find a GROUP or INPUT ( ... ) command + while (fgets(line, MAXLINE, fp) != NULL) { + IF_DEBUG(linker, debugBelch("input line = %s", line)); + if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { + // success -- try to dlopen the first named file + IF_DEBUG(linker, debugBelch("match%s\n","")); + line[match[2].rm_eo] = '\0'; + stgFree((void*)*errmsg); // Free old message before creating new one + // ROMES:TODO: NO GOOD, this is almost recursive? no, as long we + // move the loadNativeObj_ELF to a shared impl + r = loadNativeObj_POSIX(line+match[2].rm_so, errmsg); + break; + } + // if control reaches here, no GROUP or INPUT ( ... ) directive + // was found and the original error message is returned to the + // caller + } + fclose(fp); + } + + return r; +} + + #endif /* elf */ ===================================== rts/linker/Elf.h ===================================== @@ -14,7 +14,6 @@ int ocResolve_ELF ( ObjectCode* oc ); int ocRunInit_ELF ( ObjectCode* oc ); int ocRunFini_ELF ( ObjectCode* oc ); int ocAllocateExtras_ELF ( ObjectCode *oc ); -void freeNativeCode_ELF ( ObjectCode *nc ); -void *loadNativeObj_ELF ( pathchar *path, char **errmsg ); +void *loadNativeObjFromLinkerScript_ELF( char **errmsg ); #include "EndPrivate.h" ===================================== rts/linker/LoadNativeObjPosix.c ===================================== @@ -0,0 +1,211 @@ +#include "CheckUnload.h" +#include "ForeignExports.h" +#include "LinkerInternals.h" +#include "Rts.h" +#include "RtsUtils.h" +#include "Profiling.h" + +#include "linker/LoadNativeObjPosix.h" + +#if defined(HAVE_DLFCN_H) +#include +#endif + +#include + +#if defined(THREADED_RTS) +extern Mutex linker_mutex; +#endif + +/* + * Shared object loading + */ + +#if defined(HAVE_DLINFO) +struct piterate_cb_info { + ObjectCode *nc; + void *l_addr; /* base virtual address of the loaded code */ +}; + +static int loadNativeObjCb_(struct dl_phdr_info *info, + size_t _size STG_UNUSED, void *data) { + struct piterate_cb_info *s = (struct piterate_cb_info *) data; + + // This logic mimicks _dl_addr_inside_object from glibc + // For reference: + // int + // internal_function + // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) + // { + // int n = l->l_phnum; + // const ElfW(Addr) reladdr = addr - l->l_addr; + // + // while (--n >= 0) + // if (l->l_phdr[n].p_type == PT_LOAD + // && reladdr - l->l_phdr[n].p_vaddr >= 0 + // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) + // return 1; + // return 0; + // } + + if ((void*) info->dlpi_addr == s->l_addr) { + int n = info->dlpi_phnum; + while (--n >= 0) { + if (info->dlpi_phdr[n].p_type == PT_LOAD) { + NativeCodeRange* ncr = + stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); + ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); + ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); + + ncr->next = s->nc->nc_ranges; + s->nc->nc_ranges = ncr; + } + } + } + return 0; +} +#endif /* defined(HAVE_DLINFO) */ + +static void copyErrmsg(char** errmsg_dest, char* errmsg) { + if (errmsg == NULL) errmsg = "loadNativeObj_POSIX: unknown error"; + *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_POSIX"); + strcpy(*errmsg_dest, errmsg); +} + +void freeNativeCode_POSIX (ObjectCode *nc) { + ASSERT_LOCK_HELD(&linker_mutex); + + dlclose(nc->dlopen_handle); + + NativeCodeRange *ncr = nc->nc_ranges; + while (ncr) { + NativeCodeRange* last_ncr = ncr; + ncr = ncr->next; + stgFree(last_ncr); + } +} + +void * loadNativeObj_POSIX (pathchar *path, char **errmsg) +{ + ObjectCode* nc; + void *hdl, *retval; + + ASSERT_LOCK_HELD(&linker_mutex); + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX %" PATH_FMT "\n", path)); + + retval = NULL; + + + /* If we load the same object multiple times, just return the + * already-loaded handle. Note that this is broken if unloadNativeObj + * is used, as we don’t do any reference counting; see #24345. + */ + ObjectCode *existing_oc = lookupObjectByPath(path); + if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { + if (existing_oc->type == DYNAMIC_OBJECT) { + retval = existing_oc->dlopen_handle; + goto success; + } + copyErrmsg(errmsg, "loadNativeObj_POSIX: already loaded as non-dynamic object"); + goto dlopen_fail; + } + + nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); + + foreignExportsLoadingObject(nc); + + // When dlopen() loads a profiled dynamic library, it calls the ctors which + // will call registerCcsList() to append the defined CostCentreStacks to + // CCS_LIST. However, another thread may be doing other things with the RTS + // linker that transitively calls refreshProfilingCCSs() which also accesses + // CCS_LIST. So there's a risk of data race that may lead to segfaults + // (#24423), and we need to ensure the ctors are also protected by + // ccs_mutex. +#if defined(PROFILING) + ACQUIRE_LOCK(&ccs_mutex); +#endif + + // If we HAVE_DLINFO, we use RTLD_NOW rather than RTLD_LAZY because we want + // to learn eagerly about all external functions. Otherwise, there is no + // additional advantage to being eager, so it is better to be lazy and only bind + // functions when needed for better performance. + int dlopen_mode; +#if defined(HAVE_DLINFO) + dlopen_mode = RTLD_NOW; +#else + dlopen_mode = RTLD_LAZY; +#endif + + hdl = dlopen(path, dlopen_mode|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + nc->dlopen_handle = hdl; + nc->status = OBJECT_READY; + +#if defined(PROFILING) + RELEASE_LOCK(&ccs_mutex); +#endif + + foreignExportsFinishedLoadingObject(); + + if (hdl == NULL) { + /* dlopen failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlopen_fail; + } + +#if defined(HAVE_DLINFO) + struct link_map *map; + if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { + /* dlinfo failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlinfo_fail; + } + + hdl = NULL; // pass handle ownership to nc + + struct piterate_cb_info piterate_info = { + .nc = nc, + .l_addr = (void *) map->l_addr + }; + dl_iterate_phdr(loadNativeObjCb_, &piterate_info); + if (!nc->nc_ranges) { + copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); + goto dl_iterate_phdr_fail; + } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; +#endif /* defined (HAVE_DLINFO) */ + + insertOCSectionIndices(nc); + + nc->next_loaded_object = loaded_objects; + loaded_objects = nc; + + retval = nc->dlopen_handle; + +#if defined(PROFILING) + // collect any new cost centres that were defined in the loaded object. + refreshProfilingCCSs(); +#endif + + goto success; + +#if defined(HAVE_DLINFO) +dl_iterate_phdr_fail: +#endif + freeNativeCode_POSIX(nc); +#if defined(HAVE_DLINFO) +dlinfo_fail: +#endif + if (hdl) dlclose(hdl); +dlopen_fail: +success: + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX result=%p\n", retval)); + + return retval; +} + + ===================================== rts/linker/LoadNativeObjPosix.h ===================================== @@ -0,0 +1,11 @@ +#pragma once + +#include "Rts.h" +#include "LinkerInternals.h" + +#include "BeginPrivate.h" + +void freeNativeCode_POSIX ( ObjectCode *nc ); +void *loadNativeObj_POSIX ( pathchar *path, char **errmsg ); + +#include "EndPrivate.h" ===================================== rts/linker/PEi386.c ===================================== @@ -1865,7 +1865,7 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if (result != NULL || dllInstance == 0) { errorBelch("Could not load `%s'. Reason: %s\n", (char*)dllName, result); - // ROMES:QUESTION: Leaks `result`? + stgFree(result); return false; } ===================================== rts/rts.cabal ===================================== @@ -458,6 +458,7 @@ library linker/Elf.c linker/InitFini.c linker/LoadArchive.c + linker/LoadNativeObjPosix.c linker/M32Alloc.c linker/MMap.c linker/MachO.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c9d36adcd528ca9d0308ed12b121325977a181d...d408a07a0b5e9888d1c33a7a202880c06869b317 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c9d36adcd528ca9d0308ed12b121325977a181d...d408a07a0b5e9888d1c33a7a202880c06869b317 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:21:44 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 19 Mar 2024 14:21:44 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-cleanups Message-ID: <65f9d7b8b5d47_2621dc1029ac4c310596@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-cleanups at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-cleanups You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:48:37 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:48:37 -0400 Subject: [Git][ghc/ghc][master] Escape multiple arguments in the settings file Message-ID: <65f9de05e45f3_2621dc11032954323273@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - 8 changed files: - compiler/GHC/Settings/IO.hs - hadrian/src/Rules/Generate.hs - + test.hs - + testsuite/tests/ghc-api/settings-escape/T11938.hs - + testsuite/tests/ghc-api/settings-escape/T11938.stderr - + testsuite/tests/ghc-api/settings-escape/all.T - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/.gitkeep - + testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep Changes: ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -16,9 +16,11 @@ import GHC.Utils.CliOption import GHC.Utils.Fingerprint import GHC.Platform import GHC.Utils.Panic +import GHC.ResponseFile import GHC.Settings import GHC.SysTools.BaseDir +import Data.Char import Control.Monad.Trans.Except import Control.Monad.IO.Class import qualified Data.Map as Map @@ -72,9 +74,13 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getRawFilePathSetting top_dir settingsFile mySettings key + -- Escape the 'top_dir', to make sure we don't accidentally introduce an + -- unescaped space + getRawFilePathSetting (escapeArg top_dir) settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String - getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key + -- Escape the 'mtool_dir', to make sure we don't accidentally introduce + -- an unescaped space + getToolSetting key = expandToolDir useInplaceMinGW (fmap escapeArg mtool_dir) <$> getSetting key targetPlatformString <- getSetting "target platform string" cc_prog <- getToolSetting "C compiler command" cxx_prog <- getToolSetting "C++ compiler command" @@ -91,10 +97,10 @@ initSettings top_dir = do let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] else [] - cpp_args = map Option (words cpp_args_str) - hs_cpp_args = map Option (words hs_cpp_args_str) - cc_args = words cc_args_str ++ unreg_cc_args - cxx_args = words cxx_args_str + cpp_args = map Option (unescapeArgs cpp_args_str) + hs_cpp_args = map Option (unescapeArgs hs_cpp_args_str) + cc_args = unescapeArgs cc_args_str ++ unreg_cc_args + cxx_args = unescapeArgs cxx_args_str -- The extra flags we need to pass gcc when we invoke it to compile .hc code. -- @@ -135,12 +141,12 @@ initSettings top_dir = do let as_prog = cc_prog as_args = map Option cc_args ld_prog = cc_prog - ld_args = map Option (cc_args ++ words cc_link_args_str) + ld_args = map Option (cc_args ++ unescapeArgs cc_link_args_str) ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getToolSetting "Merge objects flags" let ld_r | null ld_r_prog = Nothing - | otherwise = Just (ld_r_prog, map Option $ words ld_r_args) + | otherwise = Just (ld_r_prog, map Option $ unescapeArgs ld_r_args) llvmTarget <- getSetting "LLVM target" @@ -261,3 +267,19 @@ getTargetPlatform settingsFile settings = do , platformHasLibm = targetHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } + +-- ---------------------------------------------------------------------------- +-- Escape Args helpers +-- ---------------------------------------------------------------------------- + +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -6,6 +6,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import Data.Char (isSpace) import qualified Data.Set as Set import Base import qualified Context @@ -416,7 +417,7 @@ generateSettings = do , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) - , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) + , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays) , ("Tables next to code", queryTarget (yesNo . tgtTablesNextToCode)) , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) @@ -431,23 +432,23 @@ generateSettings = do ++ ["]"] where ccPath = prgPath . ccProgram . tgtCCompiler - ccFlags = unwords . prgFlags . ccProgram . tgtCCompiler + ccFlags = escapeArgs . prgFlags . ccProgram . tgtCCompiler cxxPath = prgPath . cxxProgram . tgtCxxCompiler - cxxFlags = unwords . prgFlags . cxxProgram . tgtCxxCompiler - clinkFlags = unwords . prgFlags . ccLinkProgram . tgtCCompilerLink + cxxFlags = escapeArgs . prgFlags . cxxProgram . tgtCxxCompiler + clinkFlags = escapeArgs . prgFlags . ccLinkProgram . tgtCCompilerLink linkSupportsNoPie = yesNo . ccLinkSupportsNoPie . tgtCCompilerLink cppPath = prgPath . cppProgram . tgtCPreprocessor - cppFlags = unwords . prgFlags . cppProgram . tgtCPreprocessor + cppFlags = escapeArgs . prgFlags . cppProgram . tgtCPreprocessor hsCppPath = prgPath . hsCppProgram . tgtHsCPreprocessor - hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor + hsCppFlags = escapeArgs . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs - mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + mergeObjsFlags = maybe "" (escapeArgs . prgFlags . mergeObjsProgram) . tgtMergeObjs linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink arPath = prgPath . arMkArchive . tgtAr - arFlags = unwords . prgFlags . arMkArchive . tgtAr + arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib @@ -571,3 +572,19 @@ generatePlatformHostHs = do , "hostPlatformArchOS :: ArchOS" , "hostPlatformArchOS = ArchOS hostPlatformArch hostPlatformOS" ] + +-- | Just like 'GHC.ResponseFile.escapeArgs', but use spaces instead of newlines +-- for splitting elements. +escapeArgs :: [String] -> String +escapeArgs = unwords . map escapeArg + +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs ===================================== test.hs ===================================== @@ -0,0 +1,14 @@ +import Data.Char +import Data.Foldable +-- | Just like 'GHC.ResponseFile.escapeArg', but it is not exposed from base. +escapeArg :: String -> String +escapeArg = reverse . foldl' escape [] + +escape :: String -> Char -> String +escape cs c + | isSpace c + || '\\' == c + || '\'' == c + || '"' == c = c:'\\':cs -- n.b., our caller must reverse the result + | otherwise = c:cs + ===================================== testsuite/tests/ghc-api/settings-escape/T11938.hs ===================================== @@ -0,0 +1,136 @@ + +import GHC +import GHC.ResponseFile (unescapeArgs) +import GHC.Settings +import GHC.Settings.IO +import GHC.Driver.DynFlags +import GHC.Driver.Session +import GHC.Driver.Env +import GHC.Utils.CliOption (Option, showOpt) + +import Control.Monad.Trans.Except (runExceptT) +import qualified Data.Set as Set +import Data.Maybe (fromJust) +import Data.List (intercalate) +import System.Directory (makeAbsolute, createDirectory) +import System.Environment +import System.IO (hPutStrLn, stderr) +import System.Exit (exitWith, ExitCode(ExitFailure)) + +-- Precondition: this test case must be executed in a directory with a space. +-- +-- First we get the current settings file and amend it with extra arguments that we *know* +-- contain spaces by construction. +-- Then, we write this new settings file to disk where we know one of the parent +-- directories contains a space by virtue of the ghc test suite. This is important +-- for testing variable substitution containing spaces in the settings file. +-- At last, we parse the settings file again and compare the options to the original settings +-- file. As we added a fixed number of options, we verify that relevant all config options parser +-- escaped the spaces appropriately. +main :: IO () +main = do + libdir:args <- getArgs + + (rawSettingOpts, originalSettings) <- runGhc (Just libdir) $ do + dflags <- hsc_dflags <$> getSession + pure (rawSettings dflags, settings dflags) + + topDir <- makeAbsolute "./ghc-install-folder/lib" + + let argsWithSpaces = "\"-some option\" -some\\ other" + numberOfExtraArgs = length $ unescapeArgs argsWithSpaces + -- These are all options that can have multiple 'String' or 'Option' values. + -- We explicitly do not add 'C compiler link flags' here, as 'initSettings' + -- already adds the options of "C compiler flags" to this config field. + multipleArguments = Set.fromList + [ "Haskell CPP flags" + , "C compiler flags" + , "C++ compiler flags" + , "CPP flags" + , "Merge objects flags" + ] + + let rawSettingOptsWithExtraArgs = + map (\(name, args) -> if Set.member name multipleArguments + then (name, args ++ " " ++ argsWithSpaces) + else (name, args)) rawSettingOpts + + -- write out the modified settings. We try to keep it legible + writeFile (topDir ++ "/settings") $ + "[" ++ (intercalate "\n," (map show rawSettingOptsWithExtraArgs)) ++ "]" + + settingsm <- runExceptT $ initSettings topDir + + case settingsm of + Left (SettingsError_MissingData msg) -> do + hPutStrLn stderr $ "WARNING: " ++ show msg + hPutStrLn stderr $ "dont know target platform" + exitWith $ ExitFailure 1 + Left (SettingsError_BadData msg) -> do + hPutStrLn stderr msg + exitWith $ ExitFailure 1 + Right settings -> do + let + recordSetting :: String -> (Settings -> [String]) -> IO () + recordSetting label selector = do + let opts = selector settings + origOpts = selector originalSettings + -- At least one of the options must contain a space + containsSpaces = any (' ' `elem`) opts + hPutStrLn stderr + $ "=== '" <> label <> "' contains " ++ show numberOfExtraArgs ++ " new entries: " + ++ show (length opts == length origOpts + numberOfExtraArgs) + hPutStrLn stderr $ " Contains spaces: " ++ show containsSpaces + + recordSettingM :: String -> (Settings -> Maybe [a]) -> IO () + recordSettingM label selector = do + let optsM = selector settings + origOptsM = selector originalSettings + hPutStrLn stderr + $ "=== '" <> label <> "' contains expected entries: " + ++ show (case (optsM, origOptsM) of + (Just opts, Just origOpts) -> length opts == length origOpts + numberOfExtraArgs + (Nothing, Nothing) -> True + (Just _, Nothing) -> False + (Nothing, Just _) -> False + ) + + recordFpSetting :: String -> (Settings -> String) -> IO () + recordFpSetting label selector = do + let fp = selector settings + containsOnlyEscapedSpaces ('\\':' ':xs) = containsOnlyEscapedSpaces xs + containsOnlyEscapedSpaces (' ':_) = False + containsOnlyEscapedSpaces [] = True + containsOnlyEscapedSpaces (_:xs) = containsOnlyEscapedSpaces xs + + -- Filepath may only contain escaped spaces + containsSpaces = containsOnlyEscapedSpaces fp + hPutStrLn stderr $ "=== FilePath '" <> label <> "' contains only escaped spaces: " ++ show containsSpaces + + -- Assertions + -- Assumption: this test case is executed in a directory with a space. + + -- Setting 'Haskell CPP flags' contains '$topdir' reference. + -- Resolving those while containing spaces, should not introduce more options. + recordSetting "Haskell CPP flags" (map showOpt . snd . toolSettings_pgm_P . sToolSettings) + -- Setting 'C compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C compiler flags" (toolSettings_opt_c . sToolSettings) + -- Setting 'C compiler link flags' contains strings with spaces. + -- GHC should not split these by word. + -- While we did not explicitly add the extra arguments, 'initSettings' adds "C compiler flags" options + -- to this field. + recordSetting "C compiler link flags" (map showOpt . snd . toolSettings_pgm_l . sToolSettings) + -- Setting 'C++ compiler flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "C++ compiler flags" (toolSettings_opt_cxx . sToolSettings) + -- Setting 'CPP flags' contains strings with spaces. + -- GHC should not split these by word. + recordSetting "CPP flags" (map showOpt . snd . toolSettings_pgm_cpp . sToolSettings) + -- Setting 'Merge objects flags' contains strings with spaces. + -- GHC should not split these by word. + -- If 'Nothing', ignore this test, otherwise the same assertion holds as before. + recordSettingM "Merge objects flags" (fmap (map showOpt . snd) . toolSettings_pgm_lm . sToolSettings) + -- Setting 'unlit command' contains '$topdir' reference. + -- Resolving those while containing spaces, should be escaped correctly. + recordFpSetting "unlit command" (toolSettings_pgm_L . sToolSettings) ===================================== testsuite/tests/ghc-api/settings-escape/T11938.stderr ===================================== @@ -0,0 +1,12 @@ +=== 'Haskell CPP flags' contains 2 new entries: True + Contains spaces: True +=== 'C compiler flags' contains 2 new entries: True + Contains spaces: True +=== 'C compiler link flags' contains 2 new entries: True + Contains spaces: True +=== 'C++ compiler flags' contains 2 new entries: True + Contains spaces: True +=== 'CPP flags' contains 2 new entries: True + Contains spaces: True +=== 'Merge objects flags' contains expected entries: True +=== FilePath 'unlit command' contains only escaped spaces: True ===================================== testsuite/tests/ghc-api/settings-escape/all.T ===================================== @@ -0,0 +1,5 @@ +test('T11938', + [ extra_run_opts('"' + config.libdir + '"') + , extra_files(['ghc-install-folder/'])] + , compile_and_run + , ['-package ghc -package directory -package containers -package transformers']) ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/lib/.gitkeep ===================================== ===================================== testsuite/tests/ghc-api/settings-escape/ghc-install-folder/mingw/.gitkeep ===================================== View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31bf85ee49fe2ca0b17eaee0774e395f017a9373 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31bf85ee49fe2ca0b17eaee0774e395f017a9373 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:49:26 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:49:26 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Read global package database from settings file Message-ID: <65f9de369e1ba_2621dc1122fff43284ed@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - 8 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - libraries/ghc-boot/GHC/Settings/Utils.hs - utils/ghc-pkg/Main.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3611,7 +3611,8 @@ compilerInfo dflags ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), ("LibDir", topDir dflags), - -- The path of the global package database used by GHC + -- This is always an absolute path, unlike "Relative Global Package DB" which is + -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ] where ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -118,8 +118,14 @@ initSettings top_dir = do ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" - let globalpkgdb_path = installed "package.conf.d" - ghc_usage_msg_path = installed "ghc-usage.txt" + + -- The package database is either a relative path to the location of the settings file + -- OR an absolute path. + -- In case the path is absolute then top_dir abs_path == abs_path + -- the path is relative then top_dir rel_path == top_dir rel_path + globalpkgdb_path <- installed <$> getSetting "Relative Global Package DB" + + let ghc_usage_msg_path = installed "ghc-usage.txt" ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities ===================================== hadrian/bindist/Makefile ===================================== @@ -141,6 +141,7 @@ lib/settings : config.mk @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@ @echo ',("RTS expects libdw", "$(GhcRtsWithLibdw)")' >> $@ + @echo ',("Relative Global Package DB", "package.conf.d")' >> $@ @echo "]" >> $@ # We need to install binaries relative to libraries. ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -13,8 +13,6 @@ import Hadrian.Oracles.TextFile import Oracles.Setting (topDirectory, setting, Setting(..)) import Packages import Settings.Program (programContext) -import Hadrian.Oracles.Path -import System.Directory (makeAbsolute) testConfigFile :: Action FilePath testConfigFile = buildRoot <&> (-/- "test/ghcconfig") @@ -81,15 +79,12 @@ testRTSSettings = do file <- testConfigFile words <$> lookupValueOrError Nothing file "GhcRTSWays" -absoluteBuildRoot :: Action FilePath -absoluteBuildRoot = (fixAbsolutePathOnWindows =<< liftIO . makeAbsolute =<< buildRoot) - -- | Directory to look for binaries. -- We assume that required programs are present in the same binary directory -- in which ghc is stored and that they have their conventional name. getBinaryDirectory :: String -> Action FilePath getBinaryDirectory "stage0" = takeDirectory <$> setting SystemGhc -getBinaryDirectory "stage1" = liftM2 (-/-) absoluteBuildRoot (pure "stage1-test/bin/") +getBinaryDirectory "stage1" = liftM2 (-/-) topDirectory (stageBinPath stage0InTree) getBinaryDirectory "stage2" = liftM2 (-/-) topDirectory (stageBinPath Stage1) getBinaryDirectory "stage3" = liftM2 (-/-) topDirectory (stageBinPath Stage2) getBinaryDirectory "stage-cabal" = do @@ -101,7 +96,7 @@ getBinaryDirectory compiler = pure $ takeDirectory compiler -- | Get the path to the given @--test-compiler at . getCompilerPath :: String -> Action FilePath getCompilerPath "stage0" = setting SystemGhc -getCompilerPath "stage1" = liftM2 (-/-) absoluteBuildRoot (pure ("stage1-test/bin/ghc" <.> exe)) +getCompilerPath "stage1" = liftM2 (-/-) topDirectory (fullPath stage0InTree ghc) getCompilerPath "stage2" = liftM2 (-/-) topDirectory (fullPath Stage1 ghc) getCompilerPath "stage3" = liftM2 (-/-) topDirectory (fullPath Stage2 ghc) getCompilerPath "stage-cabal" = do ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -235,8 +235,8 @@ generateRules = do forM_ allStages $ \stage -> do let prefix = root -/- stageString stage -/- "lib" - go gen file = generate file (semiEmptyTarget stage) gen - (prefix -/- "settings") %> go generateSettings + go gen file = generate file (semiEmptyTarget (succStage stage)) gen + (prefix -/- "settings") %> \out -> go (generateSettings out) out where file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out @@ -356,21 +356,26 @@ templateRules = do ghcWrapper :: Stage -> Expr String ghcWrapper (Stage0 {}) = error "Stage0 GHC does not require a wrapper script to run." ghcWrapper stage = do - dbPath <- expr $ () <$> topDirectory <*> packageDbPath (PackageDbLoc stage Final) ghcPath <- expr $ () <$> topDirectory <*> programPath (vanillaContext (predStage stage) ghc) return $ unwords $ map show $ [ ghcPath ] - ++ (if stage == Stage1 - then ["-no-global-package-db" - , "-package-env=-" - , "-package-db " ++ dbPath - ] - else []) ++ [ "$@" ] -generateSettings :: Expr String -generateSettings = do +generateSettings :: FilePath -> Expr String +generateSettings settingsFile = do ctx <- getContext + stage <- getStage + + package_db_path <- expr $ do + let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final) + case stage of + Stage0 {} -> error "Unable to generate settings for stage0" + Stage1 -> get_pkg_db Stage1 + Stage2 -> get_pkg_db Stage1 + Stage3 -> get_pkg_db Stage2 + + let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path + settings <- traverse sequence $ [ ("C compiler command", queryTarget ccPath) , ("C compiler flags", queryTarget ccFlags) @@ -422,6 +427,7 @@ generateSettings = do , ("Leading underscore", queryTarget (yesNo . tgtSymbolsHaveLeadingUnderscore)) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) + , ("Relative Global Package DB", pure rel_pkg_db) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -124,28 +124,6 @@ testRules = do testsuiteDeps - -- we need to create wrappers to test the stage1 compiler - -- as the stage1 compiler needs the stage2 libraries - -- to have any hope of passing tests. - root -/- "stage1-test/bin/*" %> \path -> do - - bin_path <- stageBinPath stage0InTree - let prog = takeBaseName path - stage0prog = bin_path -/- prog <.> exe - need [stage0prog] - abs_prog_path <- liftIO (IO.canonicalizePath stage0prog) - -- Use the stage1 package database - pkgDb <- liftIO . IO.makeAbsolute =<< packageDbPath (PackageDbLoc Stage1 Final) - if prog `elem` ["ghc","runghc"] then do - let flags = [ "-no-global-package-db", "-no-user-package-db", "-hide-package", "ghc" , "-package-env","-","-package-db",pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else if prog == "ghc-pkg" then do - let flags = ["--no-user-package-db", "--global-package-db", pkgDb] - writeFile' path $ unlines ["#!/bin/sh",unwords ((abs_prog_path : flags) ++ ["${1+\"$@\"}"])] - makeExecutable path - else createFileLink abs_prog_path path - -- Rules for building check-ppr, check-exact and -- check-ppr-annotations with the compiler we are going to test -- (in-tree or out-of-tree). @@ -344,18 +322,6 @@ needTestsuitePackages stg = do need =<< mapM (uncurry pkgFile) pkgs cross <- flag CrossCompiling when (not cross) $ needIservBins stg - root <- buildRoot - -- require the shims for testing stage1 - when (stg == stage0InTree) $ do - -- Windows not supported as the wrapper scripts don't work on windows.. we could - -- support it with a separate .bat or C wrapper code path but seems overkill when no-one will - -- probably ever try and do this. - when windowsHost $ do - putFailure $ unlines [ "Testing stage1 compiler with windows is currently unsupported," - , "if you desire to do this then please open a ticket"] - fail "Testing stage1 is not supported" - - need =<< sequence [(\f -> root -/- "stage1-test/bin" -/- takeFileName f) <$> (pkgFile stage0InTree p) | (Stage0 InTreeLibs,p) <- exepkgs] -- stage 1 ghc lives under stage0/bin, -- stage 2 ghc lives under stage1/bin, etc ===================================== libraries/ghc-boot/GHC/Settings/Utils.hs ===================================== @@ -8,6 +8,7 @@ import qualified Data.Map as Map import GHC.BaseDir import GHC.Platform.ArchOS +import System.FilePath maybeRead :: Read a => String -> Maybe a maybeRead str = case reads str of @@ -42,6 +43,12 @@ getTargetArchOS settingsFile settings = ArchOS <$> readRawSetting settingsFile settings "target arch" <*> readRawSetting settingsFile settings "target os" +getGlobalPackageDb :: FilePath -> RawSettings -> Either String FilePath +getGlobalPackageDb settingsFile settings = do + rel_db <- getRawSetting settingsFile settings "Relative Global Package DB" + return (dropFileName settingsFile rel_db) + + getRawSetting :: FilePath -> RawSettings -> String -> Either String String ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -28,7 +28,7 @@ import qualified GHC.Unit.Database as GhcPkg import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) -import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) +import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy, getGlobalPackageDb, RawSettings) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) import qualified GHC.Data.ShortText as ST @@ -582,6 +582,21 @@ allPackagesInStack = concatMap packages stackUpTo :: FilePath -> PackageDBStack -> PackageDBStack stackUpTo to_modify = dropWhile ((/= to_modify) . location) +readFromSettingsFile :: FilePath + -> (FilePath -> RawSettings -> Either String b) + -> IO (Either String b) +readFromSettingsFile settingsFile f = do + settingsStr <- readFile settingsFile + pure $ do + mySettings <- case maybeReadFuzzy settingsStr of + Just s -> pure $ Map.fromList s + -- It's excusable to not have a settings file (for now at + -- least) but completely inexcusable to have a malformed one. + Nothing -> Left $ "Can't parse settings file " ++ show settingsFile + case f settingsFile mySettings of + Right archOS -> Right archOS + Left e -> Left e + getPkgDatabases :: Verbosity -> GhcPkg.DbOpenMode mode DbModifySelector -> Bool -- use the user db @@ -605,24 +620,38 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do -- location is passed to the binary using the --global-package-db flag by the -- wrapper script. let err_msg = "missing --global-package-db option, location of global package database unknown\n" - global_conf <- + (top_dir, global_conf) <- case [ f | FlagGlobalConfig f <- my_flags ] of -- See Note [Base Dir] for more information on the base dir / top dir. [] -> do mb_dir <- getBaseDir case mb_dir of Nothing -> die err_msg Just dir -> do - r <- lookForPackageDBIn dir - case r of - Nothing -> die ("Can't find package database in " ++ dir) - Just path -> return path - fs -> return (last fs) - - -- The value of the $topdir variable used in some package descriptions - -- Note that the way we calculate this is slightly different to how it - -- is done in ghc itself. We rely on the convention that the global - -- package db lives in ghc's libdir. - top_dir <- absolutePath (takeDirectory global_conf) + -- Look for where it is given in the settings file, if marked there. + let settingsFile = dir "settings" + exists_settings_file <- doesFileExist settingsFile + erel_db <- + if exists_settings_file + then readFromSettingsFile settingsFile getGlobalPackageDb + else pure (Left ("Settings file doesn't exist: " ++ settingsFile)) + + case erel_db of + Right rel_db -> return (dir, dir rel_db) + -- If the version of GHC doesn't have this field or the settings file + -- doesn't exist for some reason, look in the libdir. + Left err -> do + r <- lookForPackageDBIn dir + case r of + Nothing -> die (unlines [err, ("Fallback: Can't find package database in " ++ dir)]) + Just path -> return (dir, path) + fs -> do + -- The value of the $topdir variable used in some package descriptions + -- Note that the way we calculate this is slightly different to how it + -- is done in ghc itself. We rely on the convention that the global + -- package db lives in ghc's libdir. + let pkg_db = last fs + top_dir <- absolutePath (takeDirectory pkg_db) + return (top_dir, pkg_db) let no_user_db = FlagNoUserDb `elem` my_flags @@ -641,16 +670,11 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do warn $ "WARNING: settings file doesn't exist " ++ show settingsFile warn "cannot know target platform so guessing target == host (native compiler)." pure hostPlatformArchOS - True -> do - settingsStr <- readFile settingsFile - mySettings <- case maybeReadFuzzy settingsStr of - Just s -> pure $ Map.fromList s - -- It's excusable to not have a settings file (for now at - -- least) but completely inexcusable to have a malformed one. - Nothing -> die $ "Can't parse settings file " ++ show settingsFile - case getTargetArchOS settingsFile mySettings of - Right archOS -> pure archOS + True -> + readFromSettingsFile settingsFile getTargetArchOS >>= \case + Right v -> pure v Left e -> die e + let subdir = uniqueSubdir targetArchOS getFirstSuccess :: [IO a] -> IO (Maybe a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/31bf85ee49fe2ca0b17eaee0774e395f017a9373...4c8f179405394e9961b2a7c148f0c650dd24e1e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/31bf85ee49fe2ca0b17eaee0774e395f017a9373...4c8f179405394e9961b2a7c148f0c650dd24e1e3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:50:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:50:07 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Remove unused ghc-internal module "GHC.Internal.Constants" Message-ID: <65f9de5f7d305_2621dc113e49943319d0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/StgToJS/Types.hs - compiler/GHC/Tc/Errors/Hole/Plugin.hs-boot - compiler/GHC/Tc/Types/LclEnv.hs-boot - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Types/Id.hs-boot - compiler/GHC/Types/Var.hs-boot - compiler/GHC/Utils/Containers/Internal/StrictPair.hs - compiler/ghc.cabal.in - libraries/base/src/Data/Functor/Product.hs - libraries/base/src/Data/Functor/Sum.hs - libraries/base/src/Data/Kind.hs - libraries/base/src/GHC/ConsoleHandler.hs - libraries/base/src/GHC/Constants.hs - libraries/base/src/GHC/IO/Encoding/CodePage.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c8f179405394e9961b2a7c148f0c650dd24e1e3...b56d2761274ca5cd8ed35e5f348f7d6fe1dcd45d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c8f179405394e9961b2a7c148f0c650dd24e1e3...b56d2761274ca5cd8ed35e5f348f7d6fe1dcd45d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:51:20 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:51:20 -0400 Subject: [Git][ghc/ghc][master] Eliminate thunk in 'IfaceTyCon' Message-ID: <65f9dea8238ef_2621dc118f78143379b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 1 changed file: - compiler/GHC/Iface/Type.hs Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -93,6 +93,7 @@ import {-# SOURCE #-} GHC.Tc.Utils.TcType ( isMetaTyVar, isTyConableTyVar ) import Data.Maybe( isJust ) import qualified Data.Semigroup as Semi import Control.DeepSeq +import Control.Monad ((<$!>)) {- ************************************************************************ @@ -244,7 +245,18 @@ instance Monoid IfaceAppArgs where -- We have to tag them in order to pretty print them -- properly. data IfaceTyCon = IfaceTyCon { ifaceTyConName :: IfExtName - , ifaceTyConInfo :: IfaceTyConInfo } + , ifaceTyConInfo :: !IfaceTyConInfo + -- ^ We add a bang to this field as heap analysis + -- showed that this constructor retains a thunk to + -- a value that is usually shared. + -- + -- See !12200 for how this bang saved ~10% residency + -- when loading 'mi_extra_decls' on the agda + -- code base. + -- + -- See Note [Sharing IfaceTyConInfo] for why + -- sharing is so important for 'IfaceTyConInfo'. + } deriving (Eq) -- | The various types of TyCons which have special, built-in syntax. @@ -2050,7 +2062,13 @@ instance Binary IfaceTyConSort where instance Binary IfaceTyConInfo where put_ bh (IfaceTyConInfo i s) = put_ bh i >> put_ bh s - get bh = mkIfaceTyConInfo <$> get bh <*> get bh + get bh = mkIfaceTyConInfo <$!> get bh <*> get bh + -- We want to make sure, when reading from disk, as the most common case + -- is supposed to be shared. Any thunk adds an additional indirection + -- making sharing less useful. + -- + -- See !12200 for how this bang and the one in 'IfaceTyCon' reduces the + -- residency by ~10% when loading 'mi_extra_decls' from disk. instance Outputable IfaceTyLit where ppr = pprIfaceTyLit View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/349ea3302bd81daa896e0541b6b8e34a5da16b52 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/349ea3302bd81daa896e0541b6b8e34a5da16b52 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:52:04 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:52:04 -0400 Subject: [Git][ghc/ghc][master] Minor misc cleanups Message-ID: <65f9ded4db8f8_2621dc1191e3ec341095@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - 15 changed files: - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Stg/Utils.hs - compiler/GHC/StgToCmm/DataCon.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - docs/users_guide/using-warnings.rst - docs/users_guide/using.rst - testsuite/tests/programs/andy_cherry/test.T Changes: ===================================== compiler/GHC/Core/LateCC/OverloadedCalls.hs ===================================== @@ -107,7 +107,7 @@ overloadedCallsCC = let cc_name :: FastString cc_name = - fsLit $ maybe "" getOccString (exprName app) + maybe (fsLit "") getOccFS (exprName app) cc_srcspan <- fmap (Strict.fromMaybe (UnhelpfulSpan UnhelpfulNoLocationInfo)) $ ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -586,7 +586,7 @@ tryCastWorkerWrapper env bind_cxt old_bndr occ_info bndr (Cast rhs co) -- a DFunUnfolding in mk_worker_unfolding , not (exprIsTrivial rhs) -- Not x = y |> co; Wrinkle 1 , not (hasInlineUnfolding info) -- Not INLINE things: Wrinkle 4 - , isConcreteType (typeKind work_ty) -- Don't peel off a cast if doing so would + , typeHasFixedRuntimeRep work_ty -- Don't peel off a cast if doing so would -- lose the underlying runtime representation. -- See Note [Preserve RuntimeRep info in cast w/w] , not (isOpaquePragma (idInlinePragma old_bndr)) -- Not for OPAQUE bindings ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -617,7 +617,7 @@ extract_renamed_stuff mod_summary tc_result = do -- Validate HIE files when (gopt Opt_ValidateHie dflags) $ do - hs_env <- Hsc $ \e w -> return (e, w) + hs_env <- getHscEnv liftIO $ do -- Validate Scopes case validateScopes (hie_module hieFile) $ getAsts $ hie_asts hieFile of ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -526,10 +526,9 @@ dsExpr (HsStatic (_, whole_ty) expr@(L loc _)) = do , srcLocCol $ realSrcSpanStart r ) _ -> (0, 0) - srcLoc = mkCoreConApps (tupleDataCon Boxed 2) - [ Type intTy , Type intTy - , mkIntExprInt platform line, mkIntExprInt platform col - ] + srcLoc = mkCoreTup [ mkIntExprInt platform line + , mkIntExprInt platform col + ] putSrcSpanDsA loc $ return $ mkCoreApps (Var makeStaticId) [ Type ty, srcLoc, expr_ds ] ===================================== compiler/GHC/HsToCore/Foreign/Call.hs ===================================== @@ -172,8 +172,8 @@ unboxArg arg -- data ByteArray ix = ByteArray ix ix ByteArray# -- data MutableByteArray s ix = MutableByteArray ix ix (MutableByteArray# s) | is_product_type && - data_con_arity == 3 && - isJust maybe_arg3_tycon && + data_con_arity == 3, + Just arg3_tycon <- maybe_arg3_tycon, (arg3_tycon == byteArrayPrimTyCon || arg3_tycon == mutableByteArrayPrimTyCon) = do case_bndr <- newSysLocalDs ManyTy arg_ty @@ -196,7 +196,6 @@ unboxArg arg (_ : _ : data_con_arg_ty3 : _) = data_con_arg_tys maybe_arg3_tycon = tyConAppTyCon_maybe data_con_arg_ty3 - Just arg3_tycon = maybe_arg3_tycon boxResult :: Type -> DsM (Type, CoreExpr -> CoreExpr) ===================================== compiler/GHC/HsToCore/Foreign/JavaScript.hs ===================================== @@ -446,8 +446,8 @@ unboxJsArg arg -- data ByteArray ix = ByteArray ix ix ByteArray# -- data MutableByteArray s ix = MutableByteArray ix ix (MutableByteArray# s) | is_product_type && - data_con_arity == 3 && - isJust maybe_arg3_tycon && + data_con_arity == 3, + Just arg3_tycon <- maybe_arg3_tycon, (arg3_tycon == byteArrayPrimTyCon || arg3_tycon == mutableByteArrayPrimTyCon) = do case_bndr <- newSysLocalDs ManyTy arg_ty @@ -469,7 +469,6 @@ unboxJsArg arg (_ : _ : data_con_arg_ty3 : _) = data_con_arg_tys maybe_arg3_tycon = tyConAppTyCon_maybe (scaledThing data_con_arg_ty3) - Just arg3_tycon = maybe_arg3_tycon -- Takes the result of the user-level ccall: @@ -545,7 +544,7 @@ mk_alt return_result (Just prim_res_ty, wrap_result) -- The ccall returns a non-() value | isUnboxedTupleType prim_res_ty = do let - Just ls = fmap dropRuntimeRepArgs (tyConAppArgs_maybe prim_res_ty) + ls = dropRuntimeRepArgs (tyConAppArgs prim_res_ty) arity = 1 + length ls args_ids <- mapM (newSysLocalDs ManyTy) ls state_id <- newSysLocalDs ManyTy realWorldStatePrimTy @@ -612,15 +611,13 @@ jsResultWrapper result_ty | isPrimitiveType result_ty = return (Just result_ty, \e -> e) -- Base case 1c: boxed tuples - -- fixme: levity args? - | Just (tc, args) <- splitTyConApp_maybe result_ty + | Just (tc, args) <- maybe_tc_app , isBoxedTupleTyCon tc = do - let args' = dropRuntimeRepArgs args - innerTy = mkTupleTy Unboxed args' + let innerTy = mkTupleTy Unboxed args (inner_res, w) <- jsResultWrapper innerTy - matched <- mapM (newSysLocalDs ManyTy) args' + matched <- mapM (newSysLocalDs ManyTy) args let inner e = mkWildCase (w e) (unrestricted innerTy) result_ty - [ Alt (DataAlt (tupleDataCon Unboxed (length args'))) + [ Alt (DataAlt (tupleDataCon Unboxed (length args))) matched (mkCoreTup (map Var matched)) -- mkCoreConApps (tupleDataCon Boxed (length args)) (map Type args ++ map Var matched) ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -759,13 +759,11 @@ mapTupleIdBinders mapTupleIdBinders ids args0 rho0 = assert (not (any (null . stgArgRep) args0)) $ let - ids_unarised :: [(Id, [PrimRep])] - ids_unarised = map (\id -> (id, typePrimRep (idType id))) ids - - map_ids :: UnariseEnv -> [(Id, [PrimRep])] -> [StgArg] -> UnariseEnv + map_ids :: UnariseEnv -> [Id] -> [StgArg] -> UnariseEnv map_ids rho [] _ = rho - map_ids rho ((x, x_reps) : xs) args = + map_ids rho (x : xs) args = let + x_reps = typePrimRep (idType x) x_arity = length x_reps (x_args, args') = assert (args `lengthAtLeast` x_arity) @@ -780,7 +778,7 @@ mapTupleIdBinders ids args0 rho0 in map_ids rho' xs args' in - map_ids rho0 ids_unarised args0 + map_ids rho0 ids args0 mapSumIdBinders :: InId -- Binder (in the case alternative). @@ -1094,7 +1092,7 @@ unariseConArg _ arg@(StgLitArg lit) | Just as <- unariseLiteral_maybe lit = as | otherwise - = assert (not (isZeroBitTy (literalType lit))) -- We have no non-rubbish void literals + = assert (isNvUnaryRep (typePrimRep (literalType lit))) -- We have no non-rubbish non-unary literals [arg] unariseConArgs :: UnariseEnv -> [InStgArg] -> [OutStgArg] @@ -1110,10 +1108,10 @@ unariseConArgBinder = unariseArgBinder True -------------------------------------------------------------------------------- -mkIds :: FastString -> [UnaryType] -> UniqSM [Id] +mkIds :: FastString -> [NvUnaryType] -> UniqSM [Id] mkIds fs tys = mkUnarisedIds fs tys -mkId :: FastString -> UnaryType -> UniqSM Id +mkId :: FastString -> NvUnaryType -> UniqSM Id mkId s t = mkUnarisedId s t isMultiValBndr :: Id -> Bool ===================================== compiler/GHC/Stg/Utils.hs ===================================== @@ -30,10 +30,10 @@ import GHC.Utils.Panic import GHC.Data.FastString -mkUnarisedIds :: MonadUnique m => FastString -> [UnaryType] -> m [Id] +mkUnarisedIds :: MonadUnique m => FastString -> [NvUnaryType] -> m [Id] mkUnarisedIds fs tys = mapM (mkUnarisedId fs) tys -mkUnarisedId :: MonadUnique m => FastString -> UnaryType -> m Id +mkUnarisedId :: MonadUnique m => FastString -> NvUnaryType -> m Id mkUnarisedId s t = mkSysLocalM s ManyTy t -- Checks if id is a top level error application. ===================================== compiler/GHC/StgToCmm/DataCon.hs ===================================== @@ -335,7 +335,7 @@ precomputedStaticConInfo_maybe cfg binder con [arg] , platformOS platform /= OSMinGW32 || not (stgToCmmPIE cfg || stgToCmmPIC cfg) , Just val <- getClosurePayload arg , inRange val - = let intlike_lbl = mkCmmClosureLabel rtsUnitId (fsLit label) + = let intlike_lbl = mkCmmClosureLabel rtsUnitId label val_int = fromIntegral val :: Int offsetW = (val_int - fromIntegral min_static_range) * (fixedHdrSizeW profile + 1) -- INTLIKE/CHARLIKE closures consist of a header and one word payload @@ -366,8 +366,8 @@ precomputedStaticConInfo_maybe cfg binder con [arg] | charClosure = fromIntegral (pc_MAX_CHARLIKE constants) | otherwise = panic "precomputedStaticConInfo_maybe: Unknown closure type" label - | intClosure = "stg_INTLIKE" - | charClosure = "stg_CHARLIKE" + | intClosure = fsLit "stg_INTLIKE" + | charClosure = fsLit "stg_CHARLIKE" | otherwise = panic "precomputedStaticConInfo_maybe: Unknown closure type" precomputedStaticConInfo_maybe _ _ _ _ = Nothing ===================================== compiler/GHC/StgToJS/CodeGen.hs ===================================== @@ -297,13 +297,13 @@ genSetConInfo i d l {- srt -} = do emitClosureInfo $ ClosureInfo ei (CIRegs 0 [PtrV]) (mkFastString $ renderWithContext defaultSDocContext (ppr d)) - (fixedLayout $ map unaryTypeJSRep fields) + (fixedLayout fields) (CICon $ dataConTag d) sr return (mkDataEntry ei) where -- dataConRepArgTys sometimes returns unboxed tuples. is that a bug? - fields = concatMap (map primRepToType . typePrimRep . unwrapType . scaledThing) + fields = concatMap (typeJSRep . unwrapType . scaledThing) (dataConRepArgTys d) -- concatMap (map slotTyToType . repTypeSlots . repType) (dataConRepArgTys d) ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -491,7 +491,7 @@ optimizeFree offset ids = do -- this line goes wrong vvvvvvv let -- ids' = concat $ map (\i -> map (i,) [1..varSize . unaryTypeJSRep . idType $ i]) ids idSize :: Id -> Int - idSize i = sum $ map varSize (typeJSRep . idType $ i) + idSize i = typeSize $ idType i ids' = concatMap (\i -> map (i,) [1..idSize i]) ids -- 1..varSize] . unaryTypeJSRep . idType $ i]) (typeJSRep ids) l = length ids' ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2216,7 +2216,7 @@ tcAnonWildCardOcc is_extra (TcTyMode { mode_holes = Just (hole_lvl, hole_mode) } = do { kv_details <- newTauTvDetailsAtLevel hole_lvl ; kv_name <- newMetaTyVarName (fsLit "k") ; wc_details <- newTauTvDetailsAtLevel hole_lvl - ; wc_name <- newMetaTyVarName (fsLit wc_nm) + ; wc_name <- newMetaTyVarName wc_nm ; let kv = mkTcTyVar kv_name liftedTypeKind kv_details wc_kind = mkTyVarTy kv wc_tv = mkTcTyVar wc_name wc_kind wc_details @@ -2235,10 +2235,10 @@ tcAnonWildCardOcc is_extra (TcTyMode { mode_holes = Just (hole_lvl, hole_mode) } where -- See Note [Wildcard names] wc_nm = case hole_mode of - HM_Sig -> "w" - HM_FamPat -> "_" - HM_VTA -> "w" - HM_TyAppPat -> "_" + HM_Sig -> fsLit "w" + HM_FamPat -> fsLit "_" + HM_VTA -> fsLit "w" + HM_TyAppPat -> fsLit "_" emit_holes = case hole_mode of HM_Sig -> True ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -75,7 +75,6 @@ as ``-Wno-...`` for every individual warning in the group. * :ghc-flag:`-Woperator-whitespace-ext-conflict` * :ghc-flag:`-Wambiguous-fields` * :ghc-flag:`-Wunicode-bidirectional-format-characters` - * :ghc-flag:`-Wforall-identifier` * :ghc-flag:`-Wgadt-mono-local-binds` * :ghc-flag:`-Wtype-equality-requires-operators` * :ghc-flag:`-Wtype-equality-out-of-scope` ===================================== docs/users_guide/using.rst ===================================== @@ -799,7 +799,7 @@ There are two kinds of participants in the GHC Jobserver protocol: processes through the semaphore ⟨sem⟩ (specified as a string). Error if the semaphore doesn't exist. - Use of ``-jsem`` will override use of :ghc-flag:``-j[⟨n⟩]``, + Use of ``-jsem`` will override use of :ghc-flag:`-j[⟨n⟩]`, and vice-versa. .. _multi-home-units: ===================================== testsuite/tests/programs/andy_cherry/test.T ===================================== @@ -2,6 +2,5 @@ test('andy_cherry', [extra_files(['DataTypes.hs', 'GenUtils.hs', 'Interp.hs', 'InterpUtils.hs', 'Main.hs', 'Parser.hs', 'PrintTEX.hs', 'mygames.pgn']), when(fast(), skip), - expect_broken_for(23272, ['ghci-opt']), extra_run_opts('.')], multimod_compile_and_run, ['Main', '-cpp']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/594bee0bb1b5df2f0459acbd5fa69e44a6036e5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/594bee0bb1b5df2f0459acbd5fa69e44a6036e5f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:52:47 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:52:47 -0400 Subject: [Git][ghc/ghc][master] mk/relpath: Fix quoting Message-ID: <65f9deff83f4e_2621dc11b7c6d43441b1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 1 changed file: - mk/relpath.sh Changes: ===================================== mk/relpath.sh ===================================== @@ -15,7 +15,7 @@ target="$2" common_part="$src" result="" -while test "${target#$common_part}" = "${target}" ; do +while test "${target#"$common_part"}" = "${target}" ; do #echo "common_part is now : \"$common_part\"" #echo "result is now : \"$result\"" #echo "target#common_part : \"${target#$common_part}\"" @@ -39,7 +39,7 @@ fi # since we now have identified the common part, # compute the non-common part -forward_part="${target#$common_part}" +forward_part="${target#"$common_part"}" #echo "forward_part = \"$forward_part\"" if test -n "$result" && test -n "$forward_part" ; then View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf55a54b1aec7a533a4e409b01d08f4923348fa8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf55a54b1aec7a533a4e409b01d08f4923348fa8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 18:53:11 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 14:53:11 -0400 Subject: [Git][ghc/ghc][master] testsuite: Disable T21336a on wasm Message-ID: <65f9df17dd484_2621dc11daa244345832@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 1 changed file: - libraries/base/tests/IO/T21336/all.T Changes: ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -3,6 +3,10 @@ test('T21336a', [ unless(opsys('linux') or opsys('freebsd'), skip) , js_broken(22261) , fragile(22022) + # More than fragile, the test is failing consistently on wasm. See #22022. + # It would be nice to see if the test is NOT fragile on the other + # architectures, but right now I don't know how to check. + , when(arch('wasm32'), skip) , extra_files(['FinalizerExceptionHandler.hs']) ], compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ff883896baa238f82da60e5f168bc93cabe48e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ff883896baa238f82da60e5f168bc93cabe48e4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 19:22:49 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 15:22:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 18 commits: Escape multiple arguments in the settings file Message-ID: <65f9e609cd7de_2621dc12e9fd74353123@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 15eab26f by Ben Gamari at 2024-03-19T15:22:43-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - d74658f5 by Ben Gamari at 2024-03-19T15:22:43-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - 59568d0d by Ben Gamari at 2024-03-19T15:22:43-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 6989d36f by Ben Gamari at 2024-03-19T15:22:43-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - 564351bb by Ben Gamari at 2024-03-19T15:22:43-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - db221604 by Ben Gamari at 2024-03-19T15:22:43-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - add91e96 by Ben Gamari at 2024-03-19T15:22:43-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 3070cc6b by Zubin Duggal at 2024-03-19T15:22:43-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - 5e6f66e4 by Fendor at 2024-03-19T15:22:44-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Stg/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f753fd9d5a34f1f09166feea8ee898eedae3d51...5e6f66e49d4bb3339ead5500b0e4bde7485f6d46 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f753fd9d5a34f1f09166feea8ee898eedae3d51...5e6f66e49d4bb3339ead5500b0e4bde7485f6d46 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 20:39:35 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Tue, 19 Mar 2024 16:39:35 -0400 Subject: [Git][ghc/ghc][wip/T24150] 11 commits: Escape multiple arguments in the settings file Message-ID: <65f9f807e5eed_3017e11cd2c3c48136@gitlab.mail> Cheng Shao pushed to branch wip/T24150 at Glasgow Haskell Compiler / GHC Commits: 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 64f3c101 by Cheng Shao at 2024-03-19T20:39:25+00:00 rts: do not prefetch mark_closure bdescr in non-moving gc when ASSERTS_ENABLED This commit fixes a small an oversight in !12148: the prefetch logic in non-moving GC may trap in debug RTS because it calls Bdescr() for mark_closure which may be a static one. It's fine in non-debug RTS because even invalid bdescr addresses are prefetched, they will not cause segfaults, so this commit implements the most straightforward fix: don't prefetch mark_closure bdescr when assertions are enabled. - - - - - 8d857b78 by Teo Camarasu at 2024-03-19T20:39:25+00:00 rts: Allocate non-moving segments with megablocks Non-moving segments are 8 blocks long and need to be aligned. Previously we serviced allocations by grabbing 15 blocks, finding an aligned 8 block group in it and returning the rest. This proved to lead to high levels of fragmentation as a de-allocating a segment caused an 8 block gap to form, and this could not be reused for allocation. This patch introduces a segment allocator based around using entire megablocks to service segment allocations in bulk. When there are no free segments, we grab an entire megablock and fill it with aligned segments. As the megablock is free, we can easily guarantee alignment. Any unused segments are placed on a free list. It only makes sense to free segments in bulk when all of the segments in a megablock are freeable. After sweeping, we grab the free list, sort it, and find all groups of segments where they cover the megablock and free them. This introduces a period of time when free segments are not available to the mutator, but the risk that this would lead to excessive allocation is low. Right after sweep, we should have an abundance of partially full segments, and this pruning step is relatively quick. In implementing this we drop the logic that kept NONMOVING_MAX_FREE segments on the free list. See Note [Segment allocation strategy] Resolves #24150 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Stg/Utils.hs - compiler/GHC/StgToCmm/DataCon.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1757ae3489776d8178783d869dbdb5e91cbff626...8d857b78cebcd8dbe4b57dc1c879c66f6b1cc496 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1757ae3489776d8178783d869dbdb5e91cbff626...8d857b78cebcd8dbe4b57dc1c879c66f6b1cc496 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 21:18:21 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 19 Mar 2024 17:18:21 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65fa011def3cc_3017e12dc06e848726@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: bbd3447f by Apoorv Ingle at 2024-03-19T16:18:09-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -797,6 +788,8 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' , text "matchPmChecked" <+> ppr (isMatchContextPmChecked dflags origin ctxt)]) ; matches_nablas <- if isMatchContextPmChecked dflags origin ctxt + -- See Note [Expanding HsDo with XXExprGhcRn] Part 1. Wrinkle 1 for + -- pmc for pattern synonyms -- See Note [Long-distance information] in GHC.HsToCore.Pmc then addHsScrutTmCs (concat scrs) new_vars $ @@ -843,16 +836,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -356,25 +356,44 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash at runtime. -* That call of `fail` will (rightly) automatically generate a `MonadFail` constraint. So if the - pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate - a `MonadFail` constraint that isn't needed. - -* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. - When the pattern is irrefutable, we do not add the fail block. - This is important because the occurrence of `fail` means that the typechecker - will generate a `MonadFail` constraint, and the language spec says that - we should not do that for irrefutable patterns. - - Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate - a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) +* According to the language specification, when the pattern is irrefutable, + we should not add the `fail` alternative. This is important because + the occurrence of `fail` means that the typechecker will generate a `MonadFail` constraint, + and irrefutable patterns shouldn't need a fail alternative. + +* _Wrinkel 1_: Note that pattern synonyms count as refutable during type checking, + see `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`. they will hence generate a + `MonadFail` constraint and we will always be wrapped in a `fail`able-block. + + Consider a patten synonym declaration (testcase T24552): + + pattern MyJust :: a -> Maybe a + pattern MyJust x <- Just x where MyJust = Just + + and a `do`-block with the following bind and return statement + + do { MyJust x <- [Just ()] + ; return x + } + + The `do`-expansion will generate the expansion + + (>>=) ([MyJust x]) + (\case MyJust x -> return x -- (1) + _ -> fail "failable pattern .. " -- (2) + ) + + This code is compiler generated, so the associated `Origin` will be `Generated`. + It will be ignored by the pattern match check (using `isMatchContextPmChecked`). + This ensures we do not generate spurious redundant pattern match warnings, eg. due to line (2) above + `MyJust x` pattern can never be anything else; it is effectively irrefutable and evaluation + will always preceed with line (1). + See Note [Generated code and pattern-match checking] + See Note [Long-distance information in matchWrapper] * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we - attach to that constraint? It should be a good one, because it'll show up in error - messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the + attach to that constraint? When the `MonadFail` constraint can't be solved, it'll show up in error + messages and it needs to be a good location. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs) ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,16 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude hiding (Maybe, Nothing,Just) +import qualified Prelude as P + +data Maybe a = Nothing_ | Just_ a + +pattern Nothing :: Maybe a +pattern Nothing <- Nothing_ where Nothing = Nothing_ + +pattern Just :: a -> Maybe a +pattern Just x <- Just_ x where Just = Just_ + +main = print $ do Just x <- [Nothing, Just ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bbd3447f06a253a72c379018d2378bbaa413614b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bbd3447f06a253a72c379018d2378bbaa413614b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 22:44:54 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Tue, 19 Mar 2024 18:44:54 -0400 Subject: [Git][ghc/ghc][wip/T24150] rts: Allocate non-moving segments with megablocks Message-ID: <65fa1566eeb6_3017e153e64f8614a3@gitlab.mail> Cheng Shao pushed to branch wip/T24150 at Glasgow Haskell Compiler / GHC Commits: f89868f8 by Teo Camarasu at 2024-03-19T22:44:23+00:00 rts: Allocate non-moving segments with megablocks Non-moving segments are 8 blocks long and need to be aligned. Previously we serviced allocations by grabbing 15 blocks, finding an aligned 8 block group in it and returning the rest. This proved to lead to high levels of fragmentation as a de-allocating a segment caused an 8 block gap to form, and this could not be reused for allocation. This patch introduces a segment allocator based around using entire megablocks to service segment allocations in bulk. When there are no free segments, we grab an entire megablock and fill it with aligned segments. As the megablock is free, we can easily guarantee alignment. Any unused segments are placed on a free list. It only makes sense to free segments in bulk when all of the segments in a megablock are freeable. After sweeping, we grab the free list, sort it, and find all groups of segments where they cover the megablock and free them. This introduces a period of time when free segments are not available to the mutator, but the risk that this would lead to excessive allocation is low. Right after sweep, we should have an abundance of partially full segments, and this pruning step is relatively quick. In implementing this we drop the logic that kept NONMOVING_MAX_FREE segments on the free list. See Note [Segment allocation strategy] Resolves #24150 ------------------------- Metric Decrease: T18223 ------------------------- - - - - - 6 changed files: - rts/include/rts/storage/Block.h - rts/sm/BlockAlloc.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingAllocate.c - rts/sm/Sanity.c Changes: ===================================== rts/include/rts/storage/Block.h ===================================== @@ -323,6 +323,10 @@ bdescr *allocGroupOnNode(uint32_t node, W_ n); // bdescr *allocAlignedGroupOnNode(uint32_t node, W_ n); +// Allocate a MBlock worth of `n` block sized chunks aligned at `n`-block boundry. +// This returns a linked list of `bdescr` of length `BLOCKS_PER_MBLOCK / n`. +bdescr *allocMBlockAlignedGroupOnNode(uint32_t node, W_ n); + EXTERN_INLINE bdescr* allocBlockOnNode(uint32_t node); EXTERN_INLINE bdescr* allocBlockOnNode(uint32_t node) { ===================================== rts/sm/BlockAlloc.c ===================================== @@ -394,6 +394,53 @@ split_block_low (bdescr *bd, W_ n) } +// A variant of `split_block_high` where we keep both blocks. +// The returned block has size `n`, which is split off `bd`. +static bdescr * +split_block_high_no_free (bdescr *bd, W_ n) +{ + ASSERT(bd->blocks > n); + + bdescr* ret = bd + bd->blocks - n; // take n blocks off the end + ret->blocks = n; + ret->start = ret->free = bd->start + (bd->blocks - n)*BLOCK_SIZE_W; + ret->link = NULL; + + bd->blocks -= n; + + setup_tail(ret); + setup_tail(bd); + + return ret; +} + +// Allocate a MBlock worth of `n` block sized chunks aligned at `n`-block boundry. +// This returns a linked list of `bdescr` of length `BLOCKS_PER_MBLOCK / n`. +// We assume relevant locks are held. +bdescr * +allocMBlockAlignedGroupOnNode(uint32_t node, W_ n) +{ + bdescr *bd = allocGroupOnNode(node, BLOCKS_PER_MBLOCK); + + // Free unaligned blocks, as we can't use these. + ASSERT(bd->blocks == BLOCKS_PER_MBLOCK); + bd = split_block_high(bd, bd->blocks - bd->blocks % n); + ASSERT(bd->blocks % n == 0); + + bdescr *last = NULL; + bdescr *chunk = NULL; + // Chain the aligned groups together into a linked-list + while (bd->blocks > n) { + chunk = split_block_high_no_free(bd, n); + chunk->link = last; + last = chunk; + } + bd->link = chunk; + + return bd; +} + + /* Find a fitting block for the allocation request in the given free list. Returns: - not NULL: when an exact match was found in the free list. ===================================== rts/sm/NonMoving.c ===================================== @@ -248,6 +248,8 @@ static void nonmovingBumpEpoch(void) { * * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. * + * - Note [Segment allocation strategy] explains our segment allocation strategy. + * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage * collector for functional programs on multicore processors. SIGPLAN Not. 51, @@ -560,6 +562,21 @@ static void nonmovingBumpEpoch(void) { * * See #23340 * + * Note [Segment allocation strategy] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Non-moving segments must be aligned. In order, to efficiently service these + * allocations, we allocate segments in bulk + * We allocate an entire megablocks worth of segments at once. + * All unused segments are placed on the `nonmovingHeap.free` list. + * + * Symmetrically, we only de-allocate segments if all the segments in a megablock are free-able, ie, + * are on `nonmovingHeap.free`. We prune the free list in `nonmovingPruneFreeSegmentList`. + * Note that during pruning of the free list, free segments are not available for use by the + * mutator. This might lead to extra allocation of segments. But the risk is low as just after sweep + * there is usually a large amount of partially full segments, and pruning the free list is quite + * quick. + * + * See #24150 */ memcount nonmoving_segment_live_words = 0; @@ -578,19 +595,6 @@ static void nonmovingExitConcurrentWorker(void); // Add a segment to the free list. void nonmovingPushFreeSegment(struct NonmovingSegment *seg) { - // See Note [Live data accounting in nonmoving collector]. - if (RELAXED_LOAD(&nonmovingHeap.n_free) > NONMOVING_MAX_FREE) { - bdescr *bd = Bdescr((StgPtr) seg); - ACQUIRE_SM_LOCK; - ASSERT(oldest_gen->n_blocks >= bd->blocks); - ASSERT(oldest_gen->n_words >= BLOCK_SIZE_W * bd->blocks); - oldest_gen->n_blocks -= bd->blocks; - oldest_gen->n_words -= BLOCK_SIZE_W * bd->blocks; - freeGroup(bd); - RELEASE_SM_LOCK; - return; - } - SET_SEGMENT_STATE(seg, FREE); while (true) { struct NonmovingSegment *old = nonmovingHeap.free; @@ -601,6 +605,102 @@ void nonmovingPushFreeSegment(struct NonmovingSegment *seg) __sync_add_and_fetch(&nonmovingHeap.n_free, 1); } +static int +cmp_segment_ptr (const void *x, const void *y) +{ + const struct NonMovingSegment *p1 = *(const struct NonMovingSegment**)x; + const struct NonMovingSegment *p2 = *(const struct NonMovingSegment**)y; + if (p1 > p2) return +1; + else if (p1 < p2) return -1; + else return 0; +} + +// Prune the free list of segments that can be freed. +// Segments can be freed if all segments from a mblock are on the free list. +void nonmovingPruneFreeSegmentList(void) +{ + // Atomically grab the entire free list. + struct NonmovingSegment *free; + size_t length; + while (true) { + free = ACQUIRE_LOAD(&nonmovingHeap.free); + length = ACQUIRE_LOAD(&nonmovingHeap.n_free); + if (cas((StgVolatilePtr) &nonmovingHeap.free, + (StgWord) free, + (StgWord) NULL) == (StgWord) free) { + __sync_sub_and_fetch(&nonmovingHeap.n_free, length); + break; + } + // Save the current free list so the sanity checker can see these segments. + nonmovingHeap.saved_free = free; + } + + // Sort the free list by address. + struct NonmovingSegment **sorted = stgMallocBytes(sizeof(struct NonmovingSegment*) * length, "sorted free segment list"); + for(size_t i = 0; ilink; + } + // we should have reached the end of the free list + ASSERT(free == NULL); + + qsort(sorted, length, sizeof(struct NonmovingSegment*), cmp_segment_ptr); + + // Walk the sorted list and either: + // - free segments if the entire megablock is free + // - put it back on the free list + size_t new_length = 0; + size_t free_in_megablock = 0; + // iterate through segments by megablock + for(size_t i = 0; ilink = last; + new_length++; + } + } else { + // the megablock is free, so let's free all the segments. + ACQUIRE_SM_LOCK; + for(size_t j = 0; j < free_in_megablock;j++){ + bdescr *bd = Bdescr((StgPtr)sorted[i+j]); + freeGroup(bd); + } + RELEASE_SM_LOCK; + } + } + stgFree(sorted); + // If we have any segments left over, then put them back on the free list. + if(free) { + struct NonmovingSegment* tail = free; + while(tail->link) { + tail = tail->link; + } + while (true) { + struct NonmovingSegment* rest = ACQUIRE_LOAD(&nonmovingHeap.free); + tail->link = rest; + if (cas((StgVolatilePtr) &nonmovingHeap.free, + (StgWord) rest, + (StgWord) free) == (StgWord) rest) { + __sync_add_and_fetch(&nonmovingHeap.n_free, new_length); + break; + } + } + } + // See Note [Live data accounting in nonmoving collector]. + oldest_gen->n_blocks -= (length - new_length) * NONMOVING_SEGMENT_BLOCKS; + oldest_gen->n_words -= (length - new_length) * NONMOVING_SEGMENT_SIZE; + nonmovingHeap.saved_free = NULL; +} + void nonmovingInitAllocator(struct NonmovingAllocator* alloc, uint16_t block_size) { *alloc = (struct NonmovingAllocator) @@ -1216,6 +1316,7 @@ concurrent_marking: nonmovingSweepStableNameTable(); nonmovingSweep(); + nonmovingPruneFreeSegmentList(); ASSERT(nonmovingHeap.sweep_list == NULL); debugTrace(DEBUG_nonmoving_gc, "Finished sweeping."); traceConcSweepEnd(); ===================================== rts/sm/NonMoving.h ===================================== @@ -119,16 +119,16 @@ extern uint8_t nonmoving_alloca_dense_cnt; // NONMOVING_SEGMENT_SIZE (in bytes) extern uint8_t nonmoving_alloca_cnt; -// maximum number of free segments to hold on to -#define NONMOVING_MAX_FREE 16 - struct NonmovingHeap { struct NonmovingAllocator *allocators; - // free segment list. This is a cache where we keep up to - // NONMOVING_MAX_FREE segments to avoid thrashing the block allocator. + // free segment list. This is a cache where we keep segments + // belonging to megablocks that are only partially free. // Note that segments in this list are still counted towards // oldest_gen->n_blocks. struct NonmovingSegment *free; + // saved free segment list, so the sanity checker can + // see the segments while the free list is being pruned. + struct NonmovingSegment *saved_free; // how many segments in free segment list? accessed atomically. unsigned int n_free; @@ -172,6 +172,7 @@ void nonmovingCollect(StgWeak **dead_weaks, bool concurrent); void nonmovingPushFreeSegment(struct NonmovingSegment *seg); +void nonmovingPruneFreeSegmentList(void); INLINE_HEADER unsigned long log2_ceil(unsigned long x) { ===================================== rts/sm/NonMovingAllocate.c ===================================== @@ -65,19 +65,42 @@ static struct NonmovingSegment *nonmovingAllocSegment(enum AllocLockMode mode, u struct NonmovingSegment *ret; ret = nonmovingPopFreeSegment(); - // Nothing in the free list, allocate a new segment... + // Nothing in the free list, allocate a new segment. + // We allocate a full megablock, and add spare segments to our free list. if (ret == NULL) { acquire_alloc_lock(mode); - bdescr *bd = allocAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); - // See Note [Live data accounting in nonmoving collector]. - oldest_gen->n_blocks += bd->blocks; - oldest_gen->n_words += BLOCK_SIZE_W * bd->blocks; + // Another thread might have allocated while we were waiting for the lock. + ret = nonmovingPopFreeSegment(); + if (ret != NULL) { + release_alloc_lock(mode); + // Check alignment + ASSERT(((uintptr_t)ret % NONMOVING_SEGMENT_SIZE) == 0); + return ret; + } + + bdescr *bd = allocMBlockAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); release_alloc_lock(mode); - for (StgWord32 i = 0; i < bd->blocks; ++i) { + W_ alloc_blocks = BLOCKS_PER_MBLOCK - (BLOCKS_PER_MBLOCK % NONMOVING_SEGMENT_BLOCKS); + + // See Note [Live data accounting in nonmoving collector]. + oldest_gen->n_blocks += alloc_blocks; + oldest_gen->n_words += BLOCK_SIZE_W * alloc_blocks; + + for (StgWord32 i = 0; i < alloc_blocks; ++i) { initBdescr(&bd[i], oldest_gen, oldest_gen); bd[i].flags = BF_NONMOVING; } + + // Push all but the last segment to the free segment list. + while(bd->link) { + bdescr *next_bd = bd->link; + bd->link = NULL; + nonmovingPushFreeSegment((struct NonmovingSegment *)bd->start); + bd = next_bd; + } + + // Use the last segment to service the allocation. ret = (struct NonmovingSegment *)bd->start; } ===================================== rts/sm/Sanity.c ===================================== @@ -1238,6 +1238,7 @@ countNonMovingHeap(struct NonmovingHeap *heap) } ret += countNonMovingSegments(heap->sweep_list); ret += countNonMovingSegments(heap->free); + ret += countNonMovingSegments(heap->saved_free); return ret; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f89868f8e954311ae3aeded02db8bbe54ada84a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f89868f8e954311ae3aeded02db8bbe54ada84a2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 19 23:33:20 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 19:33:20 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: hadrian/bindist: Eliminate extraneous `dirname` invocation Message-ID: <65fa20bf9704_3017e168745b4720bb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 064e1b66 by Ben Gamari at 2024-03-19T19:33:03-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - fb774956 by Ben Gamari at 2024-03-19T19:33:03-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - 3d23f491 by Ben Gamari at 2024-03-19T19:33:03-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 83e1893b by Ben Gamari at 2024-03-19T19:33:03-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - 3f7f860c by Ben Gamari at 2024-03-19T19:33:04-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 879fa724 by Ben Gamari at 2024-03-19T19:33:04-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - e59f4c16 by Ben Gamari at 2024-03-19T19:33:04-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - aef64c4b by Zubin Duggal at 2024-03-19T19:33:04-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - ed7b3d68 by Fendor at 2024-03-19T19:33:05-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 7 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Iface/Type.hs - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs - m4/fp_settings.m4 Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -36,6 +36,7 @@ import os import yaml import gitlab from urllib.request import urlopen +from urllib.parse import urlparse import hashlib import sys import json @@ -80,7 +81,7 @@ source_artifact = Artifact('source-tarball' test_artifact = Artifact('source-tarball' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' - , 'ghc-{version}' ) + , 'ghc-{version}/testsuite' ) def debian(arch, n): return linux_platform(arch, "{arch}-linux-deb{n}".format(arch=arch, n=n)) @@ -156,13 +157,18 @@ def mk_one_metadata(release_mode, version, job_map, artifact): eprint(f"Bindist URL: {url}") eprint(f"Download URL: {final_url}") - #Download and hash from the release pipeline, this must not change anyway during upload. + # Download and hash from the release pipeline, this must not change anyway during upload. h = download_and_hash(url) res = { "dlUri": final_url , "dlSubdir": artifact.subdir.format(version=version) - , "dlOutput": artifact.output_name.format(version=version) , "dlHash" : h } + + # Only add dlOutput if it is inconsistent with the filename inferred from the URL + output = artifact.output_name.format(version=version) + if Path(urlparse(final_url).path).name != output: + res["dlOutput"] = output + eprint(res) return res ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -9,21 +9,22 @@ usage : %.gz : %.xz echo "[xz->gz] $< to $@..." - xz -c $< | gzip -c > $@ + xz -cd $< | gzip -c > $@ %.bz2 : %.xz echo "[xz->bz2] $< to $@..." - xz -c $< | bzip2 -c > $@ + xz -cd $< | bzip2 -c > $@ %.lz : %.xz echo "[xz->lz] $< to $@..." - xz -c $< | lzip -c > $@ + xz -cd $< | lzip -c > $@ %.zip : %.tar.xz echo "[tarxz->zip] $< to $@..." - tmp="$(mktemp tmp.XXX)" && \ + tmp="$$(mktemp tmp.XXX)" && \ tar -C "$$tmp" -xf $< && \ cd "$$tmp" && \ zip -9 -r $@ * && \ + cd .. && \ rm -R "$$tmp" ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -145,7 +145,7 @@ function purge_all() { curl -X PURGE http://downloads.haskell.org/~ghc/$dir curl -X PURGE http://downloads.haskell.org/~ghc/$dir/ for i in *; do - purge_file $i + purge_file "$i" done } @@ -158,43 +158,14 @@ function purge_file() { ) for dir in ${dirs[@]}; do - curl -X PURGE http://downloads.haskell.org/$dir/$i - curl -X PURGE http://downloads.haskell.org/$dir/$i/ - curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + curl -X PURGE http://downloads.haskell.org/$dir/$1 + curl -X PURGE http://downloads.haskell.org/$dir/$1/ + curl -X PURGE http://downloads.haskell.org/$dir/$1/docs/ done } function prepare_docs() { echo "THIS COMMAND IS DEPRECATED, THE DOCS FOLDER SHOULD BE PREPARED BY THE FETCH SCRIPT" - local tmp - rm -Rf docs - if [ -z "$GHC_TREE" ]; then - tmp="$(mktemp -d)" - tar -xf "ghc-$ver-src.tar.xz" -C "$tmp" - GHC_TREE="$tmp/ghc-$ver" - fi - mkdocs="$GHC_TREE/distrib/mkDocs/mkDocs" - if [ ! -e "$mkdocs" ]; then - echo "Couldn't find GHC mkDocs at $mkdocs." - echo "Perhaps you need to override GHC_TREE?" - rm -Rf "$tmp" - exit 1 - fi - windows_bindist="$(ls ghc-$ver-x86_64-unknown-mingw32.tar.xz | head -n1)" - linux_bindist="$(ls ghc-$ver-x86_64-deb9-linux.tar.xz | head -n1)" - echo "Windows bindist: $windows_bindist" - echo "Linux bindist: $linux_bindist" - $ENTER_FHS_ENV $mkdocs $linux_bindist $windows_bindist - if [ -d "$tmp" ]; then rm -Rf "$tmp"; fi - - mkdir -p docs/html - tar -Jxf "$linux_bindist" - cp -R "ghc-$ver/docs/users_guide/build-html/users_guide docs/html/users_guide" - #cp -R ghc-$ver/utils/haddock/doc/haddock docs/html/haddock - rm -R "ghc-$ver" - - tar -Jxf docs/libraries.html.tar.xz -C docs/html - mv docs/index.html docs/html } function recompress() { @@ -213,7 +184,7 @@ function recompress() { needed+=( "$(basename $i .tar.xz).zip" ) done - recompress-all -l ${needed[@]} + recompress-all -j10 ${needed[@]} } function upload_docs() { ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -728,6 +728,12 @@ ifaceVisAppArgsLength = go 0 | isVisibleForAllTyFlag argf = go (n+1) rest | otherwise = go n rest +ifaceAppArgsLength :: IfaceAppArgs -> Int +ifaceAppArgsLength = go 0 + where + go !n IA_Nil = n + go !n (IA_Arg _ _ ts) = go (n + 1) ts + {- Note [Suppressing invisible arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2090,21 +2096,27 @@ instance Binary IfaceTyLit where _ -> panic ("get IfaceTyLit " ++ show tag) instance Binary IfaceAppArgs where - put_ bh tk = - case tk of - IA_Arg t a ts -> putByte bh 0 >> put_ bh t >> put_ bh a >> put_ bh ts - IA_Nil -> putByte bh 1 + put_ bh tk = do + -- Int is variable length encoded so only + -- one byte for small lists. + put_ bh (ifaceAppArgsLength tk) + go tk + where + go IA_Nil = pure () + go (IA_Arg a b t) = do + put_ bh a + put_ bh b + go t - get bh = - do c <- getByte bh - case c of - 0 -> do - t <- get bh - a <- get bh - ts <- get bh - return $! IA_Arg t a ts - 1 -> return IA_Nil - _ -> panic ("get IfaceAppArgs " ++ show c) + get bh = do + n <- get bh :: IO Int + go n + where + go 0 = return IA_Nil + go c = do + a <- get bh + b <- get bh + IA_Arg a b <$> go (c - 1) ------------------- ===================================== hadrian/bindist/Makefile ===================================== @@ -176,18 +176,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" ; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" ===================================== m4/fp_settings.m4 ===================================== @@ -44,7 +44,7 @@ dnl ghc-toolchain. AC_DEFUN([SUBST_TOOLDIR], [ dnl and Note [How we configure the bundled windows toolchain] -set -- "$(echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g')" + $1=`echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'` ]) # FP_SETTINGS View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e6f66e49d4bb3339ead5500b0e4bde7485f6d46...ed7b3d680f08d593ebfcd3f361a533c86dbe6e81 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e6f66e49d4bb3339ead5500b0e4bde7485f6d46...ed7b3d680f08d593ebfcd3f361a533c86dbe6e81 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 02:33:47 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 22:33:47 -0400 Subject: [Git][ghc/ghc][master] 7 commits: hadrian/bindist: Eliminate extraneous `dirname` invocation Message-ID: <65fa4b0b147e8_10f5b72db76886262c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 5 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -36,6 +36,7 @@ import os import yaml import gitlab from urllib.request import urlopen +from urllib.parse import urlparse import hashlib import sys import json @@ -80,7 +81,7 @@ source_artifact = Artifact('source-tarball' test_artifact = Artifact('source-tarball' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' - , 'ghc-{version}' ) + , 'ghc-{version}/testsuite' ) def debian(arch, n): return linux_platform(arch, "{arch}-linux-deb{n}".format(arch=arch, n=n)) @@ -156,13 +157,18 @@ def mk_one_metadata(release_mode, version, job_map, artifact): eprint(f"Bindist URL: {url}") eprint(f"Download URL: {final_url}") - #Download and hash from the release pipeline, this must not change anyway during upload. + # Download and hash from the release pipeline, this must not change anyway during upload. h = download_and_hash(url) res = { "dlUri": final_url , "dlSubdir": artifact.subdir.format(version=version) - , "dlOutput": artifact.output_name.format(version=version) , "dlHash" : h } + + # Only add dlOutput if it is inconsistent with the filename inferred from the URL + output = artifact.output_name.format(version=version) + if Path(urlparse(final_url).path).name != output: + res["dlOutput"] = output + eprint(res) return res ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -9,21 +9,22 @@ usage : %.gz : %.xz echo "[xz->gz] $< to $@..." - xz -c $< | gzip -c > $@ + xz -cd $< | gzip -c > $@ %.bz2 : %.xz echo "[xz->bz2] $< to $@..." - xz -c $< | bzip2 -c > $@ + xz -cd $< | bzip2 -c > $@ %.lz : %.xz echo "[xz->lz] $< to $@..." - xz -c $< | lzip -c > $@ + xz -cd $< | lzip -c > $@ %.zip : %.tar.xz echo "[tarxz->zip] $< to $@..." - tmp="$(mktemp tmp.XXX)" && \ + tmp="$$(mktemp tmp.XXX)" && \ tar -C "$$tmp" -xf $< && \ cd "$$tmp" && \ zip -9 -r $@ * && \ + cd .. && \ rm -R "$$tmp" ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -145,7 +145,7 @@ function purge_all() { curl -X PURGE http://downloads.haskell.org/~ghc/$dir curl -X PURGE http://downloads.haskell.org/~ghc/$dir/ for i in *; do - purge_file $i + purge_file "$i" done } @@ -158,43 +158,14 @@ function purge_file() { ) for dir in ${dirs[@]}; do - curl -X PURGE http://downloads.haskell.org/$dir/$i - curl -X PURGE http://downloads.haskell.org/$dir/$i/ - curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + curl -X PURGE http://downloads.haskell.org/$dir/$1 + curl -X PURGE http://downloads.haskell.org/$dir/$1/ + curl -X PURGE http://downloads.haskell.org/$dir/$1/docs/ done } function prepare_docs() { echo "THIS COMMAND IS DEPRECATED, THE DOCS FOLDER SHOULD BE PREPARED BY THE FETCH SCRIPT" - local tmp - rm -Rf docs - if [ -z "$GHC_TREE" ]; then - tmp="$(mktemp -d)" - tar -xf "ghc-$ver-src.tar.xz" -C "$tmp" - GHC_TREE="$tmp/ghc-$ver" - fi - mkdocs="$GHC_TREE/distrib/mkDocs/mkDocs" - if [ ! -e "$mkdocs" ]; then - echo "Couldn't find GHC mkDocs at $mkdocs." - echo "Perhaps you need to override GHC_TREE?" - rm -Rf "$tmp" - exit 1 - fi - windows_bindist="$(ls ghc-$ver-x86_64-unknown-mingw32.tar.xz | head -n1)" - linux_bindist="$(ls ghc-$ver-x86_64-deb9-linux.tar.xz | head -n1)" - echo "Windows bindist: $windows_bindist" - echo "Linux bindist: $linux_bindist" - $ENTER_FHS_ENV $mkdocs $linux_bindist $windows_bindist - if [ -d "$tmp" ]; then rm -Rf "$tmp"; fi - - mkdir -p docs/html - tar -Jxf "$linux_bindist" - cp -R "ghc-$ver/docs/users_guide/build-html/users_guide docs/html/users_guide" - #cp -R ghc-$ver/utils/haddock/doc/haddock docs/html/haddock - rm -R "ghc-$ver" - - tar -Jxf docs/libraries.html.tar.xz -C docs/html - mv docs/index.html docs/html } function recompress() { @@ -213,7 +184,7 @@ function recompress() { needed+=( "$(basename $i .tar.xz).zip" ) done - recompress-all -l ${needed[@]} + recompress-all -j10 ${needed[@]} } function upload_docs() { ===================================== hadrian/bindist/Makefile ===================================== @@ -176,18 +176,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" ; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ff883896baa238f82da60e5f168bc93cabe48e4...6d398066b6084a971248da8ce37bc40c53a83525 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ff883896baa238f82da60e5f168bc93cabe48e4...6d398066b6084a971248da8ce37bc40c53a83525 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 02:34:20 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 22:34:20 -0400 Subject: [Git][ghc/ghc][master] Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" Message-ID: <65fa4b2c46a16_10f5b72f6e9a4670db@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - 1 changed file: - m4/fp_settings.m4 Changes: ===================================== m4/fp_settings.m4 ===================================== @@ -44,7 +44,7 @@ dnl ghc-toolchain. AC_DEFUN([SUBST_TOOLDIR], [ dnl and Note [How we configure the bundled windows toolchain] -set -- "$(echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g')" + $1=`echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'` ]) # FP_SETTINGS View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/576f8b7ec292382aaa47fceab504b5abf4cc1f8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/576f8b7ec292382aaa47fceab504b5abf4cc1f8a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 02:34:56 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 19 Mar 2024 22:34:56 -0400 Subject: [Git][ghc/ghc][master] Compact serialisation of IfaceAppArgs Message-ID: <65fa4b50bfbc6_10f5b7312ec30700e2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 1 changed file: - compiler/GHC/Iface/Type.hs Changes: ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -728,6 +728,12 @@ ifaceVisAppArgsLength = go 0 | isVisibleForAllTyFlag argf = go (n+1) rest | otherwise = go n rest +ifaceAppArgsLength :: IfaceAppArgs -> Int +ifaceAppArgsLength = go 0 + where + go !n IA_Nil = n + go !n (IA_Arg _ _ ts) = go (n + 1) ts + {- Note [Suppressing invisible arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2090,21 +2096,27 @@ instance Binary IfaceTyLit where _ -> panic ("get IfaceTyLit " ++ show tag) instance Binary IfaceAppArgs where - put_ bh tk = - case tk of - IA_Arg t a ts -> putByte bh 0 >> put_ bh t >> put_ bh a >> put_ bh ts - IA_Nil -> putByte bh 1 + put_ bh tk = do + -- Int is variable length encoded so only + -- one byte for small lists. + put_ bh (ifaceAppArgsLength tk) + go tk + where + go IA_Nil = pure () + go (IA_Arg a b t) = do + put_ bh a + put_ bh b + go t - get bh = - do c <- getByte bh - case c of - 0 -> do - t <- get bh - a <- get bh - ts <- get bh - return $! IA_Arg t a ts - 1 -> return IA_Nil - _ -> panic ("get IfaceAppArgs " ++ show c) + get bh = do + n <- get bh :: IO Int + go n + where + go 0 = return IA_Nil + go c = do + a <- get bh + b <- get bh + IA_Arg a b <$> go (c - 1) ------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdfe6e01f113dbed9df6703c97207c02fc60303b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdfe6e01f113dbed9df6703c97207c02fc60303b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 08:23:59 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 20 Mar 2024 04:23:59 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24553 Message-ID: <65fa9d1fcbeaa_2731c0618ece0369a6@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24553 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24553 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 08:59:30 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 20 Mar 2024 04:59:30 -0400 Subject: [Git][ghc/ghc][wip/T24553] Print more info about kinds in error messages Message-ID: <65faa572e775c_2731c07474af84711e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: 03f78c74 by Simon Peyton Jones at 2024-03-20T08:59:14+00:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 9 changed files: - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Utils/TcType.hs - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -177,6 +177,13 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 && (vis_only || go env (varType tv1) (varType tv2)) && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- If we have (forall a. ty1 ~ Maybe a) then respond (surprisingly) + -- with True; that result makes GHC print the type with all foralls and + -- kinds. See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy {}) _ | vis_only = True + go _ _ (ForAllTy {})| vis_only = True + -- Make sure we handle all FunTy cases since falling through to the -- AppTy case means that tcSplitAppTyNoView_maybe may see an unzonked -- kind variable, which causes things to blow up. ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,15 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitForalls = True + , sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,59 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = tcEqTypeVis ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by `GHC.Core.TyCo.Compare.tcEqTypeVis` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Display foralls: sdocPrintExplicitForalls + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6088,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6171,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6433,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6457,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03f78c7406907cc4f7fa302070e5d19b5033aa9c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03f78c7406907cc4f7fa302070e5d19b5033aa9c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 09:40:23 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 20 Mar 2024 05:40:23 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Add created interface sharing Message-ID: <65faaf07271cd_2731c086be2cc64557@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: 0974da17 by Matthew Pickering at 2024-03-20T09:40:10+00:00 Add created interface sharing - - - - - 4 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -160,7 +160,7 @@ import GHC.JS.Syntax import GHC.IfaceToCore ( typecheckIface, typecheckWholeCoreBindings ) -import GHC.Iface.Load ( ifaceStats, writeIface ) +import GHC.Iface.Load ( ifaceStats, writeIface , pprModIface ) import GHC.Iface.Make import GHC.Iface.Recomp import GHC.Iface.Tidy @@ -168,6 +168,8 @@ import GHC.Iface.Ext.Ast ( mkHieFile ) import GHC.Iface.Ext.Types ( getAsts, hie_asts, hie_module ) import GHC.Iface.Ext.Binary ( readHieFile, writeHieFile , hie_file_result) import GHC.Iface.Ext.Debug ( diffFile, validateScopes ) +import GHC.Iface.Binary +import GHC.Utils.Binary import GHC.Core import GHC.Core.Lint.Interactive ( interactiveInScope ) @@ -239,7 +241,7 @@ import GHC.Types.IPE import GHC.Types.SourceFile import GHC.Types.SrcLoc import GHC.Types.Name -import GHC.Types.Name.Cache ( initNameCache ) +import GHC.Types.Name.Cache ( initNameCache, NameCache ) import GHC.Types.Name.Reader import GHC.Types.Name.Ppr import GHC.Types.TyThing @@ -962,12 +964,25 @@ loadByteCode iface mod_sum = do -- Compilers -------------------------------------------------------------- +shareIface :: NameCache -> ModIface -> IO ModIface +shareIface nc mi = do + bh <- openBinMem (1024 * 1024) + -- Todo, not quite right (See ext fields etc) + start <- tellBin @() bh + putWithUserData QuietBinIFace bh mi + seekBin bh start + res <- getWithUserData nc bh + let resiface = res { mi_src_hash = mi_src_hash mi } + forceModIface resiface + return resiface + -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] -initModDetails :: HscEnv -> ModIface -> IO ModDetails -initModDetails hsc_env iface = - fixIO $ \details' -> do +initModDetails :: HscEnv -> ModIface -> IO (ModIface, ModDetails) +initModDetails hsc_env raw_iface = do + iface <- shareIface (hsc_NC hsc_env) raw_iface + d <- fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) let !hsc_env' = hscUpdateHPT act hsc_env @@ -976,6 +991,7 @@ initModDetails hsc_env iface = -- any further typechecking. It's much more useful -- in make mode, since this HMI will go into the HPT. genModDetails hsc_env' iface + return (iface, d) -- Hydrate any WholeCoreBindings linkables into BCOs initWholeCoreBindings :: HscEnv -> ModIface -> ModDetails -> Linkable -> IO Linkable @@ -987,16 +1003,16 @@ initWholeCoreBindings hsc_env mod_iface details (LM utc_time this_mod uls) = LM types_var <- newIORef (md_types details) let kv = knotVarsFromModuleEnv (mkModuleEnv [(this_mod, types_var)]) let hsc_env' = hscUpdateHPT act hsc_env { hsc_type_env_vars = kv } - core_binds <- initIfaceCheck (text "l") hsc_env' $ typecheckWholeCoreBindings types_var fi -- MP: The NoStubs here is only from (I think) the TH `qAddForeignFilePath` feature but it's a bit unclear what to do -- with these files, do we have to read and serialise the foreign file? I will leave it for now until someone -- reports a bug. - let cgi_guts = CgInteractiveGuts this_mod core_binds (typeEnvTyCons (md_types details)) NoStubs Nothing [] -- The bytecode generation itself is lazy because otherwise even when doing -- recompilation checking the bytecode will be generated (which slows things down a lot) -- the laziness is OK because generateByteCode just depends on things already loaded -- in the interface file. LoadedBCOs <$> (unsafeInterleaveIO $ do + core_binds <- initIfaceCheck (text "l") hsc_env' $ typecheckWholeCoreBindings types_var fi + let cgi_guts = CgInteractiveGuts this_mod core_binds (typeEnvTyCons (md_types details)) NoStubs Nothing [] trace_if (hsc_logger hsc_env) (text "Generating ByteCode for" <+> (ppr this_mod)) generateByteCode hsc_env cgi_guts (wcb_mod_location fi)) go ul = return ul ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -244,9 +244,9 @@ compileOne' mHscMessage let pipeline = hscPipeline pipe_env (setDumpPrefix pipe_env plugin_hsc_env, upd_summary, status) (iface, linkable) <- runPipeline (hsc_hooks plugin_hsc_env) pipeline -- See Note [ModDetails and --make mode] - details <- initModDetails plugin_hsc_env iface - linkable' <- traverse (initWholeCoreBindings plugin_hsc_env iface details) (homeMod_bytecode linkable) - return $! HomeModInfo iface details (linkable { homeMod_bytecode = linkable' }) + (shared_iface, details) <- initModDetails plugin_hsc_env iface + linkable' <- traverse (initWholeCoreBindings plugin_hsc_env shared_iface details) (homeMod_bytecode linkable) + return $! HomeModInfo shared_iface details (linkable { homeMod_bytecode = linkable' }) where lcl_dflags = ms_hspp_opts summary location = ms_location summary ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -4,7 +4,7 @@ -- (c) The University of Glasgow 2002-2006 -- -{-# OPTIONS_GHC -O0 -ddump-simpl -ddump-to-file #-} +{-# OPTIONS_GHC -O2 -ddump-simpl -ddump-to-file #-} -- We always optimise this, otherwise performance of a non-optimised -- compiler is severely affected ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -1267,6 +1267,7 @@ getGenericSymtab :: Binary a => SymbolTable a -> BinHandle -> IO a getGenericSymtab symtab bh = do i :: Word32 <- get bh + pprTraceM "getting" (ppr (bounds symtab, i)) return $! symtab ! fromIntegral i data SomeCache = forall a . SomeCache (TypeRep, CachedBinary a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0974da17b15d2b9dd4176148096e95ac24f3a8fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0974da17b15d2b9dd4176148096e95ac24f3a8fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 10:46:36 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 20 Mar 2024 06:46:36 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 11 commits: Add missing req_interp modifier to T18441fail3 and T18441fail19 Message-ID: <65fabe8ce3a8c_2731c0a3794c069540@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 12bd1735 by Matthew Pickering at 2023-12-22T14:04:09+00:00 Add missing req_interp modifier to T18441fail3 and T18441fail19 These tests require the interpreter but they were failing in a different way with the javascript backend because the interpreter was disabled and stderr is ignored by the test. - - - - - 2aa7ea0f by Matthew Pickering at 2023-12-22T14:51:49+00:00 Use explicit syntax rather than pure - - - - - 34679d87 by Matthew Pickering at 2023-12-22T14:51:49+00:00 ci: Fail when bindist configure fails when installing bindist It is better to fail earlier if the configure step fails rather than carrying on for a more obscure error message. - - - - - e0fdeb4b by Matthew Pickering at 2023-12-22T14:53:02+00:00 packaging: correctly propagate build/host/target to bindist configure script At the moment the host and target which we will produce a compiler for is fixed at the initial configure time. Therefore we need to persist the choice made at this time into the installation bindist as well so we look for the right tools, with the right prefixes at install time. In the future, we want to provide a bit more control about what kind of bindist we produce so the logic about what the host/target will have to be written by hadrian rather than persisted by the configure script. In particular with cross compilers we want to either build a normal stage 2 cross bindist or a stage 3 bindist, which creates a bindist which has a native compiler for the target platform. Fixes #21970 - - - - - fec155bc by Matthew Pickering at 2023-12-22T14:55:49+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - d6933f41 by Matthew Pickering at 2023-12-22T15:01:50+00:00 hadrian: Disable docs when cross compiling Before there were a variety of ad-hoc places where doc building was disabled when cross compiling. * Some CI jobs sets --docs=none in gen_ci.hs * Some CI jobs set --docs=none in .gitlab/ci.sh * There was some logic in hadrian to not need the ["docs"] target when making a bindist. Now the situation is simple: * If you are cross compiling then defaultDocsTargets is empty by default. In theory, there is no reason why we can't build documentation for cross compiler bindists, but this is left to future work to generalise the documentation building rules to allow this (#24289) - - - - - bdccba92 by Matthew Pickering at 2023-12-22T15:10:29+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - b2e1a14b by Matthew Pickering at 2023-12-22T15:10:32+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - c64ee583 by Matthew Pickering at 2023-12-22T15:10:32+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - ef4d45dc by Matthew Pickering at 2023-12-22T15:10:32+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - e8f17b14 by Matthew Pickering at 2023-12-22T15:45:41+00:00 Wrappers for stage2 cross - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/hadrian.cabal - + hadrian/src/BindistConfig.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Expression.hs - hadrian/src/Hadrian/Haskell/Hash.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Flavour.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04bc9786e169cb88ca4a15a9d28e1819b58ee7a8...e8f17b14cc2c957d1dccde6f4c076c861503110a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04bc9786e169cb88ca4a15a9d28e1819b58ee7a8...e8f17b14cc2c957d1dccde6f4c076c861503110a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 10:46:58 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 20 Mar 2024 06:46:58 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 374 commits: testsuite: mark jspace as fragile on i386. Message-ID: <65fabea28b4b2_2731c0a4b8cf0713df@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - ee865bd6 by Matthew Pickering at 2024-03-20T10:38:46+00:00 Add missing req_interp modifier to T18441fail3 and T18441fail19 These tests require the interpreter but they were failing in a different way with the javascript backend because the interpreter was disabled and stderr is ignored by the test. - - - - - ea7b9603 by Matthew Pickering at 2024-03-20T10:38:46+00:00 Use explicit syntax rather than pure - - - - - c7ed3545 by Matthew Pickering at 2024-03-20T10:38:46+00:00 ci: Fail when bindist configure fails when installing bindist It is better to fail earlier if the configure step fails rather than carrying on for a more obscure error message. - - - - - db747afa by Matthew Pickering at 2024-03-20T10:38:46+00:00 packaging: correctly propagate build/host/target to bindist configure script At the moment the host and target which we will produce a compiler for is fixed at the initial configure time. Therefore we need to persist the choice made at this time into the installation bindist as well so we look for the right tools, with the right prefixes at install time. In the future, we want to provide a bit more control about what kind of bindist we produce so the logic about what the host/target will have to be written by hadrian rather than persisted by the configure script. In particular with cross compilers we want to either build a normal stage 2 cross bindist or a stage 3 bindist, which creates a bindist which has a native compiler for the target platform. Fixes #21970 - - - - - a0222248 by Matthew Pickering at 2024-03-20T10:38:46+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - b2eda2ce by Matthew Pickering at 2024-03-20T10:38:46+00:00 hadrian: Disable docs when cross compiling Before there were a variety of ad-hoc places where doc building was disabled when cross compiling. * Some CI jobs sets --docs=none in gen_ci.hs * Some CI jobs set --docs=none in .gitlab/ci.sh * There was some logic in hadrian to not need the ["docs"] target when making a bindist. Now the situation is simple: * If you are cross compiling then defaultDocsTargets is empty by default. In theory, there is no reason why we can't build documentation for cross compiler bindists, but this is left to future work to generalise the documentation building rules to allow this (#24289) - - - - - 12c7ac3b by Matthew Pickering at 2024-03-20T10:45:13+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 New hadrian target: * `binary-dist-dir-cross`: Build a cross compiler bindist (compiler = stage 1, libraries = stage 2) ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 1a595f9b by Matthew Pickering at 2024-03-20T10:45:16+00:00 ci: Test cross bindists We remove the special logic for testing in-tree cross compilers and instead test cross compiler bindists, like we do for all other platforms. - - - - - 59fb4690 by Matthew Pickering at 2024-03-20T10:45:16+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 351cb581 by Matthew Pickering at 2024-03-20T10:45:16+00:00 ci: Introduce CROSS_STAGE variable In preparation for building and testing stage3 bindists we introduce the CROSS_STAGE variable which is used by a CI job to determine what kind of bindist the CI job should produce. At the moment we are only using CROSS_STAGE=2 but in the future we will have some jobs which set CROSS_STAGE=3 to produce native bindists for a target, but produced by a cross compiler, which can be tested on by another CI job on the native platform. CROSS_STAGE=2: Build a normal cross compiler bindist CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target - - - - - 645bd490 by Matthew Pickering at 2024-03-20T10:45:16+00:00 Split up system.config into host/target config files There were a number of settings which were not applied per-stage, for example if you specified `--ffi-include-dir` then that was applied to both host and target. Now this will just be passed when building the crosscompiler. The solution for now is to separate these two files into host/target and the host file contains very bare-bones . There isn't currently a way to specify with configure anything in the host file, so if you are building a cross-compiler and you need to do that, you have to modify the file yourself. - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8f17b14cc2c957d1dccde6f4c076c861503110a...645bd490cb3c367aae48fecc0929bbf51299097b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8f17b14cc2c957d1dccde6f4c076c861503110a...645bd490cb3c367aae48fecc0929bbf51299097b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 10:57:41 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 20 Mar 2024 06:57:41 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Remove traces and profiling Message-ID: <65fac12527de_2731c0ad5f8b876341@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: 2b8cbe10 by Matthew Pickering at 2024-03-20T10:57:32+00:00 Remove traces and profiling - - - - - 2 changed files: - compiler/GHC/Iface/Binary.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -215,10 +215,9 @@ getTables' name_cache bh = do -- bh_name2 = addDecoder (mkCache (Proxy :: Proxy IfaceTyCon) ifaceDecoder) bh_name - pprTraceM "getTables" empty ifaceSymTab2 <- Binary.forwardGet bh_name (getTable ifaceTypeCache bhRef bh_name) let ifaceDecoder2 = mkReader $ getGenericSymtab ifaceSymTab2 - let bh_type = addDecoder (mkCache (Proxy :: Proxy IfaceType) (pprTrace "forced" (text "f") ifaceDecoder2)) bh_name + let bh_type = addDecoder (mkCache (Proxy :: Proxy IfaceType) ifaceDecoder2) bh_name writeIORef bhRef bh_type return bh_type ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -206,9 +206,11 @@ data BinProf = BinProf { stack :: ![ProfKey], report :: IORef (Map.Map [ProfKey] initBinProf = BinProf <$> pure [StringKey "TOP"] <*> newIORef (Map.empty) addStack :: TypeRep -> BinProf -> BinProf +addStack _ bp = bp addStack s (BinProf ss i) = (BinProf (TypeableKey s:ss) i) recordSample :: Int -> BinProf -> IO () +recordSample _ _ = return () recordSample weight (BinProf ss i) = modifyIORef i (Map.insertWith (+) ss weight) -- XXX: should really store a "high water mark" for dumping out -- the binary data to a file. @@ -1231,7 +1233,6 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do case vs of [] -> return table_count todo -> do - print (map fst todo) mapM_ (\n -> lazyPut' serialiser bh n) (map snd vs) loop table_count snd <$> @@ -1245,7 +1246,7 @@ getGenericSymbolTable deserialiser bhRef bh = do forM_ [0..(sz-1)] $ \i -> do f <- lazyGet' (Just bhRef) deserialiser bh writeArray mut_arr i f - pprTraceM "gotten" (ppr sz) +-- pprTraceM "gotten" (ppr sz) unsafeFreeze mut_arr putGenericSymTab :: (Ord a, Binary a) => GenericSymbolTable a -> BinHandle -> a -> IO () @@ -1267,7 +1268,7 @@ getGenericSymtab :: Binary a => SymbolTable a -> BinHandle -> IO a getGenericSymtab symtab bh = do i :: Word32 <- get bh - pprTraceM "getting" (ppr (bounds symtab, i)) +-- pprTraceM "getting" (ppr (bounds symtab, i)) return $! symtab ! fromIntegral i data SomeCache = forall a . SomeCache (TypeRep, CachedBinary a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b8cbe10266f7ea9b25a544175ff4bae9afcc29d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b8cbe10266f7ea9b25a544175ff4bae9afcc29d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 12:29:01 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 20 Mar 2024 08:29:01 -0400 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65fad68d4b762_2731c0d73825c849de@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: 37bc734d by Zubin Duggal at 2024-03-20T17:58:50+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 5 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,20 +1714,20 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) @@ -1737,47 +1736,52 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] +checkHomeUnitsClosed ue home_id_set + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + extra_files(['genMultiComp','Setup.hs']), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/37bc734d4d25d54b096a042b2c676620059599bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/37bc734d4d25d54b096a042b2c676620059599bc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 12:42:42 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 20 Mar 2024 08:42:42 -0400 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65fad9c237f36_2731c0dcf1338873ad@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: 2033e86c by Zubin Duggal at 2024-03-20T18:12:32+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 5 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,20 +1714,20 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) @@ -1737,47 +1736,52 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] +checkHomeUnitsClosed ue home_id_set + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2033e86cc9c741cdf55b7921200e3b9820ab4229 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2033e86cc9c741cdf55b7921200e3b9820ab4229 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 12:44:21 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 20 Mar 2024 08:44:21 -0400 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65fada252c3f9_2731c0ddc782087933@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: 1014b7af by Zubin Duggal at 2024-03-20T18:14:07+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 6 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,20 +1714,20 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) @@ -1737,47 +1736,52 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] +checkHomeUnitsClosed ue home_id_set + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1014b7aff68b8beb3a86758e2333c0eb8c48f45c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1014b7aff68b8beb3a86758e2333c0eb8c48f45c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 12:51:48 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 20 Mar 2024 08:51:48 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy Message-ID: <65fadbe43faed_2731c0e11a450885a6@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 68888e40 by Andrei Borzenkov at 2024-03-20T16:51:31+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy - - - - - 9 changed files: - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/Language/Haskell/Syntax/Type.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout - + testsuite/tests/th/T24299.hs - + testsuite/tests/th/T24299.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -677,7 +677,7 @@ References: [2] 'rnSpliceExpr' [3] 'GHC.Tc.Gen.Splice.qAddModFinalizer' [4] 'GHC.Tc.Gen.Expr.tcExpr' ('HsSpliceE' ('HsSpliced' ...)) -[5] 'GHC.Tc.Gen.HsType.tc_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) +[5] 'GHC.Tc.Gen.HsType.tc_check_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) [6] 'GHC.Tc.Gen.Pat.tc_pat' ('SplicePat' ('HsSpliced' ...)) -} ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -609,7 +609,7 @@ tc_top_lhs_type tyki ctxt (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs <- pushLevelAndSolveEqualitiesX "tc_top_lhs_type" $ tcOuterTKBndrs skol_info hs_outer_bndrs $ do { kind <- newExpectedKind (expectedKindInCtxt ctxt) - ; tc_lhs_type (mkMode tyki) body kind } + ; tc_check_lhs_type (mkMode tyki) body kind } ; outer_bndrs <- scopedSortOuter outer_bndrs ; let outer_tv_bndrs = outerTyVarBndrs outer_bndrs @@ -704,7 +704,7 @@ tcHsTypeApp wc_ty kind -- We are looking at a user-written type, very like a -- signature so we want to solve its equalities right now bindNamedWildCardBinders sig_wcs $ \ _ -> - tc_lhs_type mode hs_ty kind + tc_check_lhs_type mode hs_ty kind -- We do not kind-generalize type applications: we just -- instantiate with exactly what the user says. @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -1002,15 +1002,6 @@ that *can* be kind-polymorphic, we implement just the "up" (functions with "infer" in their name) version, as we gain nothing by also implementing the "down" version. -Note [Future-proofing the type checker] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As discussed in Note [Bidirectional type checking], each HsType form is -handled in *either* tc_infer_hs_type *or* tc_hs_type. These functions -are mutually recursive, so that either one can work for any type former. -But, we want to make sure that our pattern-matches are complete. So, -we have a bunch of repetitive code just so that we get warnings if we're -missing any patterns. - -} ------------------------------------------ @@ -1022,74 +1013,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tc_hs_type mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1135,14 +1065,23 @@ substitution to each HsCoreTy and all is well: ------------------------------------------ tcLHsType :: LHsType GhcRn -> TcKind -> TcM TcType tcLHsType hs_ty exp_kind - = tc_lhs_type typeLevelMode hs_ty exp_kind + = tc_check_lhs_type typeLevelMode hs_ty exp_kind + +tc_check_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_check_lhs_type mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_check_hs_type mode ty exp_kind -tc_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_check_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +-- See Note [Bidirectional type checking] +tc_check_hs_type mode ty ek = tc_hs_type mode ty (Check ek) + +tc_lhs_type :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType tc_lhs_type mode (L span ty) exp_kind = setSrcSpanA span $ tc_hs_type mode ty exp_kind -tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +tc_hs_type :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType -- See Note [Bidirectional type checking] tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind @@ -1187,8 +1126,8 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] @@ -1204,72 +1143,47 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ; return (mkForAllTys tv_bndrs ty') } tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind - | null (unLoc ctxt) - = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind - = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } - - | otherwise - = do { ctxt' <- tc_hs_context mode ctxt + = do k <- expTypeToType exp_kind + tc_hs_qual_ty k + where + tc_hs_qual_ty kind + | null (unLoc ctxt) + = tc_check_lhs_type mode rn_ty kind - ; ek <- newOpenTypeKind -- The body kind (result of the function) can - -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + -- See Note [Body kind of a HsQualTy] + | isConstraintLikeKind kind + = do { ctxt' <- tc_hs_context mode ctxt + ; ty' <- tc_check_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } + | otherwise + = do { ctxt' <- tc_hs_context mode ctxt + + ; ek <- newOpenTypeKind -- The body kind (result of the function) can + -- be TYPE r, for any r, hence newOpenTypeKind + ; ty' <- tc_check_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpectedKind (unLoc rn_ty) res_ty + liftedTypeKind kind } --------- Lists, arrays, and tuples tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind - = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind + = do { tau_ty <- tc_check_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } - --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" - - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind +tc_hs_type mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys - ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) hs_tys arg_kinds ; let arg_reps = map kindRep arg_kinds arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples @@ -1277,13 +1191,15 @@ tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind -- The '[] case is handled in tc_infer_hs_type. -- See Note [Future-proofing the type checker]. | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] @@ -1292,54 +1208,122 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar - ; taus <- zipWithM (tc_lhs_type mode) tys ks + ; taus <- zipWithM (tc_check_lhs_type mode) tys ks ; let kind_con = tupleTyCon Boxed arity ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) - ; ty' <- tc_lhs_type mode ty liftedTypeKind + ; ty' <- tc_check_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tc_hs_type mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek +--------- Infer +tc_hs_type mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind + +tc_hs_type mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tc_hs_type:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_check_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tc_hs_type _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tc_hs_type tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * + + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind + +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty {- Note [Variable Specificity and Forall Visibility] @@ -1366,28 +1350,28 @@ Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in "GHC.Core.TyCo ------------------------------------------ tc_mult :: TcTyMode -> HsArrow GhcRn -> TcM Mult -tc_mult mode ty = tc_lhs_type mode (arrowToHsType ty) multiplicityTy +tc_mult mode ty = tc_check_lhs_type mode (arrowToHsType ty) multiplicityTy ------------------------------------------ -tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> TcKind +tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> ExpKind -> TcM TcType tc_fun_type mode mult ty1 ty2 exp_kind = case mode_tyki mode of TypeLevel -> do { traceTc "tc_fun_type" (ppr ty1 $$ ppr ty2) ; arg_k <- newOpenTypeKind ; res_k <- newOpenTypeKind - ; ty1' <- tc_lhs_type mode ty1 arg_k - ; ty2' <- tc_lhs_type mode ty2 res_k + ; ty1' <- tc_check_lhs_type mode ty1 arg_k + ; ty2' <- tc_check_lhs_type mode ty2 res_k ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } KindLevel -> -- no representation polymorphism in kinds. yet. - do { ty1' <- tc_lhs_type mode ty1 liftedTypeKind - ; ty2' <- tc_lhs_type mode ty2 liftedTypeKind + do { ty1' <- tc_check_lhs_type mode ty1 liftedTypeKind + ; ty2' <- tc_check_lhs_type mode ty2 liftedTypeKind ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } {- Note [Skolem escape and forall-types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1442,7 +1426,7 @@ tc_tuple rn_ty mode tup_sort tys exp_kind BoxedTuple -> return (replicate arity liftedTypeKind) UnboxedTuple -> replicateM arity newOpenTypeKind ConstraintTuple -> return (replicate arity constraintKind) - ; tau_tys <- zipWithM (tc_lhs_type mode) tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) tys arg_kinds ; finish_tuple rn_ty tup_sort tau_tys arg_kinds exp_kind } where arity = length tys @@ -1530,9 +1514,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1531,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -1656,7 +1644,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args ; arg_mode <- mkHoleMode KindLevel HM_VTA -- HM_VKA: see Note [Wildcards in visible kind application] ; ki_arg <- addErrCtxt (funAppCtxt orig_hs_ty hs_ki_arg n) $ - tc_lhs_type arg_mode hs_ki_arg exp_kind + tc_check_lhs_type arg_mode hs_ki_arg exp_kind ; traceTc "tcInferTyApps (vis kind app)" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder ki_arg @@ -1687,7 +1675,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args , ppr subst ]) ; let exp_kind = substTy subst $ piTyBinderType ki_binder ; arg' <- addErrCtxt (funAppCtxt orig_hs_ty arg n) $ - tc_lhs_type mode arg exp_kind + tc_check_lhs_type mode arg exp_kind ; traceTc "tcInferTyApps (vis normal app) 2" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder arg' ; go (n+1) fun' subst' inner_ki args } @@ -1975,6 +1963,19 @@ checkExpectedKind hs_ty ty act_kind exp_kind n_act_invis_bndrs = invisibleTyBndrCount act_kind n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + +-- tyr <- checkExpKind hs_ty ty (act_ki :: Kind) (exp_ki :: ExpKind) +-- requires that `ty` has kind `act_ki` +-- It checks that the actual kind `act_ki` matches the expected kind `exp_ki` +-- and returns `tyr`, a possibly-casted form of `ty`, that has precisely kind `exp_ki` +-- `hs_ty` is purely for error messages +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + --------------------------- tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] @@ -1988,7 +1989,7 @@ tc_hs_context :: TcTyMode -> LHsContext GhcRn -> TcM [PredType] tc_hs_context mode ctxt = mapM (tc_lhs_pred mode) (unLoc ctxt) tc_lhs_pred :: TcTyMode -> LHsType GhcRn -> TcM PredType -tc_lhs_pred mode pred = tc_lhs_type mode pred constraintKind +tc_lhs_pred mode pred = tc_check_lhs_type mode pred constraintKind --------------------------- tcTyVar :: Name -> TcM (TcType, TcKind) @@ -4045,7 +4046,7 @@ tcHsPartialSigType ctxt sig_ty ; tau <- -- Don't do (addTypeCtxt hs_tau) here else we get -- In the type -- In the type signature: foo :: - tc_lhs_type mode hs_tau ek + tc_check_lhs_type mode hs_tau ek ; return (wcs, wcx, theta, tau) } @@ -4355,8 +4356,8 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind - ; ty <- tc_lhs_type mode hs_ty ek + do { ek <- newExpectedKind ctxt_kind + ; ty <- tc_check_lhs_type mode hs_ty ek ; return (wcs, ty) } ; mapM_ emitNamedTypeHole wcs @@ -4532,7 +4533,7 @@ tc_lhs_kind_sig mode ctxt hs_kind -- Result is zonked = do { kind <- addErrCtxt (text "In the kind" <+> quotes (ppr hs_kind)) $ solveEqualities "tcLHsKindSig" $ - tc_lhs_type mode hs_kind liftedTypeKind + tc_check_lhs_type mode hs_kind liftedTypeKind ; traceTc "tcLHsKindSig" (ppr hs_kind $$ ppr kind) -- No generalization: ; kindGeneralizeNone kind ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Tc.Utils.TcType ( TcKind, TcCoVar, TcTyCoVar, TcTyVarBinder, TcInvisTVBinder, TcReqTVBinder, TcTyCon, MonoTcTyCon, PolyTcTyCon, TcTyConBinder, KnotTied, - ExpType(..), InferResult(..), + ExpType(..), ExpKind, InferResult(..), ExpTypeFRR, ExpSigmaType, ExpSigmaTypeFRR, ExpRhoType, mkCheckExpType, @@ -433,6 +433,9 @@ type ExpSigmaTypeFRR = ExpTypeFRR type ExpRhoType = ExpType +-- | Like 'ExpType', but on kind level +type ExpKind = ExpType + instance Outputable ExpType where ppr (Check ty) = text "Check" <> braces (ppr ty) ppr (Infer ir) = ppr ir ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,8 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + fillInferResult, ) where import GHC.Prelude ===================================== compiler/Language/Haskell/Syntax/Type.hs ===================================== @@ -1006,7 +1006,7 @@ would mean that when we pretty-print it back, we don't know whether the user wrote '*' or 'Type', and lose the parse/ppr roundtrip property. As a workaround, we parse '*' as HsStarTy (if it stands for 'Data.Kind.Type') -and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_hs_type). +and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_check_hs_type). When '*' is a regular type operator (StarIsType is disabled), HsStarTy is not involved. ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * ===================================== testsuite/tests/th/T24299.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24299 where +import Language.Haskell.TH.Syntax (addModFinalizer, runIO) +import GHC.Types (Type) +import System.IO + +type Proxy :: forall a. a -> Type +data Proxy a = MkProxy + +check :: ($(addModFinalizer (runIO (do putStrLn "check"; hFlush stdout)) >> + [t| Proxy |]) :: Type -> Type) Int -- There is kind signature, we are in check mode +check = MkProxy + +infer :: ($(addModFinalizer (runIO (do putStrLn "infer"; hFlush stdout)) >> + [t| Proxy |]) ) Int -- no kind signature, inference mode is enabled +infer = MkProxy ===================================== testsuite/tests/th/T24299.stderr ===================================== @@ -0,0 +1,2 @@ +check +infer ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24299', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68888e40e011c66d3165b3d2fbf652f6f6163e94 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68888e40e011c66d3165b3d2fbf652f6f6163e94 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 15:49:45 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 20 Mar 2024 11:49:45 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] Apply 1 suggestion(s) to 1 file(s) Message-ID: <65fb0599a3210_145d5e29f6cd851381@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 744ff570 by Sylvain Henry at 2024-03-20T15:49:43+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/PPC/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -518,7 +518,7 @@ jumpDestsOfInstr insn = case insn of BCC _ id _ -> [Just id] BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> [Just id | Just id <- targets] + BCTR targets _ _ -> targets _ -> [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/744ff5703ee5dc64e86cac2a86a78c35189c7296 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/744ff5703ee5dc64e86cac2a86a78c35189c7296 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 16:40:42 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 20 Mar 2024 12:40:42 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] NCG: Fix a bug in jump shortcutting. Message-ID: <65fb118a8911a_145d5e40a4b7457523@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 1d42a4e7 by Andreas Klebinger at 2024-03-20T17:26:10+01:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 12 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,15 +301,20 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr _ = [] +jumpDestsOfInstr i = case i of + (CBZ _ t) -> [ mkDest t ] + (CBNZ _ t) -> [ mkDest t ] + (J t) -> [ mkDest t ] + (B t) -> [ mkDest t ] + (BL t _ _) -> [ mkDest t ] + (BCOND _ t) -> [ mkDest t ] + _ -> [] + where + mkDest (TBlock id) = Just id + mkDest TLabel{} = Nothing + mkDest TReg{} = Nothing -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,15 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> targets + BCTRL{} -> [Nothing] + BL{} -> [Nothing] + JMP{} -> [Nothing] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} + +bar() { + return (2); +} \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d42a4e7d45dd90652d25f848c36bacb04d9fb64 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d42a4e7d45dd90652d25f848c36bacb04d9fb64 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 17:11:39 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 20 Mar 2024 13:11:39 -0400 Subject: [Git][ghc/ghc][wip/T24559] 19 commits: Escape multiple arguments in the settings file Message-ID: <65fb18cb58027_145d5e4edb82867034@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24559 at Glasgow Haskell Compiler / GHC Commits: 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Stg/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3523f3efb76fc0dcf190812de5278a8e018ab76...97a2bb1cdfa4b244a58374658aec6d48ce23a54a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3523f3efb76fc0dcf190812de5278a8e018ab76...97a2bb1cdfa4b244a58374658aec6d48ce23a54a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 17:24:43 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 20 Mar 2024 13:24:43 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 7 commits: rts: free error message before returning Message-ID: <65fb1bdaf16e2_145d5e53fdd38692ee@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 359b7ecb by Rodrigo Mesquita at 2024-03-20T17:13:32+00:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - 2f043908 by Rodrigo Mesquita at 2024-03-20T17:13:32+00:00 Start writing test - - - - - a9994389 by Alexis King at 2024-03-20T17:13:32+00:00 wip: avoid linear search when looking up Haskell symbols via dlsym - - - - - fe505ac1 by Alexis King at 2024-03-20T17:23:43+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - d3606fe9 by Alexis King at 2024-03-20T17:24:04+00:00 wip: use loadNativeObj to implement addDLL - - - - - 7ceaacb4 by Rodrigo Mesquita at 2024-03-20T17:24:05+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - f49e5a18 by Rodrigo Mesquita at 2024-03-20T17:24:05+00:00 Fail if no symbol is found in the relevant DLLs - - - - - 25 changed files: - + T23415/Makefile - + T23415/main.hs - + T23415/make_shared_libs.sh - + T23415/new-main.hs - + T23415/run_test.sh - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Interpreter.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/ObjLink.hs - libraries/ghci/GHCi/Run.hs - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/include/rts/Linker.h - rts/linker/Elf.c - rts/linker/Elf.h - + rts/linker/LoadNativeObjPosix.c - + rts/linker/LoadNativeObjPosix.h - rts/linker/PEi386.c - rts/rts.cabal - testsuite/tests/ghci/linking/dyn/T3372.hs Changes: ===================================== T23415/Makefile ===================================== @@ -0,0 +1,10 @@ +.PHONY: run build clean + +run: + sh run_test.sh + +build: + sh make_shared_libs.sh + +clean: + rm -f lib*.out main main.o main.hi test.o tags ===================================== T23415/main.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +hsLoadObjs = do + cwd <- getCurrentDirectory + forM_ [0..499] $ \i -> + loadDLL (cwd "lib" ++ show i ++ ".out") + +hsLoadSymbols = do + forM_ [0..99] $ \j -> + forM_ [0..499] $ \i -> + lookupSymbol ("lib" ++ show i ++ "_" ++ show j) + +main = do + initObjLinker RetainCAFs + hsLoadObjs + hsLoadSymbols + ===================================== T23415/make_shared_libs.sh ===================================== @@ -0,0 +1,20 @@ +#!/bin/sh + +example_dylib=$(basename -- $(find $(ghc --print-libdir) -name libHS* -not -name *.a | head -n1)) +dylib_ext="${example_dylib##*.}" +# we try .out instead of using the correct extension. + +i=0 +while [ $i -lt 500 ]; do + j=0 + while [ $j -lt 100 ]; do + echo "int lib${i}_$j(void) { return $i; }" >> "lib$i.c" + j=$(( j + 1 )) + done + cc -o "lib$i.o" -c "lib$i.c" -fPIC + cc -shared "lib$i.o" -o "lib$i.out" # "lib$i.$dylib_ext" + rm "lib$i.c" "lib$i.o" + i=$(( i + 1 )) +done + + ===================================== T23415/new-main.hs ===================================== @@ -0,0 +1,29 @@ +import Data.Either +import Data.Foldable +import Data.Map as M +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +libname i = "lib" ++ show i + +hsLoadObjs = do + cwd <- getCurrentDirectory + foldrM (\i acc -> do + Right handle <- loadDLL (cwd libname i ++ ".out") + return $ M.insert (libname i) handle acc + ) + M.empty [0..499] + +hsLoadSymbols handles = do + forM_ [0..499] $ \i -> + forM_ [0..99] $ \j -> do + let symbolname = libname i ++ "_" ++ show j + lookupSymbolInDLL (handles M.! libname i) symbolname + +main = do + initObjLinker RetainCAFs + handles <- hsLoadObjs + hsLoadSymbols handles + print "hi" ===================================== T23415/run_test.sh ===================================== @@ -0,0 +1,8 @@ +#!/bin/sh + +GHC1=/Users/romes/ghc-dev/ghc/_build/stage1/bin/ghc +GHC2=/Users/romes/ghc-dev/23415/_build/stage1/bin/ghc + +# $GHC1 --interactive main.hs -package directory -package ghci -package filepath +$GHC2 --interactive new-main.hs -package directory -package ghci -package filepath -package containers + ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -38,6 +38,7 @@ import GHC.Utils.Outputable import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.Unique.DFM import Language.Haskell.Syntax.Module.Name @@ -52,31 +53,32 @@ import GHC.Exts linkBCO :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> UnlinkedBCO -> IO ResolvedBCO -linkBCO interp le bco_ix +linkBCO interp pkgs_loaded le bco_ix (UnlinkedBCO _ arity insns bitmap lits0 ptrs0) = do -- fromIntegral Word -> Word64 should be a no op if Word is Word64 -- otherwise it will result in a cast to longlong on 32bit systems. - lits <- mapM (fmap fromIntegral . lookupLiteral interp le) (ssElts lits0) - ptrs <- mapM (resolvePtr interp le bco_ix) (ssElts ptrs0) + lits <- mapM (fmap fromIntegral . lookupLiteral interp pkgs_loaded le) (ssElts lits0) + ptrs <- mapM (resolvePtr interp pkgs_loaded le bco_ix) (ssElts ptrs0) return (ResolvedBCO isLittleEndian arity insns bitmap (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) -lookupLiteral :: Interp -> LinkerEnv -> BCONPtr -> IO Word -lookupLiteral interp le ptr = case ptr of +lookupLiteral :: Interp -> PkgsLoaded -> LinkerEnv -> BCONPtr -> IO Word +lookupLiteral interp pkgs_loaded le ptr = case ptr of BCONPtrWord lit -> return lit BCONPtrLbl sym -> do Ptr a# <- lookupStaticPtr interp sym return (W# (int2Word# (addr2Int# a#))) BCONPtrItbl nm -> do - Ptr a# <- lookupIE interp (itbl_env le) nm + Ptr a# <- lookupIE interp pkgs_loaded (itbl_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrAddr nm -> do - Ptr a# <- lookupAddr interp (addr_env le) nm + Ptr a# <- lookupAddr interp pkgs_loaded (addr_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrStr _ -> -- should be eliminated during assembleBCOs @@ -90,19 +92,19 @@ lookupStaticPtr interp addr_of_label_string = do Nothing -> linkFail "GHC.ByteCode.Linker: can't find label" (unpackFS addr_of_label_string) -lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) -lookupIE interp ie con_nm = +lookupIE :: Interp -> PkgsLoaded -> ItblEnv -> Name -> IO (Ptr ()) +lookupIE interp pkgs_loaded ie con_nm = case lookupNameEnv ie con_nm of Just (_, ItblPtr a) -> return (fromRemotePtr (castRemotePtr a)) Nothing -> do -- try looking up in the object files. let sym_to_find1 = nameToCLabel con_nm "con_info" - m <- lookupSymbol interp sym_to_find1 + m <- lookupHsSymbol interp pkgs_loaded con_nm "con_info" case m of Just addr -> return addr Nothing -> do -- perhaps a nullary constructor? let sym_to_find2 = nameToCLabel con_nm "static_info" - n <- lookupSymbol interp sym_to_find2 + n <- lookupHsSymbol interp pkgs_loaded con_nm "static_info" case n of Just addr -> return addr Nothing -> linkFail "GHC.ByteCode.Linker.lookupIE" @@ -110,14 +112,14 @@ lookupIE interp ie con_nm = unpackFS sym_to_find2) -- see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode -lookupAddr :: Interp -> AddrEnv -> Name -> IO (Ptr ()) -lookupAddr interp ae addr_nm = do +lookupAddr :: Interp -> PkgsLoaded -> AddrEnv -> Name -> IO (Ptr ()) +lookupAddr interp pkgs_loaded ae addr_nm = do case lookupNameEnv ae addr_nm of Just (_, AddrPtr ptr) -> return (fromRemotePtr ptr) Nothing -> do -- try looking up in the object files. let sym_to_find = nameToCLabel addr_nm "bytes" -- see Note [Bytes label] in GHC.Cmm.CLabel - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded addr_nm "bytes" case m of Just ptr -> return ptr Nothing -> linkFail "GHC.ByteCode.Linker.lookupAddr" @@ -133,11 +135,12 @@ lookupPrimOp interp primop = do resolvePtr :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> BCOPtr -> IO ResolvedBCOPtr -resolvePtr interp le bco_ix ptr = case ptr of +resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of BCOPtrName nm | Just ix <- lookupNameEnv bco_ix nm -> return (ResolvedBCORef ix) -- ref to another BCO in this group @@ -149,7 +152,7 @@ resolvePtr interp le bco_ix ptr = case ptr of -> assertPpr (isExternalName nm) (ppr nm) $ do let sym_to_find = nameToCLabel nm "closure" - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded nm "closure" case m of Just p -> return (ResolvedBCOStaticPtr (toRemotePtr p)) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE" (unpackFS sym_to_find) @@ -158,11 +161,27 @@ resolvePtr interp le bco_ix ptr = case ptr of -> ResolvedBCOStaticPtr <$> lookupPrimOp interp op BCOPtrBCO bco - -> ResolvedBCOPtrBCO <$> linkBCO interp le bco_ix bco + -> ResolvedBCOPtrBCO <$> linkBCO interp pkgs_loaded le bco_ix bco BCOPtrBreakArray breakarray -> withForeignRef breakarray $ \ba -> return (ResolvedBCOPtrBreakArray ba) +lookupHsSymbol :: Interp -> PkgsLoaded -> Name -> String -> IO (Maybe (Ptr ())) +lookupHsSymbol interp pkgs_loaded nm sym_suffix = do + massertPpr (isExternalName nm) (ppr nm) + let sym_to_find = nameToCLabel nm sym_suffix + pkg_id = moduleUnitId $ nameModule nm + loaded_dlls = maybe [] loaded_pkg_hs_dlls $ lookupUDFM pkgs_loaded pkg_id + + go (dll:dlls) = do + mb_ptr <- lookupSymbolInDLL interp dll sym_to_find + case mb_ptr of + Just ptr -> pure (Just ptr) + Nothing -> go dlls + go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id" + + go loaded_dlls + linkFail :: String -> String -> IO a linkFail who what = throwGhcExceptionIO (ProgramError $ ===================================== compiler/GHC/Driver/Plugins.hs ===================================== @@ -420,12 +420,12 @@ loadExternalPluginLib :: FilePath -> IO () loadExternalPluginLib path = do -- load library loadDLL path >>= \case - Just errmsg -> pprPanic "loadExternalPluginLib" - (vcat [ text "Can't load plugin library" - , text " Library path: " <> text path - , text " Error : " <> text errmsg - ]) - Nothing -> do + Left errmsg -> pprPanic "loadExternalPluginLib" + (vcat [ text "Can't load plugin library" + , text " Library path: " <> text path + , text " Error : " <> text errmsg + ]) + Right _ -> do -- TODO: use returned LoadedDLL? -- resolve objects resolveObjs >>= \case True -> return () ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -55,6 +55,7 @@ import GHC.Tc.Utils.Monad import GHC.Runtime.Interpreter import GHCi.RemoteTypes import GHC.Iface.Load +import GHCi.Message (LoadedDLL) import GHC.ByteCode.Linker import GHC.ByteCode.Asm @@ -172,7 +173,7 @@ emptyLoaderState = LoaderState -- -- The linker's symbol table is populated with RTS symbols using an -- explicit list. See rts/Linker.c for details. - where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] emptyUniqDSet) + where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] [] emptyUniqDSet) extendLoadedEnv :: Interp -> [(Name,ForeignHValue)] -> IO () extendLoadedEnv interp new_bindings = @@ -512,25 +513,25 @@ preloadLib interp hsc_env lib_paths framework_paths pls lib_spec = do DLL dll_unadorned -> do maybe_errstr <- loadDLL interp (platformSOName platform dll_unadorned) case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm | platformOS platform /= OSDarwin -> + Right _ -> maybePutStrLn logger "done" + Left mm | platformOS platform /= OSDarwin -> preloadFailed mm lib_paths lib_spec - Just mm | otherwise -> do + Left mm | otherwise -> do -- As a backup, on Darwin, try to also load a .so file -- since (apparently) some things install that way - see -- ticket #8770. let libfile = ("lib" ++ dll_unadorned) <.> "so" err2 <- loadDLL interp libfile case err2 of - Nothing -> maybePutStrLn logger "done" - Just _ -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left _ -> preloadFailed mm lib_paths lib_spec return pls DLLPath dll_path -> do do maybe_errstr <- loadDLL interp dll_path case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left mm -> preloadFailed mm lib_paths lib_spec return pls Framework framework -> @@ -614,7 +615,7 @@ loadExpr interp hsc_env span root_ul_bco = do -- Load the necessary packages and linkables let le = linker_env pls bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)] - resolved <- linkBCO interp le bco_ix root_ul_bco + resolved <- linkBCO interp (pkgs_loaded pls) le bco_ix root_ul_bco [root_hvref] <- createBCOs interp [resolved] fhv <- mkFinalizedHValue interp root_hvref return (pls, fhv) @@ -677,7 +678,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do , addr_env = plusNameEnv (addr_env le) bc_strs } -- Link the necessary packages and linkables - new_bindings <- linkSomeBCOs interp le2 [cbc] + new_bindings <- linkSomeBCOs interp (pkgs_loaded pls) le2 [cbc] nms_fhvs <- makeForeignNamedHValueRefs interp new_bindings let ce2 = extendClosureEnv (closure_env le2) nms_fhvs !pls2 = pls { linker_env = le2 { closure_env = ce2 } } @@ -858,8 +859,8 @@ dynLoadObjs interp hsc_env pls at LoaderState{..} objs = do changeTempFilesLifetime tmpfs TFL_GhcSession [soFile] m <- loadDLL interp soFile case m of - Nothing -> return $! pls { temp_sos = (libPath, libName) : temp_sos } - Just err -> linkFail msg err + Right _ -> return $! pls { temp_sos = (libPath, libName) : temp_sos } + Left err -> linkFail msg err where msg = "GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed" @@ -899,7 +900,7 @@ dynLinkBCOs interp pls bcos = do ae2 = foldr plusNameEnv (addr_env le1) (map bc_strs cbcs) le2 = le1 { itbl_env = ie2, addr_env = ae2 } - names_and_refs <- linkSomeBCOs interp le2 cbcs + names_and_refs <- linkSomeBCOs interp (pkgs_loaded pls) le2 cbcs -- We only want to add the external ones to the ClosureEnv let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs @@ -914,6 +915,7 @@ dynLinkBCOs interp pls bcos = do -- Link a bunch of BCOs and return references to their values linkSomeBCOs :: Interp + -> PkgsLoaded -> LinkerEnv -> [CompiledByteCode] -> IO [(Name,HValueRef)] @@ -921,7 +923,7 @@ linkSomeBCOs :: Interp -- the incoming unlinked BCOs. Each gives the -- value of the corresponding unlinked BCO -linkSomeBCOs interp le mods = foldr fun do_link mods [] +linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] where fun CompiledByteCode{..} inner accum = inner (bc_bcos : accum) @@ -930,7 +932,7 @@ linkSomeBCOs interp le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) - resolved <- sequence [ linkBCO interp le bco_ix bco | bco <- flat ] + resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) @@ -1092,18 +1094,18 @@ loadPackages' interp hsc_env new_pks pls = do -- Link dependents first ; pkgs' <- link pkgs deps -- Now link the package itself - ; (hs_cls, extra_cls) <- loadPackage interp hsc_env pkg_cfg + ; (hs_cls, extra_cls, loaded_dlls) <- loadPackage interp hsc_env pkg_cfg ; let trans_deps = unionManyUniqDSets [ addOneToUniqDSet (loaded_pkg_trans_deps loaded_pkg_info) dep_pkg | dep_pkg <- deps , Just loaded_pkg_info <- pure (lookupUDFM pkgs' dep_pkg) ] - ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls trans_deps)) } + ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls loaded_dlls trans_deps)) } | otherwise = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unpackFS (unitIdFS new_pkg))) -loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec]) +loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec], [RemotePtr LoadedDLL]) loadPackage interp hsc_env pkg = do let dflags = hsc_dflags hsc_env @@ -1145,7 +1147,9 @@ loadPackage interp hsc_env pkg let classifieds = hs_classifieds ++ extra_classifieds -- Complication: all the .so's must be loaded before any of the .o's. - let known_dlls = [ dll | DLLPath dll <- classifieds ] + let known_hs_dlls = [ dll | DLLPath dll <- hs_classifieds ] + known_extra_dlls = [ dll | DLLPath dll <- extra_classifieds ] + known_dlls = known_hs_dlls ++ known_extra_dlls #if defined(CAN_LOAD_DLL) dlls = [ dll | DLL dll <- classifieds ] #endif @@ -1166,10 +1170,13 @@ loadPackage interp hsc_env pkg loadFrameworks interp platform pkg -- See Note [Crash early load_dyn and locateLib] -- Crash early if can't load any of `known_dlls` - mapM_ (load_dyn interp hsc_env True) known_dlls + mapM_ (load_dyn interp hsc_env True) known_extra_dlls + loaded_dlls <- mapMaybeM (load_dyn interp hsc_env True) known_hs_dlls -- For remaining `dlls` crash early only when there is surely -- no package's DLL around ... (not is_dyn) mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls +#else + let loaded_dlls = [] #endif -- After loading all the DLLs, we can load the static objects. -- Ordering isn't important here, because we do one final link @@ -1189,7 +1196,7 @@ loadPackage interp hsc_env pkg if succeeded ok then do maybePutStrLn logger "done." - return (hs_classifieds, extra_classifieds) + return (hs_classifieds, extra_classifieds, loaded_dlls) else let errmsg = text "unable to load unit `" <> pprUnitInfoForUser pkg <> text "'" in throwGhcExceptionIO (InstallationError (showSDoc dflags errmsg)) @@ -1242,19 +1249,20 @@ restriction very easily. -- can be passed directly to loadDLL. They are either fully-qualified -- ("/usr/lib/libfoo.so"), or unqualified ("libfoo.so"). In the latter case, -- loadDLL is going to search the system paths to find the library. -load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO () +load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO (Maybe (RemotePtr LoadedDLL)) load_dyn interp hsc_env crash_early dll = do r <- loadDLL interp dll case r of - Nothing -> return () - Just err -> + Right loaded_dll -> pure (Just loaded_dll) + Left err -> if crash_early then cmdLineErrorIO err - else + else do when (diag_wopt Opt_WarnMissedExtraSharedLib diag_opts) $ logMsg logger (mkMCDiagnostic diag_opts (WarningWithFlag Opt_WarnMissedExtraSharedLib) Nothing) noSrcSpan $ withPprStyle defaultUserStyle (note err) + pure Nothing where diag_opts = initDiagOpts (hsc_dflags hsc_env) logger = hsc_logger hsc_env ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -172,6 +172,6 @@ loadFramework interp extraPaths rootname findLoadDLL (p:ps) errs = do { dll <- loadDLL interp (p fwk_file) ; case dll of - Nothing -> return Nothing - Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) + Right _ -> return Nothing + Left err -> findLoadDLL ps ((p ++ ": " ++ err):errs) } ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -40,7 +40,8 @@ import GHC.Prelude import GHC.Unit ( UnitId, Module ) import GHC.ByteCode.Types ( ItblEnv, AddrEnv, CompiledByteCode ) import GHC.Fingerprint.Type ( Fingerprint ) -import GHCi.RemoteTypes ( ForeignHValue ) +import GHCi.RemoteTypes ( ForeignHValue, RemotePtr ) +import GHCi.Message ( LoadedDLL ) import GHC.Types.Var ( Id ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnvList, filterNameEnv ) @@ -146,11 +147,13 @@ data LoadedPkgInfo { loaded_pkg_uid :: !UnitId , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] + , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] + -- ^ TODO: write Note , loaded_pkg_trans_deps :: UniqDSet UnitId } instance Outputable LoadedPkgInfo where - ppr (LoadedPkgInfo uid hs_objs non_hs_objs trans_deps) = + ppr (LoadedPkgInfo uid hs_objs non_hs_objs _ trans_deps) = vcat [ppr uid , ppr hs_objs , ppr non_hs_objs ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Runtime.Interpreter -- * The object-code linker , initObjLinker , lookupSymbol + , lookupSymbolInDLL , lookupClosure , loadDLL , loadArchive @@ -467,6 +468,13 @@ lookupSymbol interp str = case interpInstance interp of ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) +lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) +lookupSymbolInDLL interp dll str = case interpInstance interp of +#if defined(HAVE_INTERNAL_INTERPRETER) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) +#endif + ExternalInterp _ -> panic "lookupSymbolInDLL: not implemented for external interpreter" -- FIXME + lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = interpCmd interp (LookupClosure str) @@ -485,12 +493,7 @@ purgeLookupSymbolCache interp = case interpInstance interp of -- an absolute pathname to the file, or a relative filename -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. --- --- Returns: --- --- Nothing => success --- Just err_msg => failure -loadDLL :: Interp -> String -> IO (Maybe String) +loadDLL :: Interp -> String -> IO (Either String (RemotePtr LoadedDLL)) loadDLL interp str = interpCmd interp (LoadDLL str) loadArchive :: Interp -> String -> IO () ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -23,6 +23,7 @@ module GHCi.Message , getMessage, putMessage, getTHMessage, putTHMessage , Pipe(..), remoteCall, remoteTHCall, readPipe, writePipe , BreakModule + , LoadedDLL ) where import Prelude -- See note [Why do we import Prelude here?] @@ -73,8 +74,9 @@ data Message a where -- These all invoke the corresponding functions in the RTS Linker API. InitLinker :: Message () LookupSymbol :: String -> Message (Maybe (RemotePtr ())) + LookupSymbolInDLL :: RemotePtr LoadedDLL -> String -> Message (Maybe (RemotePtr ())) LookupClosure :: String -> Message (Maybe HValueRef) - LoadDLL :: String -> Message (Maybe String) + LoadDLL :: String -> Message (Either String (RemotePtr LoadedDLL)) LoadArchive :: String -> Message () -- error? LoadObj :: String -> Message () -- error? UnloadObj :: String -> Message () -- error? @@ -415,6 +417,9 @@ instance Binary a => Binary (EvalResult a) -- that type isn't available here. data BreakModule +-- | A dummy type that tags pointers returned by 'LoadDLL'. +data LoadedDLL + -- SomeException can't be serialized because it contains dynamic -- types. However, we do very limited things with the exceptions that -- are thrown by interpreted computations: @@ -544,6 +549,7 @@ getMessage = do 37 -> Msg <$> return RtsRevertCAFs 38 -> Msg <$> (ResumeSeq <$> get) 39 -> Msg <$> (NewBreakModule <$> get) + 40 -> Msg <$> (LookupSymbolInDLL <$> get <*> get) _ -> error $ "Unknown Message code " ++ (show b) putMessage :: Message a -> Put @@ -588,7 +594,8 @@ putMessage m = case m of Seq a -> putWord8 36 >> put a RtsRevertCAFs -> putWord8 37 ResumeSeq a -> putWord8 38 >> put a - NewBreakModule name -> putWord8 39 >> put name + NewBreakModule name -> putWord8 39 >> put name + LookupSymbolInDLL dll str -> putWord8 40 >> put dll >> put str {- Note [Parallelize CreateBCOs serialization] ===================================== libraries/ghci/GHCi/ObjLink.hs ===================================== @@ -18,6 +18,7 @@ module GHCi.ObjLink , unloadObj , purgeObj , lookupSymbol + , lookupSymbolInDLL , lookupClosure , resolveObjs , addLibrarySearchPath @@ -27,18 +28,17 @@ module GHCi.ObjLink import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes +import GHCi.Message (LoadedDLL) import Control.Exception (throwIO, ErrorCall(..)) import Control.Monad ( when ) import Foreign.C -import Foreign.Marshal.Alloc ( free ) -import Foreign ( nullPtr ) +import Foreign.Marshal.Alloc ( alloca, free ) +import Foreign ( nullPtr, peek ) import GHC.Exts import System.Posix.Internals ( CFilePath, withFilePath, peekFilePath ) import System.FilePath ( dropExtension, normalise ) - - -- --------------------------------------------------------------------------- -- RTS Linker Interface -- --------------------------------------------------------------------------- @@ -70,6 +70,15 @@ lookupSymbol str_in = do then return Nothing else return (Just addr) +lookupSymbolInDLL :: Ptr LoadedDLL -> String -> IO (Maybe (Ptr a)) +lookupSymbolInDLL dll str_in = do + let str = prefixUnderscore str_in + withCAString str $ \c_str -> do + addr <- c_lookupSymbolInNativeObj dll c_str + if addr == nullPtr + then return Nothing + else return (Just addr) + lookupClosure :: String -> IO (Maybe HValueRef) lookupClosure str = do m <- lookupSymbol str @@ -89,7 +98,7 @@ prefixUnderscore -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. -- -loadDLL :: String -> IO (Maybe String) +loadDLL :: String -> IO (Either String (Ptr LoadedDLL)) -- Nothing => success -- Just err_msg => failure loadDLL str0 = do @@ -101,12 +110,16 @@ loadDLL str0 = do str | isWindowsHost = dropExtension str0 | otherwise = str0 -- - maybe_errmsg <- withFilePath (normalise str) $ \dll -> c_addDLL dll - if maybe_errmsg == nullPtr - then return Nothing - else do str <- peekCString maybe_errmsg - free maybe_errmsg - return (Just str) + (maybe_handle, maybe_errmsg) <- withFilePath (normalise str) $ \dll -> + alloca $ \errmsg_ptr -> (,) + <$> c_loadNativeObj dll errmsg_ptr + <*> peek errmsg_ptr + + if maybe_handle == nullPtr + then do str <- peekCString maybe_errmsg + free maybe_errmsg + return (Left str) + else return (Right maybe_handle) loadArchive :: String -> IO () loadArchive str = do @@ -163,7 +176,8 @@ resolveObjs = do -- Foreign declarations to RTS entry points which does the real work; -- --------------------------------------------------------------------------- -foreign import ccall unsafe "addDLL" c_addDLL :: CFilePath -> IO CString +foreign import ccall unsafe "loadNativeObj" c_loadNativeObj :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) +foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInNativeObj :: Ptr LoadedDLL -> CString -> IO (Ptr a) foreign import ccall unsafe "initLinker_" c_initLinker_ :: CInt -> IO () foreign import ccall unsafe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) foreign import ccall unsafe "loadArchive" c_loadArchive :: CFilePath -> IO Int ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -66,7 +66,7 @@ run m = case m of LookupClosure str -> lookupJSClosure str #else InitLinker -> initObjLinker RetainCAFs - LoadDLL str -> loadDLL str + LoadDLL str -> fmap toRemotePtr <$> loadDLL str LoadArchive str -> loadArchive str LoadObj str -> loadObj str UnloadObj str -> unloadObj str @@ -81,6 +81,8 @@ run m = case m of #endif RtsRevertCAFs -> rts_revertCAFs LookupSymbol str -> fmap toRemotePtr <$> lookupSymbol str + LookupSymbolInDLL dll str -> + fmap toRemotePtr <$> lookupSymbolInDLL (fromRemotePtr dll) str FreeHValueRefs rs -> mapM_ freeRemoteRef rs AddSptEntry fpr r -> localRef r >>= sptAddEntry fpr EvalStmt opts r -> evalStmt opts r ===================================== rts/Linker.c ===================================== @@ -77,6 +77,10 @@ # include #endif +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) +# include "linker/LoadNativeObjPosix.h" +#endif + #if defined(dragonfly_HOST_OS) #include #endif @@ -419,9 +423,6 @@ static int linker_init_done = 0 ; static void *dl_prog_handle; static regex_t re_invalid; static regex_t re_realso; -#if defined(THREADED_RTS) -Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section -#endif #endif void initLinker (void) @@ -455,9 +456,6 @@ initLinker_ (int retain_cafs) #if defined(THREADED_RTS) initMutex(&linker_mutex); -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - initMutex(&dl_mutex); -#endif #endif symhash = allocStrHashTable(); @@ -520,9 +518,6 @@ exitLinker( void ) { if (linker_init_done == 1) { regfree(&re_invalid); regfree(&re_realso); -#if defined(THREADED_RTS) - closeMutex(&dl_mutex); -#endif } #endif if (linker_init_done == 1) { @@ -556,90 +551,6 @@ exitLinker( void ) { # if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -/* Suppose in ghci we load a temporary SO for a module containing - f = 1 - and then modify the module, recompile, and load another temporary - SO with - f = 2 - Then as we don't unload the first SO, dlsym will find the - f = 1 - symbol whereas we want the - f = 2 - symbol. We therefore need to keep our own SO handle list, and - try SOs in the right order. */ - -typedef - struct _OpenedSO { - struct _OpenedSO* next; - void *handle; - } - OpenedSO; - -/* A list thereof. */ -static OpenedSO* openedSOs = NULL; - -static const char * -internal_dlopen(const char *dll_name) -{ - OpenedSO* o_so; - void *hdl; - const char *errmsg; - char *errmsg_copy; - - // omitted: RTLD_NOW - // see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html - IF_DEBUG(linker, - debugBelch("internal_dlopen: dll_name = '%s'\n", dll_name)); - - //-------------- Begin critical section ------------------ - // This critical section is necessary because dlerror() is not - // required to be reentrant (see POSIX -- IEEE Std 1003.1-2008) - // Also, the error message returned must be copied to preserve it - // (see POSIX also) - - ACQUIRE_LOCK(&dl_mutex); - - // When dlopen() loads a profiled dynamic library, it calls the - // ctors which will call registerCcsList() to append the defined - // CostCentreStacks to CCS_LIST. This execution path starting from - // addDLL() was only protected by dl_mutex previously. However, - // another thread may be doing other things with the RTS linker - // that transitively calls refreshProfilingCCSs() which also - // accesses CCS_LIST, and those execution paths are protected by - // linker_mutex. So there's a risk of data race that may lead to - // segfaults (#24423), and we need to ensure the ctors are also - // protected by ccs_mutex. -#if defined(PROFILING) - ACQUIRE_LOCK(&ccs_mutex); -#endif - - hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ - -#if defined(PROFILING) - RELEASE_LOCK(&ccs_mutex); -#endif - - errmsg = NULL; - if (hdl == NULL) { - /* dlopen failed; return a ptr to the error msg. */ - errmsg = dlerror(); - if (errmsg == NULL) errmsg = "addDLL: unknown error"; - errmsg_copy = stgMallocBytes(strlen(errmsg)+1, "addDLL"); - strcpy(errmsg_copy, errmsg); - errmsg = errmsg_copy; - } else { - o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); - o_so->handle = hdl; - o_so->next = openedSOs; - openedSOs = o_so; - } - - RELEASE_LOCK(&dl_mutex); - //--------------- End critical section ------------------- - - return errmsg; -} - /* Note [RTLD_LOCAL] ~~~~~~~~~~~~~~~~~ @@ -660,11 +571,10 @@ internal_dlopen(const char *dll_name) static void * internal_dlsym(const char *symbol) { - OpenedSO* o_so; void *v; - // We acquire dl_mutex as concurrent dl* calls may alter dlerror - ACQUIRE_LOCK(&dl_mutex); + // concurrent dl* calls may alter dlerror + ASSERT_LOCK_HELD(&linker_mutex); // clears dlerror dlerror(); @@ -672,20 +582,19 @@ internal_dlsym(const char *symbol) { // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } - for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { - v = dlsym(o_so->handle, symbol); - if (dlerror() == NULL) { + for (ObjectCode *nc = loaded_objects; nc; nc = nc->next_loaded_object) { + if (nc->type == DYNAMIC_OBJECT) { + v = dlsym(nc->dlopen_handle, symbol); + if (dlerror() == NULL) { IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); - RELEASE_LOCK(&dl_mutex); return v; + } } } - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); # define SPECIAL_SYMBOL(sym) \ @@ -725,79 +634,33 @@ internal_dlsym(const char *symbol) { // we failed to find the symbol return NULL; } -# endif -const char * -addDLL( pathchar *dll_name ) +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name) { -# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - /* ------------------- ELF DLL loader ------------------- */ - -#define NMATCH 5 - regmatch_t match[NMATCH]; - const char *errmsg; - FILE* fp; - size_t match_length; -#define MAXLINE 1000 - char line[MAXLINE]; - int result; - - IF_DEBUG(linker, debugBelch("addDLL: dll_name = '%s'\n", dll_name)); - errmsg = internal_dlopen(dll_name); + ASSERT_LOCK_HELD(&linker_mutex); - if (errmsg == NULL) { - return NULL; - } +#if defined(OBJFORMAT_MACHO) + CHECK(symbol_name[0] == '_'); + symbol_name = symbol_name+1; +#endif + void *result = dlsym(handle, symbol_name); + return result; +} +# endif - // GHC #2615 - // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) - // contain linker scripts rather than ELF-format object code. This - // code handles the situation by recognizing the real object code - // file name given in the linker script. - // - // If an "invalid ELF header" error occurs, it is assumed that the - // .so file contains a linker script instead of ELF object code. - // In this case, the code looks for the GROUP ( ... ) linker - // directive. If one is found, the first file name inside the - // parentheses is treated as the name of a dynamic library and the - // code attempts to dlopen that file. If this is also unsuccessful, - // an error message is returned. - - // see if the error message is due to an invalid ELF header - IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", errmsg)); - result = regexec(&re_invalid, errmsg, (size_t) NMATCH, match, 0); - IF_DEBUG(linker, debugBelch("result = %i\n", result)); - if (result == 0) { - // success -- try to read the named file as a linker script - match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), - MAXLINE-1); - strncpy(line, (errmsg+(match[1].rm_so)),match_length); - line[match_length] = '\0'; // make sure string is null-terminated - IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); - if ((fp = __rts_fopen(line, "r")) == NULL) { - return errmsg; // return original error if open fails - } - // try to find a GROUP or INPUT ( ... ) command - while (fgets(line, MAXLINE, fp) != NULL) { - IF_DEBUG(linker, debugBelch("input line = %s", line)); - if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { - // success -- try to dlopen the first named file - IF_DEBUG(linker, debugBelch("match%s\n","")); - line[match[2].rm_eo] = '\0'; - stgFree((void*)errmsg); // Free old message before creating new one - errmsg = internal_dlopen(line+match[2].rm_so); - break; - } - // if control reaches here, no GROUP or INPUT ( ... ) directive - // was found and the original error message is returned to the - // caller - } - fclose(fp); +const char *addDLL(pathchar* dll_name) +{ +# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) + char *errmsg; + if (loadNativeObj(dll_name, &errmsg)) { + return NULL; + } else { + ASSERT(errmsg != NULL); + return errmsg; } - return errmsg; # elif defined(OBJFORMAT_PEi386) - return addDLL_PEi386(dll_name, NULL); + return addDLL_PEi386(dll_name); # else barf("addDLL: not implemented on this platform"); @@ -1229,9 +1092,10 @@ void freeObjectCode (ObjectCode *oc) if (oc->type == DYNAMIC_OBJECT) { #if defined(OBJFORMAT_ELF) - ACQUIRE_LOCK(&dl_mutex); + // ROMES:TODO: This previously acquired dl_mutex. Check that acquiring linker_mutex here is fine. + ACQUIRE_LOCK(&linker_mutex); freeNativeCode_ELF(oc); - RELEASE_LOCK(&dl_mutex); + RELEASE_LOCK(&linker_mutex); #else barf("freeObjectCode: This shouldn't happen"); #endif @@ -1896,12 +1760,20 @@ HsInt purgeObj (pathchar *path) return r; } +ObjectCode *lookupObjectByPath(pathchar *path) { + for (ObjectCode *o = objects; o; o = o->next) { + if (0 == pathcmp(o->fileName, path)) { + return o; + } + } + return NULL; +} + OStatus getObjectLoadStatus_ (pathchar *path) { - for (ObjectCode *o = objects; o; o = o->next) { - if (0 == pathcmp(o->fileName, path)) { - return o->status; - } + ObjectCode *oc = lookupObjectByPath(path); + if (oc) { + return oc->status; } return OBJECT_NOT_LOADED; } @@ -1988,11 +1860,21 @@ addSection (Section *s, SectionKind kind, SectionAlloc alloc, #define UNUSED(x) (void)(x) -#if defined(OBJFORMAT_ELF) +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) void * loadNativeObj (pathchar *path, char **errmsg) { + IF_DEBUG(linker, debugBelch("loadNativeObj: path = '%s'\n", path)); ACQUIRE_LOCK(&linker_mutex); - void *r = loadNativeObj_ELF(path, errmsg); + void *r = loadNativeObj_POSIX(path, errmsg); + +#if defined(OBJFORMAT_ELF) + if (!r) { + // Check if native object may be a linker script and try loading a native + // object from it + r = loadNativeObjFromLinkerScript_ELF(errmsg); + } +#endif + RELEASE_LOCK(&linker_mutex); return r; } @@ -2006,7 +1888,7 @@ loadNativeObj (pathchar *path, char **errmsg) } #endif -HsInt unloadNativeObj (void *handle) +static HsInt unloadNativeObj_(void *handle) { bool unloadedAnyObj = false; @@ -2044,6 +1926,13 @@ HsInt unloadNativeObj (void *handle) } } +HsInt unloadNativeObj(void *handle) { + ACQUIRE_LOCK(&linker_mutex); + HsInt r = unloadNativeObj_(handle); + RELEASE_LOCK(&linker_mutex); + return r; +} + /* ----------------------------------------------------------------------------- * Segment management */ ===================================== rts/LinkerInternals.h ===================================== @@ -412,10 +412,6 @@ extern Elf_Word shndx_table_uninit_label; #if defined(THREADED_RTS) extern Mutex linker_mutex; - -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -extern Mutex dl_mutex; -#endif #endif /* THREADED_RTS */ /* Type of an initializer */ @@ -515,9 +511,9 @@ HsInt loadArchive_ (pathchar *path); #define USE_CONTIGUOUS_MMAP 0 #endif - HsInt isAlreadyLoaded( pathchar *path ); OStatus getObjectLoadStatus_ (pathchar *path); +ObjectCode *lookupObjectByPath(pathchar *path); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( ObjectType type, pathchar *path, char *image, int imageSize, bool mapped, pathchar *archiveMemberName, ===================================== rts/RtsSymbols.c ===================================== @@ -619,6 +619,7 @@ extern char **environ; SymI_HasProto(purgeObj) \ SymI_HasProto(insertSymbol) \ SymI_HasProto(lookupSymbol) \ + SymI_HasProto(lookupSymbolInNativeObj) \ SymI_HasDataProto(stg_makeStablePtrzh) \ SymI_HasDataProto(stg_mkApUpd0zh) \ SymI_HasDataProto(stg_labelThreadzh) \ ===================================== rts/include/rts/Linker.h ===================================== @@ -90,8 +90,12 @@ void *loadNativeObj( pathchar *path, char **errmsg ); Takes the handle returned from loadNativeObj() as an argument. */ HsInt unloadNativeObj( void *handle ); +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name); + /* load a dynamic library */ -const char *addDLL( pathchar* dll_name ); +const char *addDLL(pathchar* dll_name); + +void *lookupSymbolInDLL(void *handle, const char *symbol_name); /* add a path to the library search path */ HsPtr addLibrarySearchPath(pathchar* dll_path); ===================================== rts/linker/Elf.c ===================================== @@ -2069,159 +2069,6 @@ int ocRunFini_ELF( ObjectCode *oc ) return true; } -/* - * Shared object loading - */ - -#if defined(HAVE_DLINFO) -struct piterate_cb_info { - ObjectCode *nc; - void *l_addr; /* base virtual address of the loaded code */ -}; - -static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size STG_UNUSED, void *data) { - struct piterate_cb_info *s = (struct piterate_cb_info *) data; - - // This logic mimicks _dl_addr_inside_object from glibc - // For reference: - // int - // internal_function - // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) - // { - // int n = l->l_phnum; - // const ElfW(Addr) reladdr = addr - l->l_addr; - // - // while (--n >= 0) - // if (l->l_phdr[n].p_type == PT_LOAD - // && reladdr - l->l_phdr[n].p_vaddr >= 0 - // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) - // return 1; - // return 0; - // } - - if ((void*) info->dlpi_addr == s->l_addr) { - int n = info->dlpi_phnum; - while (--n >= 0) { - if (info->dlpi_phdr[n].p_type == PT_LOAD) { - NativeCodeRange* ncr = - stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); - ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); - ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); - - ncr->next = s->nc->nc_ranges; - s->nc->nc_ranges = ncr; - } - } - } - return 0; -} -#endif /* defined(HAVE_DLINFO) */ - -static void copyErrmsg(char** errmsg_dest, char* errmsg) { - if (errmsg == NULL) errmsg = "loadNativeObj_ELF: unknown error"; - *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_ELF"); - strcpy(*errmsg_dest, errmsg); -} - -// need dl_mutex -void freeNativeCode_ELF (ObjectCode *nc) { - dlclose(nc->dlopen_handle); - - NativeCodeRange *ncr = nc->nc_ranges; - while (ncr) { - NativeCodeRange* last_ncr = ncr; - ncr = ncr->next; - stgFree(last_ncr); - } -} - -void * loadNativeObj_ELF (pathchar *path, char **errmsg) -{ - ObjectCode* nc; - void *hdl, *retval; - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF %" PATH_FMT "\n", path)); - - retval = NULL; - ACQUIRE_LOCK(&dl_mutex); - - /* Loading the same object multiple times will lead to chaos - * as we will have two ObjectCodes but one underlying dlopen - * handle. Fail if this happens. - */ - if (getObjectLoadStatus_(path) != OBJECT_NOT_LOADED) { - copyErrmsg(errmsg, "loadNativeObj_ELF: Already loaded"); - goto dlopen_fail; - } - - nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); - - foreignExportsLoadingObject(nc); - hdl = dlopen(path, RTLD_NOW|RTLD_LOCAL); - nc->dlopen_handle = hdl; - foreignExportsFinishedLoadingObject(); - if (hdl == NULL) { - /* dlopen failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlopen_fail; - } - -#if defined(HAVE_DLINFO) - struct link_map *map; - if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { - /* dlinfo failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlinfo_fail; - } - - hdl = NULL; // pass handle ownership to nc - - struct piterate_cb_info piterate_info = { - .nc = nc, - .l_addr = (void *) map->l_addr - }; - dl_iterate_phdr(loadNativeObjCb_, &piterate_info); - if (!nc->nc_ranges) { - copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); - goto dl_iterate_phdr_fail; - } - nc->unloadable = true; -#else - nc->nc_ranges = NULL; - nc->unloadable = false; -#endif /* defined (HAVE_DLINFO) */ - - insertOCSectionIndices(nc); - - nc->next_loaded_object = loaded_objects; - loaded_objects = nc; - - retval = nc->dlopen_handle; - -#if defined(PROFILING) - // collect any new cost centres that were defined in the loaded object. - refreshProfilingCCSs(); -#endif - - goto success; - -dl_iterate_phdr_fail: - // already have dl_mutex - freeNativeCode_ELF(nc); -dlinfo_fail: - if (hdl) dlclose(hdl); -dlopen_fail: -success: - - RELEASE_LOCK(&dl_mutex); - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF result=%p\n", retval)); - - return retval; -} - - /* * PowerPC & X86_64 ELF specifics */ @@ -2271,4 +2118,70 @@ int ocAllocateExtras_ELF( ObjectCode *oc ) #endif /* NEED_SYMBOL_EXTRAS */ +void * loadNativeObjFromLinkerScript_ELF(char **errmsg) +{ + // GHC #2615 + // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) + // contain linker scripts rather than ELF-format object code. This + // code handles the situation by recognizing the real object code + // file name given in the linker script. + // + // If an "invalid ELF header" error occurs, it is assumed that the + // .so file contains a linker script instead of ELF object code. + // In this case, the code looks for the GROUP ( ... ) linker + // directive. If one is found, the first file name inside the + // parentheses is treated as the name of a dynamic library and the + // code attempts to dlopen that file. If this is also unsuccessful, + // an error message is returned. + +#define NMATCH 5 + regmatch_t match[NMATCH]; + FILE* fp; + size_t match_length; +#define MAXLINE 1000 + char line[MAXLINE]; + int result; + void* r = NULL; + + ASSERT_LOCK_HELD(&linker_mutex) + + // see if the error message is due to an invalid ELF header + IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); + result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); + IF_DEBUG(linker, debugBelch("result = %i\n", result)); + if (result == 0) { + // success -- try to read the named file as a linker script + match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), + MAXLINE-1); + strncpy(line, (*errmsg+(match[1].rm_so)),match_length); + line[match_length] = '\0'; // make sure string is null-terminated + IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); + if ((fp = __rts_fopen(line, "r")) == NULL) { + // return original error if open fails + return NULL; + } + // try to find a GROUP or INPUT ( ... ) command + while (fgets(line, MAXLINE, fp) != NULL) { + IF_DEBUG(linker, debugBelch("input line = %s", line)); + if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { + // success -- try to dlopen the first named file + IF_DEBUG(linker, debugBelch("match%s\n","")); + line[match[2].rm_eo] = '\0'; + stgFree((void*)*errmsg); // Free old message before creating new one + // ROMES:TODO: NO GOOD, this is almost recursive? no, as long we + // move the loadNativeObj_ELF to a shared impl + r = loadNativeObj_POSIX(line+match[2].rm_so, errmsg); + break; + } + // if control reaches here, no GROUP or INPUT ( ... ) directive + // was found and the original error message is returned to the + // caller + } + fclose(fp); + } + + return r; +} + + #endif /* elf */ ===================================== rts/linker/Elf.h ===================================== @@ -14,7 +14,6 @@ int ocResolve_ELF ( ObjectCode* oc ); int ocRunInit_ELF ( ObjectCode* oc ); int ocRunFini_ELF ( ObjectCode* oc ); int ocAllocateExtras_ELF ( ObjectCode *oc ); -void freeNativeCode_ELF ( ObjectCode *nc ); -void *loadNativeObj_ELF ( pathchar *path, char **errmsg ); +void *loadNativeObjFromLinkerScript_ELF( char **errmsg ); #include "EndPrivate.h" ===================================== rts/linker/LoadNativeObjPosix.c ===================================== @@ -0,0 +1,211 @@ +#include "CheckUnload.h" +#include "ForeignExports.h" +#include "LinkerInternals.h" +#include "Rts.h" +#include "RtsUtils.h" +#include "Profiling.h" + +#include "linker/LoadNativeObjPosix.h" + +#if defined(HAVE_DLFCN_H) +#include +#endif + +#include + +#if defined(THREADED_RTS) +extern Mutex linker_mutex; +#endif + +/* + * Shared object loading + */ + +#if defined(HAVE_DLINFO) +struct piterate_cb_info { + ObjectCode *nc; + void *l_addr; /* base virtual address of the loaded code */ +}; + +static int loadNativeObjCb_(struct dl_phdr_info *info, + size_t _size STG_UNUSED, void *data) { + struct piterate_cb_info *s = (struct piterate_cb_info *) data; + + // This logic mimicks _dl_addr_inside_object from glibc + // For reference: + // int + // internal_function + // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) + // { + // int n = l->l_phnum; + // const ElfW(Addr) reladdr = addr - l->l_addr; + // + // while (--n >= 0) + // if (l->l_phdr[n].p_type == PT_LOAD + // && reladdr - l->l_phdr[n].p_vaddr >= 0 + // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) + // return 1; + // return 0; + // } + + if ((void*) info->dlpi_addr == s->l_addr) { + int n = info->dlpi_phnum; + while (--n >= 0) { + if (info->dlpi_phdr[n].p_type == PT_LOAD) { + NativeCodeRange* ncr = + stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); + ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); + ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); + + ncr->next = s->nc->nc_ranges; + s->nc->nc_ranges = ncr; + } + } + } + return 0; +} +#endif /* defined(HAVE_DLINFO) */ + +static void copyErrmsg(char** errmsg_dest, char* errmsg) { + if (errmsg == NULL) errmsg = "loadNativeObj_POSIX: unknown error"; + *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_POSIX"); + strcpy(*errmsg_dest, errmsg); +} + +void freeNativeCode_POSIX (ObjectCode *nc) { + ASSERT_LOCK_HELD(&linker_mutex); + + dlclose(nc->dlopen_handle); + + NativeCodeRange *ncr = nc->nc_ranges; + while (ncr) { + NativeCodeRange* last_ncr = ncr; + ncr = ncr->next; + stgFree(last_ncr); + } +} + +void * loadNativeObj_POSIX (pathchar *path, char **errmsg) +{ + ObjectCode* nc; + void *hdl, *retval; + + ASSERT_LOCK_HELD(&linker_mutex); + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX %" PATH_FMT "\n", path)); + + retval = NULL; + + + /* If we load the same object multiple times, just return the + * already-loaded handle. Note that this is broken if unloadNativeObj + * is used, as we don’t do any reference counting; see #24345. + */ + ObjectCode *existing_oc = lookupObjectByPath(path); + if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { + if (existing_oc->type == DYNAMIC_OBJECT) { + retval = existing_oc->dlopen_handle; + goto success; + } + copyErrmsg(errmsg, "loadNativeObj_POSIX: already loaded as non-dynamic object"); + goto dlopen_fail; + } + + nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); + + foreignExportsLoadingObject(nc); + + // When dlopen() loads a profiled dynamic library, it calls the ctors which + // will call registerCcsList() to append the defined CostCentreStacks to + // CCS_LIST. However, another thread may be doing other things with the RTS + // linker that transitively calls refreshProfilingCCSs() which also accesses + // CCS_LIST. So there's a risk of data race that may lead to segfaults + // (#24423), and we need to ensure the ctors are also protected by + // ccs_mutex. +#if defined(PROFILING) + ACQUIRE_LOCK(&ccs_mutex); +#endif + + // If we HAVE_DLINFO, we use RTLD_NOW rather than RTLD_LAZY because we want + // to learn eagerly about all external functions. Otherwise, there is no + // additional advantage to being eager, so it is better to be lazy and only bind + // functions when needed for better performance. + int dlopen_mode; +#if defined(HAVE_DLINFO) + dlopen_mode = RTLD_NOW; +#else + dlopen_mode = RTLD_LAZY; +#endif + + hdl = dlopen(path, dlopen_mode|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + nc->dlopen_handle = hdl; + nc->status = OBJECT_READY; + +#if defined(PROFILING) + RELEASE_LOCK(&ccs_mutex); +#endif + + foreignExportsFinishedLoadingObject(); + + if (hdl == NULL) { + /* dlopen failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlopen_fail; + } + +#if defined(HAVE_DLINFO) + struct link_map *map; + if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { + /* dlinfo failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlinfo_fail; + } + + hdl = NULL; // pass handle ownership to nc + + struct piterate_cb_info piterate_info = { + .nc = nc, + .l_addr = (void *) map->l_addr + }; + dl_iterate_phdr(loadNativeObjCb_, &piterate_info); + if (!nc->nc_ranges) { + copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); + goto dl_iterate_phdr_fail; + } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; +#endif /* defined (HAVE_DLINFO) */ + + insertOCSectionIndices(nc); + + nc->next_loaded_object = loaded_objects; + loaded_objects = nc; + + retval = nc->dlopen_handle; + +#if defined(PROFILING) + // collect any new cost centres that were defined in the loaded object. + refreshProfilingCCSs(); +#endif + + goto success; + +#if defined(HAVE_DLINFO) +dl_iterate_phdr_fail: +#endif + freeNativeCode_POSIX(nc); +#if defined(HAVE_DLINFO) +dlinfo_fail: +#endif + if (hdl) dlclose(hdl); +dlopen_fail: +success: + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX result=%p\n", retval)); + + return retval; +} + + ===================================== rts/linker/LoadNativeObjPosix.h ===================================== @@ -0,0 +1,11 @@ +#pragma once + +#include "Rts.h" +#include "LinkerInternals.h" + +#include "BeginPrivate.h" + +void freeNativeCode_POSIX ( ObjectCode *nc ); +void *loadNativeObj_POSIX ( pathchar *path, char **errmsg ); + +#include "EndPrivate.h" ===================================== rts/linker/PEi386.c ===================================== @@ -1865,6 +1865,7 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if (result != NULL || dllInstance == 0) { errorBelch("Could not load `%s'. Reason: %s\n", (char*)dllName, result); + stgFree(result); return false; } ===================================== rts/rts.cabal ===================================== @@ -458,6 +458,7 @@ library linker/Elf.c linker/InitFini.c linker/LoadArchive.c + linker/LoadNativeObjPosix.c linker/M32Alloc.c linker/MMap.c linker/MachO.c ===================================== testsuite/tests/ghci/linking/dyn/T3372.hs ===================================== @@ -1,3 +1,6 @@ +-- Note: This test exercises running concurrent GHCi sessions, but +-- although this test is expected to pass, running concurrent GHCi +-- sessions is currently broken in other ways; see #24345. {-# LANGUAGE MagicHash #-} module Main where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d408a07a0b5e9888d1c33a7a202880c06869b317...f49e5a187adeebb9015c25ea90b0fb6638e4c553 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d408a07a0b5e9888d1c33a7a202880c06869b317...f49e5a187adeebb9015c25ea90b0fb6638e4c553 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 17:49:14 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 20 Mar 2024 13:49:14 -0400 Subject: [Git][ghc/ghc][wip/T24553] Wibbles Message-ID: <65fb219a5d8cb_145d5e5f57760766c0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: da67e176 by Simon Peyton Jones at 2024-03-20T17:48:58+00:00 Wibbles - - - - - 3 changed files: - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Iface/Type.hs Changes: ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -22,7 +22,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -153,6 +154,7 @@ tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where @@ -181,8 +183,8 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- with True; that result makes GHC print the type with all foralls and -- kinds. See Note [Showing invisible bits of types in error messages] -- in GHC.Tc.Errors.Ppr - go _ (ForAllTy {}) _ | vis_only = True - go _ _ (ForAllTy {})| vis_only = True + go _ (ForAllTy b _) _ | vis_only, isDefaultableBndr b = True + go _ _ (ForAllTy b _) | vis_only, isDefaultableBndr b = True -- Make sure we handle all FunTy cases since falling through to the -- AppTy case means that tcSplitAppTyNoView_maybe may see an unzonked @@ -229,8 +231,13 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. - +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This should line up with the defaulting done +-- by GHC.Iface.Type.deafultIfaceTyVarsOfKind +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -336,8 +336,7 @@ pprTypeApp tc tys pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitForalls = True - , sdocPrintExplicitKinds = True + if b then ctx { sdocPrintExplicitKinds = True , sdocPrintExplicitRuntimeReps = True } else ctx ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da67e1766b2eeaa819ec84ab226f0874820e73bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da67e1766b2eeaa819ec84ab226f0874820e73bc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 19:21:21 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Wed, 20 Mar 2024 15:21:21 -0400 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Skip divbyzero test (like most archs) Message-ID: <65fb37311cc54_145d5e861f848849fd@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: d77e95a4 by Sven Tennie at 2024-03-20T20:16:08+01:00 Skip divbyzero test (like most archs) - - - - - 1 changed file: - testsuite/tests/rts/all.T Changes: ===================================== testsuite/tests/rts/all.T ===================================== @@ -62,6 +62,10 @@ test('divbyzero', # each devision. Neither gcc, nor llvm do this as of right now. Microsoft # apparently does so though? when(arch('aarch64'), skip), + # RISCV64 has no exception for this, too. Instead all bits of the result + # are set. As with Aarch64 neither GCC nor LLVM translate this result to + # an exception. + when(arch('riscv64'), skip), # Apparently the output can be different on different # Linux setups, so just ignore it. As long as we get # the right exit code we're OK. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d77e95a42e9e4cfad5e36e64c5dff4ae57d00bd7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d77e95a42e9e4cfad5e36e64c5dff4ae57d00bd7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 19:36:53 2024 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Wed, 20 Mar 2024 15:36:53 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/fix-t24570 Message-ID: <65fb3ad5c86ee_145d5e8e368c4863dd@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/fix-t24570 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/fix-t24570 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 22:12:33 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 20 Mar 2024 18:12:33 -0400 Subject: [Git][ghc/ghc][wip/T24553] Print more info about kinds in error messages Message-ID: <65fb5f51b6434_145d5ed4a45041144c9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: a38450dc by Simon Peyton Jones at 2024-03-20T22:12:16+00:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 10 changed files: - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Utils/TcType.hs - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -22,7 +22,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -153,6 +154,7 @@ tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where @@ -177,6 +179,17 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 && (vis_only || go env (varType tv1) (varType tv2)) && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- If we have (forall (r::RunTimeRep. ty1 ~ blah) then respond + -- (surprisingly) with True. Reason: the type pretty-printer defaults + -- RuntimeRep foralls (see Ghc.iface.Type.hideNonStandardTypes). That + -- can make, say (forall r. TYPE r -> Type) into (Type -> Type), so it + -- looks the same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of tcEqTypeVis) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | vis_only, isDefaultableBndr b = True + go _ _ (ForAllTy b _) | vis_only, isDefaultableBndr b = True + -- Make sure we handle all FunTy cases since falling through to the -- AppTy case means that tcSplitAppTyNoView_maybe may see an unzonked -- kind variable, which causes things to blow up. @@ -222,8 +235,15 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. - +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,59 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = tcEqTypeVis ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by `GHC.Core.TyCo.Compare.tcEqTypeVis` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6088,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6171,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6433,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6457,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a38450dc9f054949d091006efdf219d07fc6d9d1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a38450dc9f054949d091006efdf219d07fc6d9d1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 20 22:44:06 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 20 Mar 2024 18:44:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: hadrian/bindist: Eliminate extraneous `dirname` invocation Message-ID: <65fb66b65e984_145d5ee35000812561d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 84e6af81 by Alan Zimmerman at 2024-03-20T18:43:30-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - 4373a99b by Vladislav Zavialov at 2024-03-20T18:43:31-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 17 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Types/Name/Occurrence.hs - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs - m4/fp_settings.m4 - + testsuite/tests/th/T24559.hs - testsuite/tests/th/all.T - + testsuite/tests/vdq-rta/should_compile/T24570.hs - testsuite/tests/vdq-rta/should_compile/all.T - utils/check-exact/ExactPrint.hs Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -36,6 +36,7 @@ import os import yaml import gitlab from urllib.request import urlopen +from urllib.parse import urlparse import hashlib import sys import json @@ -80,7 +81,7 @@ source_artifact = Artifact('source-tarball' test_artifact = Artifact('source-tarball' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' - , 'ghc-{version}' ) + , 'ghc-{version}/testsuite' ) def debian(arch, n): return linux_platform(arch, "{arch}-linux-deb{n}".format(arch=arch, n=n)) @@ -156,13 +157,18 @@ def mk_one_metadata(release_mode, version, job_map, artifact): eprint(f"Bindist URL: {url}") eprint(f"Download URL: {final_url}") - #Download and hash from the release pipeline, this must not change anyway during upload. + # Download and hash from the release pipeline, this must not change anyway during upload. h = download_and_hash(url) res = { "dlUri": final_url , "dlSubdir": artifact.subdir.format(version=version) - , "dlOutput": artifact.output_name.format(version=version) , "dlHash" : h } + + # Only add dlOutput if it is inconsistent with the filename inferred from the URL + output = artifact.output_name.format(version=version) + if Path(urlparse(final_url).path).name != output: + res["dlOutput"] = output + eprint(res) return res ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -9,21 +9,22 @@ usage : %.gz : %.xz echo "[xz->gz] $< to $@..." - xz -c $< | gzip -c > $@ + xz -cd $< | gzip -c > $@ %.bz2 : %.xz echo "[xz->bz2] $< to $@..." - xz -c $< | bzip2 -c > $@ + xz -cd $< | bzip2 -c > $@ %.lz : %.xz echo "[xz->lz] $< to $@..." - xz -c $< | lzip -c > $@ + xz -cd $< | lzip -c > $@ %.zip : %.tar.xz echo "[tarxz->zip] $< to $@..." - tmp="$(mktemp tmp.XXX)" && \ + tmp="$$(mktemp tmp.XXX)" && \ tar -C "$$tmp" -xf $< && \ cd "$$tmp" && \ zip -9 -r $@ * && \ + cd .. && \ rm -R "$$tmp" ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -145,7 +145,7 @@ function purge_all() { curl -X PURGE http://downloads.haskell.org/~ghc/$dir curl -X PURGE http://downloads.haskell.org/~ghc/$dir/ for i in *; do - purge_file $i + purge_file "$i" done } @@ -158,43 +158,14 @@ function purge_file() { ) for dir in ${dirs[@]}; do - curl -X PURGE http://downloads.haskell.org/$dir/$i - curl -X PURGE http://downloads.haskell.org/$dir/$i/ - curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + curl -X PURGE http://downloads.haskell.org/$dir/$1 + curl -X PURGE http://downloads.haskell.org/$dir/$1/ + curl -X PURGE http://downloads.haskell.org/$dir/$1/docs/ done } function prepare_docs() { echo "THIS COMMAND IS DEPRECATED, THE DOCS FOLDER SHOULD BE PREPARED BY THE FETCH SCRIPT" - local tmp - rm -Rf docs - if [ -z "$GHC_TREE" ]; then - tmp="$(mktemp -d)" - tar -xf "ghc-$ver-src.tar.xz" -C "$tmp" - GHC_TREE="$tmp/ghc-$ver" - fi - mkdocs="$GHC_TREE/distrib/mkDocs/mkDocs" - if [ ! -e "$mkdocs" ]; then - echo "Couldn't find GHC mkDocs at $mkdocs." - echo "Perhaps you need to override GHC_TREE?" - rm -Rf "$tmp" - exit 1 - fi - windows_bindist="$(ls ghc-$ver-x86_64-unknown-mingw32.tar.xz | head -n1)" - linux_bindist="$(ls ghc-$ver-x86_64-deb9-linux.tar.xz | head -n1)" - echo "Windows bindist: $windows_bindist" - echo "Linux bindist: $linux_bindist" - $ENTER_FHS_ENV $mkdocs $linux_bindist $windows_bindist - if [ -d "$tmp" ]; then rm -Rf "$tmp"; fi - - mkdir -p docs/html - tar -Jxf "$linux_bindist" - cp -R "ghc-$ver/docs/users_guide/build-html/users_guide docs/html/users_guide" - #cp -R ghc-$ver/utils/haddock/doc/haddock docs/html/haddock - rm -R "ghc-$ver" - - tar -Jxf docs/libraries.html.tar.xz -C docs/html - mv docs/index.html docs/html } function recompress() { @@ -213,7 +184,7 @@ function recompress() { needed+=( "$(basename $i .tar.xz).zip" ) done - recompress-all -l ${needed[@]} + recompress-all -j10 ${needed[@]} } function upload_docs() { ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -728,6 +728,12 @@ ifaceVisAppArgsLength = go 0 | isVisibleForAllTyFlag argf = go (n+1) rest | otherwise = go n rest +ifaceAppArgsLength :: IfaceAppArgs -> Int +ifaceAppArgsLength = go 0 + where + go !n IA_Nil = n + go !n (IA_Arg _ _ ts) = go (n + 1) ts + {- Note [Suppressing invisible arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2090,21 +2096,27 @@ instance Binary IfaceTyLit where _ -> panic ("get IfaceTyLit " ++ show tag) instance Binary IfaceAppArgs where - put_ bh tk = - case tk of - IA_Arg t a ts -> putByte bh 0 >> put_ bh t >> put_ bh a >> put_ bh ts - IA_Nil -> putByte bh 1 + put_ bh tk = do + -- Int is variable length encoded so only + -- one byte for small lists. + put_ bh (ifaceAppArgsLength tk) + go tk + where + go IA_Nil = pure () + go (IA_Arg a b t) = do + put_ bh a + put_ bh b + go t - get bh = - do c <- getByte bh - case c of - 0 -> do - t <- get bh - a <- get bh - ts <- get bh - return $! IA_Arg t a ts - 1 -> return IA_Nil - _ -> panic ("get IfaceAppArgs " ++ show c) + get bh = do + n <- get bh :: IO Int + go n + where + go 0 = return IA_Nil + go c = do + a <- get bh + b <- get bh + IA_Arg a b <$> go (c - 1) ------------------- ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -30,7 +30,7 @@ import GHC.Prelude import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import {-# SOURCE #-} GHC.Tc.Gen.Splice - ( tcTypedSplice, tcTypedBracket, tcUntypedBracket ) + ( tcTypedSplice, tcTypedBracket, tcUntypedBracket, getUntypedSpliceBody ) import GHC.Hs import GHC.Hs.Syn.Type @@ -169,6 +169,12 @@ tcPolyExprCheck expr res_ty do { e' <- tc_body e ; return (HsPar x (L loc e')) } + -- Look through any untyped splices (#24559) + -- c.f. Note [Looking through Template Haskell splices in splitHsApps] + tc_body (HsUntypedSplice splice_res _) + = do { body <- getUntypedSpliceBody splice_res + ; tc_body body } + -- The special case for lambda: go to tcLambdaMatches, passing pat_tys tc_body e@(HsLam x lam_variant matches) = do { (wrap, matches') <- tcLambdaMatches e lam_variant matches pat_tys @@ -673,11 +679,8 @@ tcExpr (HsUntypedSplice splice _) res_ty -- for `HsUntypedSplice`; to see why, read Wrinkle (UTS1) in -- Note [Looking through Template Haskell splices in splitHsApps] in -- GHC.Tc.Gen.Head. - = case splice of - HsUntypedSpliceTop mod_finalizers expr - -> do { addModFinalizersWithLclEnv mod_finalizers - ; tcExpr expr res_ty } - HsUntypedSpliceNested {} -> panic "tcExpr: invalid nested splice" + = do { expr <- getUntypedSpliceBody splice + ; tcExpr expr res_ty } {- ************************************************************************ ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -30,6 +30,7 @@ module GHC.Tc.Gen.Head , addHeadCtxt, addExprCtxt, addStmtCtxt, addFunResCtxt ) where import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcExpr, tcCheckPolyExprNC, tcPolyLExprSig ) +import {-# SOURCE #-} GHC.Tc.Gen.Splice( getUntypedSpliceBody ) import GHC.Prelude import GHC.Hs @@ -310,15 +311,11 @@ splitHsApps e = go e (top_ctxt 0 e) [] -- See Note [Looking through Template Haskell splices in splitHsApps] go e@(HsUntypedSplice splice_res splice) ctxt args - = case splice_res of - HsUntypedSpliceTop mod_finalizers fun - -> do addModFinalizersWithLclEnv mod_finalizers - go fun ctxt' (EWrap (EExpand (OrigExpr e)) : args) - HsUntypedSpliceNested {} -> panic "splitHsApps: invalid nested splice" + = do { fun <- getUntypedSpliceBody splice_res + ; go fun ctxt' (EWrap (EExpand (OrigExpr e)) : args) } where ctxt' :: AppCtxt - ctxt' = - case splice of + ctxt' = case splice of HsUntypedSpliceExpr _ (L l _) -> set l ctxt -- l :: SrcAnn AnnListItem HsQuasiQuote _ _ (L l _) -> set l ctxt -- l :: SrcAnn NoEpAnns @@ -840,7 +837,7 @@ handling splices and quasiquotes has already been performed by the renamer by the time we get to `splitHsApps`. Wrinkle (UTS1): - `tcExpr` has a separate case for `HsUntypedSplice`s that do not occur at the + `tcExpr` has a separate case for `HsUntypedSplice`s that do /not/ occur at the head of an application. This is important to handle programs like this one: foo :: (forall a. a -> a) -> b -> b ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -21,7 +21,7 @@ -- | Template Haskell splices module GHC.Tc.Gen.Splice( tcTypedSplice, tcTypedBracket, tcUntypedBracket, - runAnnotation, + runAnnotation, getUntypedSpliceBody, runMetaE, runMetaP, runMetaT, runMetaD, runQuasi, tcTopSpliceExpr, lookupThName_maybe, @@ -639,13 +639,16 @@ Example: ************************************************************************ -} +-- None of these functions add constraints to the LIE + tcTypedBracket :: HsExpr GhcRn -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcUntypedBracket :: HsExpr GhcRn -> HsQuote GhcRn -> [PendingRnSplice] -> ExpRhoType -> TcM (HsExpr GhcTc) -tcTypedSplice :: Name -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) - -- None of these functions add constraints to the LIE +tcTypedSplice :: Name -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) + +getUntypedSpliceBody :: HsUntypedSpliceResult (HsExpr GhcRn) -> TcM (HsExpr GhcRn) +runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation -runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation {- ************************************************************************ * * @@ -815,6 +818,16 @@ quotationCtxtDoc br_body ************************************************************************ -} +-- getUntypedSpliceBody: the renamer has expanded the splice. +-- Just run the finalizers that it produced, and return +-- the renamed expression +getUntypedSpliceBody (HsUntypedSpliceTop { utsplice_result_finalizers = mod_finalizers + , utsplice_result = rn_expr }) + = do { addModFinalizersWithLclEnv mod_finalizers + ; return rn_expr } +getUntypedSpliceBody (HsUntypedSpliceNested {}) + = panic "tcTopUntypedSplice: invalid nested splice" + tcTypedSplice splice_name expr res_ty = addErrCtxt (typedSpliceCtxtDoc splice_name expr) $ setSrcSpan (getLocA expr) $ do ===================================== compiler/GHC/Tc/Gen/Splice.hs-boot ===================================== @@ -10,7 +10,7 @@ import GHC.Tc.Utils.TcType ( ExpRhoType ) import GHC.Types.Annotations ( Annotation, CoreAnnTarget ) import GHC.Hs.Extension ( GhcRn, GhcPs, GhcTc ) -import GHC.Hs ( HsQuote, HsExpr, LHsExpr, LHsType, LPat, LHsDecl, ThModFinalizers ) +import GHC.Hs ( HsQuote, HsExpr, LHsExpr, LHsType, LPat, LHsDecl, ThModFinalizers, HsUntypedSpliceResult ) import qualified Language.Haskell.TH as TH tcTypedSplice :: Name @@ -30,7 +30,8 @@ tcUntypedBracket :: HsExpr GhcRn runTopSplice :: DelayedSplice -> TcM (HsExpr GhcTc) -runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation +runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation +getUntypedSpliceBody :: HsUntypedSpliceResult (HsExpr GhcRn) -> TcM (HsExpr GhcRn) tcTopSpliceExpr :: SpliceType -> TcM (LHsExpr GhcTc) -> TcM (LHsExpr GhcTc) ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -516,7 +516,9 @@ demoteOccTvName (OccName space name) = do -- See Note [Promotion] in GHC.Rename.Env. promoteOccName :: OccName -> Maybe OccName promoteOccName (OccName space name) = do - space' <- promoteNameSpace space + promoted_space <- promoteNameSpace space + let tyop = isTvNameSpace promoted_space && isLexVarSym name + space' = if tyop then tcClsName else promoted_space -- special case for type operators (#24570) return $ OccName space' name {- | Other names in the compiler add additional information to an OccName. ===================================== hadrian/bindist/Makefile ===================================== @@ -176,18 +176,19 @@ install_lib: lib/settings @dest="$(DESTDIR)$(ActualLibsDir)"; \ cd lib; \ for i in `$(FIND) . -type f`; do \ - $(INSTALL_DIR) "$$dest/`dirname $$i`" ; \ + dir="`dirname $$i`" ; \ + $(INSTALL_DIR) "$$dest/$$dir" ; \ case $$i in \ *.a) \ - $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_DATA) $$i "$$dest/$$dir" ; \ $(RANLIB_CMD) "$$dest"/$$i ;; \ *.dll) \ - $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \ + $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \ $(STRIP_CMD) "$$dest"/$$i ;; \ *.so) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.dylib) \ - $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \ + $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \ *.mjs) \ $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \ *) \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -135,7 +135,8 @@ bindistRules = do let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty installTo Relocatable prefix - + copyDirectory (root -/- "mingw") prefix + liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw") phony "install" $ do need ["binary-dist-dir"] @@ -145,8 +146,6 @@ bindistRules = do installTo NotRelocatable installPrefix phony "binary-dist-dir" $ do - - version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 @@ -309,7 +308,7 @@ bindistRules = do let buildBinDist compressor = do win_target <- isWinTarget - when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.") + when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.") buildBinDistX "binary-dist-dir" "bindist" compressor buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" ===================================== m4/fp_settings.m4 ===================================== @@ -44,7 +44,7 @@ dnl ghc-toolchain. AC_DEFUN([SUBST_TOOLDIR], [ dnl and Note [How we configure the bundled windows toolchain] -set -- "$(echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g')" + $1=`echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'` ]) # FP_SETTINGS ===================================== testsuite/tests/th/T24559.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeAbstractions #-} +module Foo where + +import Data.Kind +import Data.Proxy + +f :: (forall (a :: Type). Proxy a) -> Proxy Bool +f k = k @Bool + +g1 :: Proxy Bool +g1 = f (\ @a -> Proxy @a) + +g2 :: Proxy Bool +g2 = f $([| \ @a -> Proxy @a |]) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24559', normal, compile, ['']) ===================================== testsuite/tests/vdq-rta/should_compile/T24570.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE RequiredTypeArguments #-} + +module T24570 where + +import Language.Haskell.TH + +idee :: forall a -> a -> a +idee _ x = x + +type (:!@#) = Bool + +f :: Bool -> Bool +f = idee (:!@#) + +type (!@#) = Bool + +g :: Bool -> Bool +g = idee (!@#) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -22,6 +22,7 @@ test('T23739_sizeOf', normal, compile, ['']) test('T23739_symbolVal', normal, compile, ['']) test('T23739_typeRep', normal, compile, ['']) test('T23739_nested', normal, compile, ['']) +test('T24570', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T23739_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -740,15 +740,12 @@ markExternalSourceText l (SourceText txt) _ = printStringAtRs (realSrcSpan l) (u -- --------------------------------------------------------------------- -markLensMAA :: (Monad m, Monoid w) => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) -markLensMAA (EpAnn anc a cs) l = - case view l a of - Nothing -> return (EpAnn anc a cs) - Just aa -> do - aa' <- markAddEpAnn aa - return (EpAnn anc (set l (Just aa') a) cs) +markLensMAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) +markLensMAA epann l = markLensMAA' epann (lepa . l) -markLensMAA' :: (Monad m, Monoid w) => a -> Lens a (Maybe AddEpAnn) -> EP w m a +markLensMAA' :: (Monad m, Monoid w) + => a -> Lens a (Maybe AddEpAnn) -> EP w m a markLensMAA' a l = case view l a of Nothing -> return a @@ -756,34 +753,27 @@ markLensMAA' a l = aa' <- markAddEpAnn aa return (set l (Just aa') a) -markLensAA :: (Monad m, Monoid w) => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensAA (EpAnn anc a cs) l = do - a' <- markKw (view l a) - return (EpAnn anc (set l a' a) cs) +-- ------------------------------------- + +markLensAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) +markLensAA epann l = markLensAA' epann (lepa . l) -markLensAA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a +markLensAA' :: (Monad m, Monoid w) + => a -> Lens a AddEpAnn -> EP w m a markLensAA' a l = do a' <- markKw (view l a) return (set l a' a) +-- ------------------------------------- markEpAnnLMS :: (Monad m, Monoid w) => EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS an l kw Nothing = markEpAnnL an l kw -markEpAnnLMS (EpAnn anc a cs) l kw (Just str) = do - anns <- mapM go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) +markEpAnnLMS epann l kw ms = markEpAnnLMS'' epann (lepa . l) kw ms markEpAnnLMS'' :: (Monad m, Monoid w) => a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS'' an l kw Nothing = markEpAnnL' an l kw +markEpAnnLMS'' an l kw Nothing = markEpAnnL an l kw markEpAnnLMS'' a l kw (Just str) = do anns <- mapM go (view l a) return (set l anns a) @@ -795,10 +785,11 @@ markEpAnnLMS'' a l kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- markEpAnnMS' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m [AddEpAnn] -markEpAnnMS' anns kw Nothing = mark' anns kw +markEpAnnMS' anns kw Nothing = mark anns kw markEpAnnMS' anns kw (Just str) = do mapM go anns where @@ -809,23 +800,15 @@ markEpAnnMS' anns kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- + markEpAnnLMS' :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS' an l _kw Nothing = markLensKwA an l -markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do - anns <- go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) + => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) +markEpAnnLMS' an l kw ms = markEpAnnLMS0 an (lepa . l) kw ms markEpAnnLMS0 :: (Monad m, Monoid w) - => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS0 an l _kw Nothing = markLensKwA' an l + => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a +markEpAnnLMS0 an l _kw Nothing = markLensKwA an l markEpAnnLMS0 a l kw (Just str) = do anns <- go (view l a) return (set l anns a) @@ -890,7 +873,8 @@ markAnnOpenP' :: (Monad m, Monoid w) => AnnPragma -> SourceText -> String -> EP markAnnOpenP' an NoSourceText txt = markEpAnnLMS0 an lapr_open AnnOpen (Just txt) markAnnOpenP' an (SourceText txt) _ = markEpAnnLMS0 an lapr_open AnnOpen (Just $ unpackFS txt) -markAnnOpen :: (Monad m, Monoid w) => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] +markAnnOpen :: (Monad m, Monoid w) + => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] markAnnOpen an NoSourceText txt = markEpAnnLMS'' an lidl AnnOpen (Just txt) markAnnOpen an (SourceText txt) _ = markEpAnnLMS'' an lidl AnnOpen (Just $ unpackFS txt) @@ -960,6 +944,16 @@ You can think of the function composition operator as having this type: -- --------------------------------------------------------------------- -- Lenses +-- data EpAnn ann +-- = EpAnn { entry :: !Anchor +-- , anns :: !ann +-- , comments :: !EpAnnComments +-- } + +lepa :: Lens (EpAnn a) a +lepa k epAnn = fmap (\newAnns -> epAnn { anns = newAnns }) + (k (anns epAnn)) + -- data AnnsModule -- = AnnsModule { -- am_main :: [AddEpAnn], @@ -1289,26 +1283,20 @@ lsumPatVbarsAfter k parent = fmap (\new -> parent { sumPatVbarsAfter = new }) -- --------------------------------------------------------------------- markLensKwA :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensKwA (EpAnn anc a cs) l = do - loc <- markKw (view l a) - return (EpAnn anc (set l loc a) cs) - -markLensKwA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a -markLensKwA' a l = do +markLensKwA a l = do loc <- markKw (view l a) return (set l loc a) -markLensKw :: (Monad m, Monoid w) +markLensKw' :: (Monad m, Monoid w) => EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a) -markLensKw (EpAnn anc a cs) l kw = do +markLensKw' (EpAnn anc a cs) l kw = do loc <- markKwA kw (view l a) return (EpAnn anc (set l loc a) cs) -markLensKw' :: (Monad m, Monoid w) +markLensKw :: (Monad m, Monoid w) => a -> Lens a EpaLocation -> AnnKeywordId -> EP w m a -markLensKw' a l kw = do +markLensKw a l kw = do loc <- markKwA kw (view l a) return (set l loc a) @@ -1338,18 +1326,18 @@ markLensKwM' a l kw = do -- --------------------------------------------------------------------- -markEpAnnL :: (Monad m, Monoid w) +markEpAnnL' :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) -markEpAnnL (EpAnn anc a cs) l kw = do - anns <- mark' (view l a) kw - return (EpAnn anc (set l anns a) cs) +markEpAnnL' epann l kw = markEpAnnL epann (lepa . l) kw -markEpAnnL' :: (Monad m, Monoid w) +markEpAnnL :: (Monad m, Monoid w) => ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m ann -markEpAnnL' a l kw = do - anns <- mark' (view l a) kw +markEpAnnL a l kw = do + anns <- mark (view l a) kw return (set l anns a) +-- ------------------------------------- + markEpAnnAllL :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) markEpAnnAllL (EpAnn anc a cs) l kw = do @@ -1374,13 +1362,13 @@ markEpAnnAllL' a l kw = do markAddEpAnn :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn markAddEpAnn a@(AddEpAnn kw _) = do - r <- mark' [a] kw + r <- mark [a] kw case r of [a'] -> return a' _ -> error "Should not happen: markAddEpAnn" -mark' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] -mark' anns kw = do +mark :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] +mark anns kw = do case find' kw anns of (lead, Just aa, end) -> do aa' <- markKw aa @@ -1637,14 +1625,14 @@ instance ExactPrint (HsModule GhcPs) where case mmn of Nothing -> return (an, mmn, mdeprec, mexports) Just m -> do - an0 <- markEpAnnL an lam_main AnnModule + an0 <- markEpAnnL' an lam_main AnnModule m' <- markAnnotated m mdeprec' <- setLayoutTopLevelP $ markAnnotated mdeprec mexports' <- setLayoutTopLevelP $ markAnnotated mexports - an1 <- setLayoutTopLevelP $ markEpAnnL an0 lam_main AnnWhere + an1 <- setLayoutTopLevelP $ markEpAnnL' an0 lam_main AnnWhere return (an1, Just m', mdeprec', mexports') @@ -1708,17 +1696,17 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where exact (L an (WarningTxt mb_cat src ws)) = do an0 <- markAnnOpenP an src "{-# WARNING" mb_cat' <- markAnnotated mb_cat - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (WarningTxt mb_cat' src ws')) exact (L an (DeprecatedTxt src ws)) = do an0 <- markAnnOpenP an src "{-# DEPRECATED" - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (DeprecatedTxt src ws')) @@ -1751,7 +1739,7 @@ instance ExactPrint (ImportDecl GhcPs) where exact (ImportDecl (XImportDeclPass ann msrc impl) modname mpkg src safeflag qualFlag mAs hiding) = do - ann0 <- markLensKw ann limportDeclAnnImport AnnImport + ann0 <- markLensKw' ann limportDeclAnnImport AnnImport let (EpAnn _anc an _cs) = ann0 -- "{-# SOURCE" and "#-}" @@ -1955,7 +1943,7 @@ exactDataFamInstDecl an top_lvl , Maybe (LHsContext GhcPs)) pp_hdr mctxt = do an0 <- case top_lvl of - TopLevel -> markEpAnnL' an lidl AnnInstance -- TODO: maybe in toplevel + TopLevel -> markEpAnnL an lidl AnnInstance -- TODO: maybe in toplevel NotTopLevel -> return an exactHsFamInstLHS an0 tycon bndrs pats fixity mctxt @@ -1978,9 +1966,9 @@ instance ExactPrint (DerivDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DerivDecl (mw, an) typ ms mov) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving ms' <- mapM markAnnotated ms - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance mw' <- mapM markAnnotated mw mov' <- mapM markAnnotated mov typ' <- markAnnotated typ @@ -1993,22 +1981,22 @@ instance ExactPrint (ForeignDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (ForeignImport an n ty fimport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnImport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnImport fimport' <- markAnnotated fimport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignImport an2 n' ty' fimport') exact (ForeignExport an n ty fexport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnExport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnExport fexport' <- markAnnotated fexport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignExport an2 n' ty' fexport') @@ -2080,18 +2068,18 @@ instance ExactPrint (WarnDecl GhcPs) where mb_cat' <- markAnnotated mb_cat ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (WarningTxt mb_cat' src ls')) -- return (Warning an1 lns' (WarningTxt mb_cat' src ls')) exact (Warning (ns_spec, an) lns (DeprecatedTxt src ls)) = do ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (DeprecatedTxt src ls')) -- return (Warning an1 lns' (DeprecatedTxt src ls')) @@ -2162,7 +2150,7 @@ instance ExactPrint (RuleDecl GhcPs) where an3 <- markLensMAA' an2 lra_tmanns_snd -- AnnDot lhs' <- markAnnotated lhs - an4 <- markEpAnnL' an3 lra_rest AnnEqual + an4 <- markEpAnnL an3 lra_rest AnnEqual rhs' <- markAnnotated rhs return (HsRule (an4,nsrc) (L ln' n) act mtybndrs' termbndrs' lhs' rhs') @@ -2171,20 +2159,20 @@ markActivation :: (Monad m, Monoid w) markActivation an l act = do case act of ActiveBefore src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ an2 <- markEpAnnLMS'' an1 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an3 <- markEpAnnL' an2 l AnnCloseS -- ']' + an3 <- markEpAnnL an2 l AnnCloseS -- ']' return an3 ActiveAfter src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' + an0 <- markEpAnnL an l AnnOpenS -- '[' an1 <- markEpAnnLMS'' an0 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 NeverActive -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 _ -> return an @@ -2214,8 +2202,8 @@ instance ExactPrint (RoleAnnotDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (RoleAnnotDecl an ltycon roles) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnRole + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnRole ltycon' <- markAnnotated ltycon let markRole (L l (Just r)) = do (L _ r') <- markAnnotated (L l r) @@ -2243,11 +2231,11 @@ instance ExactPrint (RuleBndr GhcPs) where ln' <- markAnnotated ln return (RuleBndr x ln') exact (RuleBndrSig an ln (HsPS x ty)) = do - an0 <- markEpAnnL' an lidl AnnOpenP -- "(" + an0 <- markEpAnnL an lidl AnnOpenP -- "(" ln' <- markAnnotated ln - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty - an2 <- markEpAnnL' an1 lidl AnnCloseP -- ")" + an2 <- markEpAnnL an1 lidl AnnCloseP -- ")" return (RuleBndrSig an2 ln' (HsPS x ty')) -- --------------------------------------------------------------------- @@ -2262,7 +2250,7 @@ instance (ExactPrint body) => ExactPrint (FamEqn GhcPs body) where , feqn_fixity = fixity , feqn_rhs = rhs }) = do (an0, tycon', bndrs', pats', _) <- exactHsFamInstLHS an tycon bndrs pats fixity Nothing - an1 <- markEpAnnL' an0 lidl AnnEqual + an1 <- markEpAnnL an0 lidl AnnEqual rhs' <- markAnnotated rhs return (FamEqn { feqn_ext = an1 , feqn_tycon = tycon' @@ -2286,9 +2274,9 @@ exactHsFamInstLHS :: , HsOuterTyVarBndrs () GhcPs , HsFamEqnPats GhcPs, Maybe (LHsContext GhcPs)) exactHsFamInstLHS an thing bndrs typats fixity mb_ctxt = do - an0 <- markEpAnnL' an lidl AnnForall + an0 <- markEpAnnL an lidl AnnForall bndrs' <- markAnnotated bndrs - an1 <- markEpAnnL' an0 lidl AnnDot + an1 <- markEpAnnL an0 lidl AnnDot mb_ctxt' <- mapM markAnnotated mb_ctxt (an2, thing', typats') <- exact_pats an1 typats return (an2, thing', bndrs', typats', mb_ctxt') @@ -2342,7 +2330,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where , cid_datafam_insts = adts }) = do (mbWarn', an0, mbOverlap', inst_ty') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lid AnnSemi ds <- withSortKey sortKey [(ClsAtdTag, prepareListAnnotationA ats), @@ -2350,7 +2338,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where (ClsMethodTag, prepareListAnnotationA (bagToList binds)), (ClsSigTag, prepareListAnnotationA sigs) ] - an3 <- markEpAnnL' an2 lidl AnnCloseC -- '}' + an3 <- markEpAnnL an2 lidl AnnCloseC -- '}' let ats' = undynamic ds adts' = undynamic ds @@ -2364,11 +2352,11 @@ instance ExactPrint (ClsInstDecl GhcPs) where where top_matter = do - an0 <- markEpAnnL' an lidl AnnInstance + an0 <- markEpAnnL an lidl AnnInstance mw <- mapM markAnnotated mbWarn mo <- mapM markAnnotated mbOverlap it <- markAnnotated inst_ty - an1 <- markEpAnnL' an0 lidl AnnWhere -- Optional + an1 <- markEpAnnL an0 lidl AnnWhere -- Optional return (mw, an1, mo,it) -- --------------------------------------------------------------------- @@ -2378,8 +2366,8 @@ instance ExactPrint (TyFamInstDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact d@(TyFamInstDecl { tfid_xtn = an, tfid_eqn = eqn }) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnInstance + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnInstance eqn' <- markAnnotated eqn return (d { tfid_xtn = an1, tfid_eqn = eqn' }) @@ -2456,7 +2444,7 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where , psb_id = psyn, psb_args = details , psb_def = pat , psb_dir = dir }) = do - an0 <- markEpAnnL' an lidl AnnPattern + an0 <- markEpAnnL an lidl AnnPattern (an1, psyn', details') <- case details of InfixCon v1 v2 -> do @@ -2471,25 +2459,25 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where return (an0, psyn', PrefixCon tvs' vs') RecCon vs -> do psyn' <- markAnnotated psyn - an1 <- markEpAnnL' an0 lidl AnnOpenC -- '{' + an1 <- markEpAnnL an0 lidl AnnOpenC -- '{' vs' <- markAnnotated vs - an2 <- markEpAnnL' an1 lidl AnnCloseC -- '}' + an2 <- markEpAnnL an1 lidl AnnCloseC -- '}' return (an2, psyn', RecCon vs') (an2, pat', dir') <- case dir of Unidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat return (an2, pat', dir) ImplicitBidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual pat' <- markAnnotated pat return (an2, pat', dir) ExplicitBidirectional mg -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat - an3 <- markEpAnnL' an2 lidl AnnWhere + an3 <- markEpAnnL an2 lidl AnnWhere mg' <- markAnnotated mg return (an3, pat', ExplicitBidirectional mg') @@ -2539,7 +2527,7 @@ exactMatch (Match an mctxt pats grhss) = do debugM $ "exact Match FunRhs:" ++ showPprUnsafe fun an0' <- case strictness of - SrcStrict -> markEpAnnL' an lidl AnnBang + SrcStrict -> markEpAnnL an lidl AnnBang _ -> pure an case fixity of Prefix -> do @@ -2556,18 +2544,18 @@ exactMatch (Match an mctxt pats grhss) = do p2' <- markAnnotated p2 return (an0', FunRhs fun' fixity strictness, [p1',p2']) | otherwise -> do - an0 <- markEpAnnL' an0' lidl AnnOpenP + an0 <- markEpAnnL an0' lidl AnnOpenP p1' <- markAnnotated p1 fun' <- markAnnotated fun p2' <- markAnnotated p2 - an1 <- markEpAnnL' an0 lidl AnnCloseP + an1 <- markEpAnnL an0 lidl AnnCloseP rest' <- mapM markAnnotated rest return (an1, FunRhs fun' fixity strictness, p1':p2':rest') _ -> panic "FunRhs" -- ToDo: why is LamSingle treated differently? LamAlt LamSingle -> do - an0' <- markEpAnnL' an lidl AnnLam + an0' <- markEpAnnL an lidl AnnLam pats' <- markAnnotated pats return (an0', LamAlt LamSingle, pats') LamAlt v -> do @@ -2624,7 +2612,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where exact (HsValBinds an valbinds) = do debugM $ "exact HsValBinds: an=" ++ showAst an - an0 <- markEpAnnL an lal_rest AnnWhere + an0 <- markEpAnnL' an lal_rest AnnWhere case al_anchor $ anns an of Just anc -> do @@ -2636,7 +2624,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where return (HsValBinds an1 valbinds') exact (HsIPBinds an bs) = do - (as, ipb) <- markAnnList an (markEpAnnL an lal_rest AnnWhere + (as, ipb) <- markAnnList an (markEpAnnL' an lal_rest AnnWhere >> markAnnotated bs >>= \bs' -> return (HsIPBinds an bs'::HsLocalBinds GhcPs)) case ipb of @@ -2677,7 +2665,7 @@ instance ExactPrint (IPBind GhcPs) where exact (IPBind an lr rhs) = do lr' <- markAnnotated lr - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual rhs' <- markAnnotated rhs return (IPBind an0 lr' rhs') @@ -2731,7 +2719,7 @@ instance ExactPrint (Sig GhcPs) where return (TypeSig an' vars' ty') exact (PatSynSig an lns typ) = do - an0 <- markEpAnnL' an lasRest AnnPattern + an0 <- markEpAnnL an lasRest AnnPattern lns' <- markAnnotated lns an1 <- markLensAA' an0 lasDcolon typ' <- markAnnotated typ @@ -2739,7 +2727,7 @@ instance ExactPrint (Sig GhcPs) where exact (ClassOpSig an is_deflt vars ty) | is_deflt = do - an0 <- markEpAnnL' an lasRest AnnDefault + an0 <- markEpAnnL an lasRest AnnDefault (an1, vars',ty') <- exactVarSig an0 vars ty return (ClassOpSig an1 is_deflt vars' ty') | otherwise = do @@ -2767,14 +2755,14 @@ instance ExactPrint (Sig GhcPs) where an0 <- markAnnOpen an (inl_src inl) "{-# SPECIALISE" -- Note: may be {-# SPECIALISE_INLINE an1 <- markActivation an0 lidl (inl_act inl) ln' <- markAnnotated ln - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon typs' <- markAnnotated typs an3 <- markEpAnnLMS'' an2 lidl AnnClose (Just "#-}") return (SpecSig an3 ln' typs' inl) exact (SpecInstSig (an,src) typ) = do an0 <- markAnnOpen an src "{-# SPECIALISE" - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance typ' <- markAnnotated typ an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") return (SpecInstSig (an2,src) typ') @@ -2799,7 +2787,7 @@ instance ExactPrint (Sig GhcPs) where case mty of Nothing -> return (an0, mty) Just ty -> do - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty return (an1, Just ty') an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") @@ -2822,9 +2810,9 @@ instance ExactPrint (StandaloneKindSig GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StandaloneKindSig an vars sig) = do - an0 <- markEpAnnL' an lidl AnnType + an0 <- markEpAnnL an lidl AnnType vars' <- markAnnotated vars - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon sig' <- markAnnotated sig return (StandaloneKindSig an1 vars' sig') @@ -2835,10 +2823,10 @@ instance ExactPrint (DefaultDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DefaultDecl an tys) = do - an0 <- markEpAnnL' an lidl AnnDefault - an1 <- markEpAnnL' an0 lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnDefault + an1 <- markEpAnnL an0 lidl AnnOpenP tys' <- markAnnotated tys - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP return (DefaultDecl an2 tys') -- --------------------------------------------------------------------- @@ -2855,11 +2843,11 @@ instance ExactPrint (AnnDecl GhcPs) where n' <- markAnnotated n return (an0, ValueAnnProvenance n') (TypeAnnProvenance n) -> do - an1 <- markEpAnnL' an0 lapr_rest AnnType + an1 <- markEpAnnL an0 lapr_rest AnnType n' <- markAnnotated n return (an1, TypeAnnProvenance n') ModuleAnnProvenance -> do - an1 <- markEpAnnL' an lapr_rest AnnModule + an1 <- markEpAnnL an lapr_rest AnnModule return (an1, prov) e' <- markAnnotated e @@ -2969,11 +2957,11 @@ instance ExactPrint (HsExpr GhcPs) where return (HsLit an lit') exact (HsLam an lam_variant mg) = do - an0 <- mark' an AnnLam + an0 <- mark an AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> mark' an0 AnnCase - LamCases -> mark' an0 AnnCases + LamCase -> mark an0 AnnCase + LamCases -> mark an0 AnnCases mg' <- markAnnotated mg return (HsLam an1 lam_variant mg') @@ -2995,7 +2983,7 @@ instance ExactPrint (HsExpr GhcPs) where return (OpApp an e1' e2' e3') exact (NegApp an e s) = do - an0 <- markEpAnnL' an lidl AnnMinus + an0 <- markEpAnnL an lidl AnnMinus e' <- markAnnotated e return (NegApp an0 e' s) @@ -3018,50 +3006,50 @@ instance ExactPrint (HsExpr GhcPs) where return (SectionR an op' expr') exact (ExplicitTuple an args b) = do - an0 <- if b == Boxed then markEpAnnL' an lidl AnnOpenP - else markEpAnnL' an lidl AnnOpenPH + an0 <- if b == Boxed then markEpAnnL an lidl AnnOpenP + else markEpAnnL an lidl AnnOpenPH args' <- mapM markAnnotated args - an1 <- if b == Boxed then markEpAnnL' an0 lidl AnnCloseP - else markEpAnnL' an0 lidl AnnClosePH + an1 <- if b == Boxed then markEpAnnL an0 lidl AnnCloseP + else markEpAnnL an0 lidl AnnClosePH debugM $ "ExplicitTuple done" return (ExplicitTuple an1 args' b) exact (ExplicitSum an alt arity expr) = do - an0 <- markLensKw' an laesOpen AnnOpenPH + an0 <- markLensKw an laesOpen AnnOpenPH an1 <- markAnnKwAllL an0 laesBarsBefore AnnVbar expr' <- markAnnotated expr an2 <- markAnnKwAllL an1 laesBarsAfter AnnVbar - an3 <- markLensKw' an2 laesClose AnnClosePH + an3 <- markLensKw an2 laesClose AnnClosePH return (ExplicitSum an3 alt arity expr') exact (HsCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- setLayoutBoth $ markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCase an4 e' alts') exact (HsIf an e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsIf an4 e1' e2' e3') exact (HsMultiIf an mg) = do - an0 <- markEpAnnL' an lidl AnnIf - an1 <- markEpAnnL' an0 lidl AnnOpenC -- optional + an0 <- markEpAnnL an lidl AnnIf + an1 <- markEpAnnL an0 lidl AnnOpenC -- optional mg' <- markAnnotated mg - an2 <- markEpAnnL' an1 lidl AnnCloseC -- optional + an2 <- markEpAnnL an1 lidl AnnCloseC -- optional return (HsMultiIf an2 mg') exact (HsLet (tkLet, tkIn) binds e) = do @@ -3086,57 +3074,57 @@ instance ExactPrint (HsExpr GhcPs) where return (ExplicitList an1 es') exact (RecordCon an con_id binds) = do con_id' <- markAnnotated con_id - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC binds' <- markAnnotated binds - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordCon an1 con_id' binds') exact (RecordUpd an expr fields) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC fields' <- markAnnotated fields - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordUpd an1 expr' fields') exact (HsGetField an expr field) = do expr' <- markAnnotated expr field' <- markAnnotated field return (HsGetField an expr' field') exact (HsProjection an flds) = do - an0 <- markLensKw' an lapOpen AnnOpenP + an0 <- markLensKw an lapOpen AnnOpenP flds' <- mapM markAnnotated flds - an1 <- markLensKw' an0 lapClose AnnCloseP + an1 <- markLensKw an0 lapClose AnnCloseP return (HsProjection an1 flds') exact (ExprWithTySig an expr sig) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (ExprWithTySig an0 expr' sig') exact (ArithSeq an s seqInfo) = do - an0 <- markEpAnnL' an lidl AnnOpenS -- '[' + an0 <- markEpAnnL an lidl AnnOpenS -- '[' (an1, seqInfo') <- case seqInfo of From e -> do e' <- markAnnotated e - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot return (an', From e') FromTo e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot e2' <- markAnnotated e2 return (an', FromTo e1' e2') FromThen e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot return (an'', FromThen e1' e2') FromThenTo e1 e2 e3 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot e3' <- markAnnotated e3 return (an'', FromThenTo e1' e2' e3') - an2 <- markEpAnnL' an1 lidl AnnCloseS -- ']' + an2 <- markEpAnnL an1 lidl AnnCloseS -- ']' return (ArithSeq an2 s seqInfo') @@ -3148,46 +3136,46 @@ instance ExactPrint (HsExpr GhcPs) where return (HsTypedBracket an2 e') exact (HsUntypedBracket an (ExpBr a e)) = do - an0 <- markEpAnnL' an lidl AnnOpenEQ -- "[|" - an1 <- markEpAnnL' an0 lidl AnnOpenE -- "[e|" -- optional + an0 <- markEpAnnL an lidl AnnOpenEQ -- "[|" + an1 <- markEpAnnL an0 lidl AnnOpenE -- "[e|" -- optional e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an2 (ExpBr a e')) exact (HsUntypedBracket an (PatBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[p|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (PatBr a e')) exact (HsUntypedBracket an (DecBrL a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[d|") - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseC - an3 <- markEpAnnL' an2 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an3 (DecBrL a e')) exact (HsUntypedBracket an (TypBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[t|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (TypBr a e')) exact (HsUntypedBracket an (VarBr a b e)) = do (an0, e') <- if b then do - an' <- markEpAnnL' an lidl AnnSimpleQuote + an' <- markEpAnnL an lidl AnnSimpleQuote e' <- markAnnotated e return (an', e') else do - an' <- markEpAnnL' an lidl AnnThTyQuote + an' <- markEpAnnL an lidl AnnThTyQuote e' <- markAnnotated e return (an', e') return (HsUntypedBracket an0 (VarBr a b e')) exact (HsTypedSplice an s) = do - an0 <- markEpAnnL' an lidl AnnDollarDollar + an0 <- markEpAnnL an lidl AnnDollarDollar s' <- exact s return (HsTypedSplice an0 s') @@ -3197,15 +3185,15 @@ instance ExactPrint (HsExpr GhcPs) where exact (HsProc an p c) = do debugM $ "HsProc start" - an0 <- markEpAnnL' an lidl AnnProc + an0 <- markEpAnnL an lidl AnnProc p' <- markAnnotated p - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow debugM $ "HsProc after AnnRarrow" c' <- markAnnotated c return (HsProc an1 p' c') exact (HsStatic an e) = do - an0 <- markEpAnnL' an lidl AnnStatic + an0 <- markEpAnnL an lidl AnnStatic e' <- markAnnotated e return (HsStatic an0 e') @@ -3227,14 +3215,14 @@ exactDo :: (Monad m, Monoid w, ExactPrint (LocatedAn an a)) => AnnList -> HsDoFlavour -> LocatedAn an a -> EP w m (AnnList, LocatedAn an a) exactDo an (DoExpr m) stmts = exactMdo an m AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts -exactDo an GhciStmtCtxt stmts = markEpAnnL' an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts +exactDo an GhciStmtCtxt stmts = markEpAnnL an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an (MDoExpr m) stmts = exactMdo an m AnnMdo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an ListComp stmts = markMaybeDodgyStmts an stmts exactDo an MonadComp stmts = markMaybeDodgyStmts an stmts exactMdo :: (Monad m, Monoid w) => AnnList -> Maybe ModuleName -> AnnKeywordId -> EP w m AnnList -exactMdo an Nothing kw = markEpAnnL' an lal_rest kw +exactMdo an Nothing kw = markEpAnnL an lal_rest kw exactMdo an (Just module_name) kw = markEpAnnLMS'' an lal_rest kw (Just n) where n = (moduleNameString module_name) ++ "." ++ (keywordToString kw) @@ -3270,7 +3258,7 @@ instance ExactPrint (HsUntypedSplice GhcPs) where setAnnotationAnchor a _ _ _= a exact (HsUntypedSpliceExpr an e) = do - an0 <- markEpAnnL' an lidl AnnDollar + an0 <- markEpAnnL an lidl AnnDollar e' <- markAnnotated e return (HsUntypedSpliceExpr an0 e') @@ -3334,7 +3322,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3351,7 +3339,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3367,7 +3355,7 @@ instance (ExactPrint (LocatedA body)) debugM $ "HsRecUpdField" f' <- markAnnotated f an0 <- if isPun then return an - else markEpAnnL' an lidl AnnEqual + else markEpAnnL an lidl AnnEqual arg' <- if isPun then return arg else markAnnotated arg @@ -3470,11 +3458,11 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdApp an e1' e2') exact (HsCmdLam an lam_variant matches) = do - an0 <- markEpAnnL' an lidl AnnLam + an0 <- markEpAnnL an lidl AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> markEpAnnL' an0 lidl AnnCase - LamCases -> markEpAnnL' an0 lidl AnnCases + LamCase -> markEpAnnL an0 lidl AnnCase + LamCases -> markEpAnnL an0 lidl AnnCases matches' <- markAnnotated matches return (HsCmdLam an1 lam_variant matches') @@ -3485,23 +3473,23 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdPar (lpar', rpar') e') exact (HsCmdCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCmdCase an4 e' alts') exact (HsCmdIf an a e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsCmdIf an4 a e1' e2' e3') @@ -3515,7 +3503,7 @@ instance ExactPrint (HsCmd GhcPs) where exact (HsCmdDo an es) = do debugM $ "HsCmdDo" - an0 <- markEpAnnL' an lal_rest AnnDo + an0 <- markEpAnnL an lal_rest AnnDo es' <- markAnnotated es return (HsCmdDo an0 es') @@ -3538,7 +3526,7 @@ instance ( exact (BindStmt an pat body) = do debugM $ "BindStmt" pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnLarrow + an0 <- markEpAnnL an lidl AnnLarrow body' <- markAnnotated body return (BindStmt an0 pat' body') @@ -3552,7 +3540,7 @@ instance ( exact (LetStmt an binds) = do debugM $ "LetStmt" - an0 <- markEpAnnL' an lidl AnnLet + an0 <- markEpAnnL an lidl AnnLet binds' <- markAnnotated binds return (LetStmt an0 binds') @@ -3569,7 +3557,7 @@ instance ( exact (RecStmt an stmts a b c d e) = do debugM $ "RecStmt" - an0 <- markEpAnnL' an lal_rest AnnRec + an0 <- markEpAnnL an lal_rest AnnRec (an1, stmts') <- markAnnList' an0 (markAnnotated stmts) return (RecStmt an1 stmts' a b c d e) @@ -3587,25 +3575,25 @@ exactTransStmt :: (Monad m, Monoid w) -> EP w m ([AddEpAnn], Maybe (LHsExpr GhcPs), (LHsExpr GhcPs)) exactTransStmt an by using ThenForm = do debugM $ "exactTransStmt:ThenForm" - an0 <- markEpAnnL' an lidl AnnThen + an0 <- markEpAnnL an lidl AnnThen using' <- markAnnotated using case by of Nothing -> return (an0, by, using') Just b -> do - an1 <- markEpAnnL' an0 lidl AnnBy + an1 <- markEpAnnL an0 lidl AnnBy b' <- markAnnotated b return (an1, Just b', using') exactTransStmt an by using GroupForm = do debugM $ "exactTransStmt:GroupForm" - an0 <- markEpAnnL' an lidl AnnThen - an1 <- markEpAnnL' an0 lidl AnnGroup + an0 <- markEpAnnL an lidl AnnThen + an1 <- markEpAnnL an0 lidl AnnGroup (an2, by') <- case by of Nothing -> return (an1, by) Just b -> do - an2 <- markEpAnnL' an1 lidl AnnBy + an2 <- markEpAnnL an1 lidl AnnBy b' <- markAnnotated b return (an2, Just b') - an3 <- markEpAnnL' an2 lidl AnnUsing + an3 <- markEpAnnL an2 lidl AnnUsing using' <- markAnnotated using return (an3, by', using') @@ -3626,10 +3614,10 @@ instance ExactPrint (TyClDecl GhcPs) where -- that are infix. Turn these into comments so that they feed -- into the right place automatically an0 <- annotationsToComments an lidl [AnnOpenP,AnnCloseP] - an1 <- markEpAnnL' an0 lidl AnnType + an1 <- markEpAnnL an0 lidl AnnType (_anx, ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual rhs' <- markAnnotated rhs return (SynDecl { tcdSExt = an2 , tcdLName = ltycon', tcdTyVars = tyvars', tcdFixity = fixity @@ -3656,8 +3644,8 @@ instance ExactPrint (TyClDecl GhcPs) where | null sigs && isEmptyBag methods && null ats && null at_defs -- No "where" part = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC - an2 <- markEpAnnL' an1 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnOpenC + an2 <- markEpAnnL an1 lidl AnnCloseC return (ClassDecl {tcdCExt = (an2, lo, sortKey), tcdCtxt = context', tcdLName = lclas', tcdTyVars = tyvars', tcdFixity = fixity, @@ -3669,7 +3657,7 @@ instance ExactPrint (TyClDecl GhcPs) where | otherwise -- Laid out = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lidl AnnSemi ds <- withSortKey sortKey [(ClsSigTag, prepareListAnnotationA sigs), @@ -3678,7 +3666,7 @@ instance ExactPrint (TyClDecl GhcPs) where (ClsAtdTag, prepareListAnnotationA at_defs) -- ++ prepareListAnnotation docs ] - an3 <- markEpAnnL' an2 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseC let sigs' = undynamic ds methods' = listToBag $ undynamic ds @@ -3694,15 +3682,15 @@ instance ExactPrint (TyClDecl GhcPs) where where top_matter = do an' <- annotationsToComments an lidl [AnnOpenP, AnnCloseP] - an0 <- markEpAnnL' an' lidl AnnClass + an0 <- markEpAnnL an' lidl AnnClass (_, lclas', tyvars',_,context') <- exactVanillaDeclHead lclas tyvars fixity context (an1, fds') <- if (null fds) then return (an0, fds) else do - an1 <- markEpAnnL' an0 lidl AnnVbar + an1 <- markEpAnnL an0 lidl AnnVbar fds' <- markAnnotated fds return (an1, fds') - an2 <- markEpAnnL' an1 lidl AnnWhere + an2 <- markEpAnnL an1 lidl AnnWhere return (an2, fds', lclas', tyvars',context') @@ -3714,7 +3702,7 @@ instance ExactPrint (FunDep GhcPs) where exact (FunDep an ls rs') = do ls' <- markAnnotated ls - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow rs'' <- markAnnotated rs' return (FunDep an0 ls' rs'') @@ -3741,23 +3729,23 @@ instance ExactPrint (FamilyDecl GhcPs) where case mb_inj of Nothing -> return (an3, mb_inj) Just inj -> do - an4 <- markEpAnnL' an3 lidl AnnVbar + an4 <- markEpAnnL an3 lidl AnnVbar inj' <- markAnnotated inj return (an4, Just inj') (an5, info') <- case info of ClosedTypeFamily mb_eqns -> do - an5 <- markEpAnnL' an4 lidl AnnWhere - an6 <- markEpAnnL' an5 lidl AnnOpenC + an5 <- markEpAnnL an4 lidl AnnWhere + an6 <- markEpAnnL an5 lidl AnnOpenC (an7, mb_eqns') <- case mb_eqns of Nothing -> do - an7 <- markEpAnnL' an6 lidl AnnDotdot + an7 <- markEpAnnL an6 lidl AnnDotdot return (an7, mb_eqns) Just eqns -> do eqns' <- markAnnotated eqns return (an6, Just eqns') - an8 <- markEpAnnL' an7 lidl AnnCloseC + an8 <- markEpAnnL an7 lidl AnnCloseC return (an8, ClosedTypeFamily mb_eqns') _ -> return (an4, info) return (FamilyDecl { fdExt = an5 @@ -3771,30 +3759,30 @@ instance ExactPrint (FamilyDecl GhcPs) where where exact_top_level an' = case top_level of - TopLevel -> markEpAnnL' an' lidl AnnFamily + TopLevel -> markEpAnnL an' lidl AnnFamily NotTopLevel -> do -- It seems that in some kind of legacy -- mode the 'family' keyword is still -- accepted. - markEpAnnL' an' lidl AnnFamily + markEpAnnL an' lidl AnnFamily exact_kind an' = case result of NoSig _ -> return (an', result) KindSig x kind -> do - an0 <- markEpAnnL' an' lidl AnnDcolon + an0 <- markEpAnnL an' lidl AnnDcolon kind' <- markAnnotated kind return (an0, KindSig x kind') TyVarSig x tv_bndr -> do - an0 <- markEpAnnL' an' lidl AnnEqual + an0 <- markEpAnnL an' lidl AnnEqual tv_bndr' <- markAnnotated tv_bndr return (an0, TyVarSig x tv_bndr') exactFlavour :: (Monad m, Monoid w) => [AddEpAnn] -> FamilyInfo GhcPs -> EP w m [AddEpAnn] -exactFlavour an DataFamily = markEpAnnL' an lidl AnnData -exactFlavour an OpenTypeFamily = markEpAnnL' an lidl AnnType -exactFlavour an (ClosedTypeFamily {}) = markEpAnnL' an lidl AnnType +exactFlavour an DataFamily = markEpAnnL an lidl AnnData +exactFlavour an OpenTypeFamily = markEpAnnL an lidl AnnType +exactFlavour an (ClosedTypeFamily {}) = markEpAnnL an lidl AnnType -- --------------------------------------------------------------------- @@ -3821,31 +3809,31 @@ exactDataDefn an exactHdr an0 <- case condecls of DataTypeCons is_type_data _ -> do an0' <- if is_type_data - then markEpAnnL' an' lidl AnnType + then markEpAnnL an' lidl AnnType else return an' - markEpAnnL' an0' lidl AnnData - NewTypeCon _ -> markEpAnnL' an' lidl AnnNewtype + markEpAnnL an0' lidl AnnData + NewTypeCon _ -> markEpAnnL an' lidl AnnNewtype - an1 <- markEpAnnL' an0 lidl AnnInstance -- optional + an1 <- markEpAnnL an0 lidl AnnInstance -- optional mb_ct' <- mapM markAnnotated mb_ct (anx, ln', tvs', b, mctxt') <- exactHdr context (an2, mb_sig') <- case mb_sig of Nothing -> return (an1, Nothing) Just kind -> do - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon kind' <- markAnnotated kind return (an2, Just kind') an3 <- if (needsWhere condecls) - then markEpAnnL' an2 lidl AnnWhere + then markEpAnnL an2 lidl AnnWhere else return an2 - an4 <- markEpAnnL' an3 lidl AnnOpenC + an4 <- markEpAnnL an3 lidl AnnOpenC (an5, condecls') <- exact_condecls an4 (toList condecls) let condecls'' = case condecls of DataTypeCons d _ -> DataTypeCons d condecls' NewTypeCon _ -> case condecls' of [decl] -> NewTypeCon decl _ -> panic "exacprint NewTypeCon" - an6 <- markEpAnnL' an5 lidl AnnCloseC + an6 <- markEpAnnL an5 lidl AnnCloseC derivings' <- mapM markAnnotated derivings return (anx, an6, ln', tvs', b, mctxt', (HsDataDefn { dd_ext = x, dd_ctxt = context @@ -3895,9 +3883,9 @@ instance ExactPrint (InjectivityAnn GhcPs) where getAnnotationEntry _ = NoEntryVal setAnnotationAnchor a _ _ _ = a exact (InjectivityAnn an lhs rhs) = do - an0 <- markEpAnnL' an lidl AnnVbar + an0 <- markEpAnnL an lidl AnnVbar lhs' <- markAnnotated lhs - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow rhs' <- mapM markAnnotated rhs return (InjectivityAnn an1 lhs' rhs') @@ -3950,7 +3938,7 @@ instance ExactPrintTVFlag flag => ExactPrint (HsTyVarBndr flag GhcPs) where exact (KindedTyVar an flag n k) = do r <- exactTVDelimiters an flag $ do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (KindedTyVar an0 flag n' k') case r of @@ -3976,7 +3964,7 @@ instance ExactPrint (HsType GhcPs) where return (HsQualTy an ctxt' ty') exact (HsTyVar an promoted name) = do an0 <- if (promoted == IsPromoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an name' <- markAnnotated name return (HsTyVar an0 promoted name') @@ -4011,7 +3999,7 @@ instance ExactPrint (HsType GhcPs) where return (HsSumTy an1 tys') exact (HsOpTy an promoted t1 lo t2) = do an0 <- if (isPromoted promoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an t1' <- markAnnotated t1 lo' <- markAnnotated lo @@ -4024,7 +4012,7 @@ instance ExactPrint (HsType GhcPs) where return (HsParTy an1 ty') exact (HsIParamTy an n t) = do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon t' <- markAnnotated t return (HsIParamTy an0 n' t') exact (HsStarTy an isUnicode) = do @@ -4034,7 +4022,7 @@ instance ExactPrint (HsType GhcPs) where return (HsStarTy an isUnicode) exact (HsKindSig an ty k) = do ty' <- markAnnotated ty - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (HsKindSig an0 ty' k') exact (HsSpliceTy a splice) = do @@ -4055,24 +4043,24 @@ instance ExactPrint (HsType GhcPs) where return an1 an1 <- case str of - SrcLazy -> mark' an0 AnnTilde - SrcStrict -> mark' an0 AnnBang + SrcLazy -> mark an0 AnnTilde + SrcStrict -> mark an0 AnnBang NoSrcStrict -> return an0 ty' <- markAnnotated ty return (HsBangTy an1 (HsSrcBang mt up str) ty') exact (HsExplicitListTy an prom tys) = do an0 <- if (isPromoted prom) - then mark' an AnnSimpleQuote + then mark an AnnSimpleQuote else return an - an1 <- mark' an0 AnnOpenS + an1 <- mark an0 AnnOpenS tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseS + an2 <- mark an1 AnnCloseS return (HsExplicitListTy an2 prom tys') exact (HsExplicitTupleTy an tys) = do - an0 <- mark' an AnnSimpleQuote - an1 <- mark' an0 AnnOpenP + an0 <- mark an AnnSimpleQuote + an1 <- mark an0 AnnOpenP tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseP + an2 <- mark an1 AnnCloseP return (HsExplicitTupleTy an2 tys') exact (HsTyLit a lit) = do case lit of @@ -4113,7 +4101,7 @@ instance ExactPrint (HsDerivingClause GhcPs) where exact (HsDerivingClause { deriv_clause_ext = an , deriv_clause_strategy = dcs , deriv_clause_tys = dct }) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving exact_strat_before dct' <- markAnnotated dct exact_strat_after @@ -4133,16 +4121,16 @@ instance ExactPrint (DerivStrategy GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StockStrategy an) = do - an0 <- markEpAnnL' an lid AnnStock + an0 <- markEpAnnL an lid AnnStock return (StockStrategy an0) exact (AnyclassStrategy an) = do - an0 <- markEpAnnL' an lid AnnAnyclass + an0 <- markEpAnnL an lid AnnAnyclass return (AnyclassStrategy an0) exact (NewtypeStrategy an) = do - an0 <- markEpAnnL' an lid AnnNewtype + an0 <- markEpAnnL an lid AnnNewtype return (NewtypeStrategy an0) exact (ViaStrategy (XViaStrategyPs an ty)) = do - an0 <- markEpAnnL' an lid AnnVia + an0 <- markEpAnnL an lid AnnVia ty' <- markAnnotated ty return (ViaStrategy (XViaStrategyPs an0 ty')) @@ -4293,7 +4281,7 @@ exact_condecls an cs return (an, cs') | otherwise -- In H98 syntax = do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual cs' <- mapM markAnnotated cs return (an0, cs') where @@ -4317,15 +4305,15 @@ instance ExactPrint (ConDecl GhcPs) where , con_args = args , con_doc = doc }) = do an0 <- if has_forall - then markEpAnnL' an lidl AnnForall + then markEpAnnL an lidl AnnForall else return an ex_tvs' <- mapM markAnnotated ex_tvs an1 <- if has_forall - then markEpAnnL' an0 lidl AnnDot + then markEpAnnL an0 lidl AnnDot else return an0 mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 (con', args') <- exact_details args @@ -4373,7 +4361,7 @@ instance ExactPrint (ConDecl GhcPs) where mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 args' <- case args of @@ -4422,7 +4410,7 @@ instance ExactPrint (ConDeclField GhcPs) where exact (ConDeclField an names ftype mdoc) = do names' <- markAnnotated names - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon ftype' <- markAnnotated ftype return (ConDeclField an0 names' ftype' mdoc) @@ -4496,7 +4484,7 @@ instance ExactPrint (LocatedL [LocatedA (IE GhcPs)]) where exact (L an ies) = do debugM $ "LocatedL [LIE" - an0 <- markEpAnnL an lal_rest AnnHiding + an0 <- markEpAnnL' an lal_rest AnnHiding p <- getPosP debugM $ "LocatedL [LIE:p=" ++ showPprUnsafe p (an1, ies') <- markAnnList an0 (markAnnotated ies) @@ -4579,16 +4567,16 @@ instance ExactPrint (IE GhcPs) where exact (IEThingAll (depr, an) thing doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnCloseP + an0 <- markEpAnnL an lidl AnnOpenP + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingAll (depr', an2) thing' doc') exact (IEThingWith (depr, an) thing wc withs doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnOpenP (an1, wc', withs') <- case wc of NoIEWildcard -> do @@ -4597,17 +4585,17 @@ instance ExactPrint (IE GhcPs) where IEWildcard pos -> do let (bs, as) = splitAt pos withs bs' <- markAnnotated bs - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnComma + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnComma as' <- markAnnotated as return (an2, wc, bs'++as') - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingWith (depr', an2) thing' wc' withs' doc') exact (IEModuleContents (depr, an) m) = do depr' <- markAnnotated depr - an0 <- markEpAnnL' an lidl AnnModule + an0 <- markEpAnnL an lidl AnnModule m' <- markAnnotated m return (IEModuleContents (depr', an0) m') @@ -4658,7 +4646,7 @@ instance ExactPrint (Pat GhcPs) where else return n return (VarPat x n') exact (LazyPat an pat) = do - an0 <- markEpAnnL' an lidl AnnTilde + an0 <- markEpAnnL an lidl AnnTilde pat' <- markAnnotated pat return (LazyPat an0 pat') exact (AsPat at n pat) = do @@ -4673,7 +4661,7 @@ instance ExactPrint (Pat GhcPs) where return (ParPat (lpar', rpar') pat') exact (BangPat an pat) = do - an0 <- markEpAnnL' an lidl AnnBang + an0 <- markEpAnnL an lidl AnnBang pat' <- markAnnotated pat return (BangPat an0 pat') @@ -4683,20 +4671,20 @@ instance ExactPrint (Pat GhcPs) where exact (TuplePat an pats boxity) = do an0 <- case boxity of - Boxed -> markEpAnnL' an lidl AnnOpenP - Unboxed -> markEpAnnL' an lidl AnnOpenPH + Boxed -> markEpAnnL an lidl AnnOpenP + Unboxed -> markEpAnnL an lidl AnnOpenPH pats' <- markAnnotated pats an1 <- case boxity of - Boxed -> markEpAnnL' an0 lidl AnnCloseP - Unboxed -> markEpAnnL' an0 lidl AnnClosePH + Boxed -> markEpAnnL an0 lidl AnnCloseP + Unboxed -> markEpAnnL an0 lidl AnnClosePH return (TuplePat an1 pats' boxity) exact (SumPat an pat alt arity) = do - an0 <- markEpAnnL' an lsumPatParens AnnOpenPH + an0 <- markEpAnnL an lsumPatParens AnnOpenPH an1 <- markAnnKwAllL an0 lsumPatVbarsBefore AnnVbar pat' <- markAnnotated pat an2 <- markAnnKwAllL an1 lsumPatVbarsAfter AnnVbar - an3 <- markEpAnnL' an2 lsumPatParens AnnClosePH + an3 <- markEpAnnL an2 lsumPatParens AnnClosePH return (SumPat an3 pat' alt arity) exact (ConPat an con details) = do @@ -4704,7 +4692,7 @@ instance ExactPrint (Pat GhcPs) where return (ConPat an' con' details') exact (ViewPat an expr pat) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow pat' <- markAnnotated pat return (ViewPat an0 expr' pat') exact (SplicePat x splice) = do @@ -4713,7 +4701,7 @@ instance ExactPrint (Pat GhcPs) where exact p@(LitPat _ lit) = printStringAdvance (hsLit2String lit) >> return p exact (NPat an ol mn z) = do an0 <- if (isJust mn) - then markEpAnnL' an lidl AnnMinus + then markEpAnnL an lidl AnnMinus else return an ol' <- markAnnotated ol return (NPat an0 ol' mn z) @@ -4726,7 +4714,7 @@ instance ExactPrint (Pat GhcPs) where exact (SigPat an pat sig) = do pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (SigPat an0 pat' sig') @@ -4832,9 +4820,9 @@ exactUserCon an c (InfixCon p1 p2) = do return (an, c', InfixCon p1' p2') exactUserCon an c details = do c' <- markAnnotated c - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC details' <- exactConArgs details - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (an1, c', details') instance ExactPrint (HsConPatTyArg GhcPs) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed7b3d680f08d593ebfcd3f361a533c86dbe6e81...4373a99b39b63b663be83f01850a0f0b82572d8d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed7b3d680f08d593ebfcd3f361a533c86dbe6e81...4373a99b39b63b663be83f01850a0f0b82572d8d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 02:44:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 20 Mar 2024 22:44:07 -0400 Subject: [Git][ghc/ghc][master] Expand untyped splices in tcPolyExprCheck Message-ID: <65fb9ef773df1_17e2c465c4e6872830@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 6 changed files: - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - + testsuite/tests/th/T24559.hs - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -30,7 +30,7 @@ import GHC.Prelude import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import {-# SOURCE #-} GHC.Tc.Gen.Splice - ( tcTypedSplice, tcTypedBracket, tcUntypedBracket ) + ( tcTypedSplice, tcTypedBracket, tcUntypedBracket, getUntypedSpliceBody ) import GHC.Hs import GHC.Hs.Syn.Type @@ -169,6 +169,12 @@ tcPolyExprCheck expr res_ty do { e' <- tc_body e ; return (HsPar x (L loc e')) } + -- Look through any untyped splices (#24559) + -- c.f. Note [Looking through Template Haskell splices in splitHsApps] + tc_body (HsUntypedSplice splice_res _) + = do { body <- getUntypedSpliceBody splice_res + ; tc_body body } + -- The special case for lambda: go to tcLambdaMatches, passing pat_tys tc_body e@(HsLam x lam_variant matches) = do { (wrap, matches') <- tcLambdaMatches e lam_variant matches pat_tys @@ -673,11 +679,8 @@ tcExpr (HsUntypedSplice splice _) res_ty -- for `HsUntypedSplice`; to see why, read Wrinkle (UTS1) in -- Note [Looking through Template Haskell splices in splitHsApps] in -- GHC.Tc.Gen.Head. - = case splice of - HsUntypedSpliceTop mod_finalizers expr - -> do { addModFinalizersWithLclEnv mod_finalizers - ; tcExpr expr res_ty } - HsUntypedSpliceNested {} -> panic "tcExpr: invalid nested splice" + = do { expr <- getUntypedSpliceBody splice + ; tcExpr expr res_ty } {- ************************************************************************ ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -30,6 +30,7 @@ module GHC.Tc.Gen.Head , addHeadCtxt, addExprCtxt, addStmtCtxt, addFunResCtxt ) where import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcExpr, tcCheckPolyExprNC, tcPolyLExprSig ) +import {-# SOURCE #-} GHC.Tc.Gen.Splice( getUntypedSpliceBody ) import GHC.Prelude import GHC.Hs @@ -310,15 +311,11 @@ splitHsApps e = go e (top_ctxt 0 e) [] -- See Note [Looking through Template Haskell splices in splitHsApps] go e@(HsUntypedSplice splice_res splice) ctxt args - = case splice_res of - HsUntypedSpliceTop mod_finalizers fun - -> do addModFinalizersWithLclEnv mod_finalizers - go fun ctxt' (EWrap (EExpand (OrigExpr e)) : args) - HsUntypedSpliceNested {} -> panic "splitHsApps: invalid nested splice" + = do { fun <- getUntypedSpliceBody splice_res + ; go fun ctxt' (EWrap (EExpand (OrigExpr e)) : args) } where ctxt' :: AppCtxt - ctxt' = - case splice of + ctxt' = case splice of HsUntypedSpliceExpr _ (L l _) -> set l ctxt -- l :: SrcAnn AnnListItem HsQuasiQuote _ _ (L l _) -> set l ctxt -- l :: SrcAnn NoEpAnns @@ -840,7 +837,7 @@ handling splices and quasiquotes has already been performed by the renamer by the time we get to `splitHsApps`. Wrinkle (UTS1): - `tcExpr` has a separate case for `HsUntypedSplice`s that do not occur at the + `tcExpr` has a separate case for `HsUntypedSplice`s that do /not/ occur at the head of an application. This is important to handle programs like this one: foo :: (forall a. a -> a) -> b -> b ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -21,7 +21,7 @@ -- | Template Haskell splices module GHC.Tc.Gen.Splice( tcTypedSplice, tcTypedBracket, tcUntypedBracket, - runAnnotation, + runAnnotation, getUntypedSpliceBody, runMetaE, runMetaP, runMetaT, runMetaD, runQuasi, tcTopSpliceExpr, lookupThName_maybe, @@ -639,13 +639,16 @@ Example: ************************************************************************ -} +-- None of these functions add constraints to the LIE + tcTypedBracket :: HsExpr GhcRn -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcUntypedBracket :: HsExpr GhcRn -> HsQuote GhcRn -> [PendingRnSplice] -> ExpRhoType -> TcM (HsExpr GhcTc) -tcTypedSplice :: Name -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) - -- None of these functions add constraints to the LIE +tcTypedSplice :: Name -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) + +getUntypedSpliceBody :: HsUntypedSpliceResult (HsExpr GhcRn) -> TcM (HsExpr GhcRn) +runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation -runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation {- ************************************************************************ * * @@ -815,6 +818,16 @@ quotationCtxtDoc br_body ************************************************************************ -} +-- getUntypedSpliceBody: the renamer has expanded the splice. +-- Just run the finalizers that it produced, and return +-- the renamed expression +getUntypedSpliceBody (HsUntypedSpliceTop { utsplice_result_finalizers = mod_finalizers + , utsplice_result = rn_expr }) + = do { addModFinalizersWithLclEnv mod_finalizers + ; return rn_expr } +getUntypedSpliceBody (HsUntypedSpliceNested {}) + = panic "tcTopUntypedSplice: invalid nested splice" + tcTypedSplice splice_name expr res_ty = addErrCtxt (typedSpliceCtxtDoc splice_name expr) $ setSrcSpan (getLocA expr) $ do ===================================== compiler/GHC/Tc/Gen/Splice.hs-boot ===================================== @@ -10,7 +10,7 @@ import GHC.Tc.Utils.TcType ( ExpRhoType ) import GHC.Types.Annotations ( Annotation, CoreAnnTarget ) import GHC.Hs.Extension ( GhcRn, GhcPs, GhcTc ) -import GHC.Hs ( HsQuote, HsExpr, LHsExpr, LHsType, LPat, LHsDecl, ThModFinalizers ) +import GHC.Hs ( HsQuote, HsExpr, LHsExpr, LHsType, LPat, LHsDecl, ThModFinalizers, HsUntypedSpliceResult ) import qualified Language.Haskell.TH as TH tcTypedSplice :: Name @@ -30,7 +30,8 @@ tcUntypedBracket :: HsExpr GhcRn runTopSplice :: DelayedSplice -> TcM (HsExpr GhcTc) -runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation +runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation +getUntypedSpliceBody :: HsUntypedSpliceResult (HsExpr GhcRn) -> TcM (HsExpr GhcRn) tcTopSpliceExpr :: SpliceType -> TcM (LHsExpr GhcTc) -> TcM (LHsExpr GhcTc) ===================================== testsuite/tests/th/T24559.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeAbstractions #-} +module Foo where + +import Data.Kind +import Data.Proxy + +f :: (forall (a :: Type). Proxy a) -> Proxy Bool +f k = k @Bool + +g1 :: Proxy Bool +g1 = f (\ @a -> Proxy @a) + +g2 :: Proxy Bool +g2 = f $([| \ @a -> Proxy @a |]) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24559', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97a2bb1cdfa4b244a58374658aec6d48ce23a54a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97a2bb1cdfa4b244a58374658aec6d48ce23a54a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 02:45:01 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 20 Mar 2024 22:45:01 -0400 Subject: [Git][ghc/ghc][master] EPA: Clean up Exactprint helper functions a bit Message-ID: <65fb9f2d28317_17e2c46774ccc7619b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - 1 changed file: - utils/check-exact/ExactPrint.hs Changes: ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -740,15 +740,12 @@ markExternalSourceText l (SourceText txt) _ = printStringAtRs (realSrcSpan l) (u -- --------------------------------------------------------------------- -markLensMAA :: (Monad m, Monoid w) => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) -markLensMAA (EpAnn anc a cs) l = - case view l a of - Nothing -> return (EpAnn anc a cs) - Just aa -> do - aa' <- markAddEpAnn aa - return (EpAnn anc (set l (Just aa') a) cs) +markLensMAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) +markLensMAA epann l = markLensMAA' epann (lepa . l) -markLensMAA' :: (Monad m, Monoid w) => a -> Lens a (Maybe AddEpAnn) -> EP w m a +markLensMAA' :: (Monad m, Monoid w) + => a -> Lens a (Maybe AddEpAnn) -> EP w m a markLensMAA' a l = case view l a of Nothing -> return a @@ -756,34 +753,27 @@ markLensMAA' a l = aa' <- markAddEpAnn aa return (set l (Just aa') a) -markLensAA :: (Monad m, Monoid w) => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensAA (EpAnn anc a cs) l = do - a' <- markKw (view l a) - return (EpAnn anc (set l a' a) cs) +-- ------------------------------------- + +markLensAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) +markLensAA epann l = markLensAA' epann (lepa . l) -markLensAA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a +markLensAA' :: (Monad m, Monoid w) + => a -> Lens a AddEpAnn -> EP w m a markLensAA' a l = do a' <- markKw (view l a) return (set l a' a) +-- ------------------------------------- markEpAnnLMS :: (Monad m, Monoid w) => EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS an l kw Nothing = markEpAnnL an l kw -markEpAnnLMS (EpAnn anc a cs) l kw (Just str) = do - anns <- mapM go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) +markEpAnnLMS epann l kw ms = markEpAnnLMS'' epann (lepa . l) kw ms markEpAnnLMS'' :: (Monad m, Monoid w) => a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS'' an l kw Nothing = markEpAnnL' an l kw +markEpAnnLMS'' an l kw Nothing = markEpAnnL an l kw markEpAnnLMS'' a l kw (Just str) = do anns <- mapM go (view l a) return (set l anns a) @@ -795,10 +785,11 @@ markEpAnnLMS'' a l kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- markEpAnnMS' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m [AddEpAnn] -markEpAnnMS' anns kw Nothing = mark' anns kw +markEpAnnMS' anns kw Nothing = mark anns kw markEpAnnMS' anns kw (Just str) = do mapM go anns where @@ -809,23 +800,15 @@ markEpAnnMS' anns kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- + markEpAnnLMS' :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS' an l _kw Nothing = markLensKwA an l -markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do - anns <- go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) + => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) +markEpAnnLMS' an l kw ms = markEpAnnLMS0 an (lepa . l) kw ms markEpAnnLMS0 :: (Monad m, Monoid w) - => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS0 an l _kw Nothing = markLensKwA' an l + => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a +markEpAnnLMS0 an l _kw Nothing = markLensKwA an l markEpAnnLMS0 a l kw (Just str) = do anns <- go (view l a) return (set l anns a) @@ -890,7 +873,8 @@ markAnnOpenP' :: (Monad m, Monoid w) => AnnPragma -> SourceText -> String -> EP markAnnOpenP' an NoSourceText txt = markEpAnnLMS0 an lapr_open AnnOpen (Just txt) markAnnOpenP' an (SourceText txt) _ = markEpAnnLMS0 an lapr_open AnnOpen (Just $ unpackFS txt) -markAnnOpen :: (Monad m, Monoid w) => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] +markAnnOpen :: (Monad m, Monoid w) + => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] markAnnOpen an NoSourceText txt = markEpAnnLMS'' an lidl AnnOpen (Just txt) markAnnOpen an (SourceText txt) _ = markEpAnnLMS'' an lidl AnnOpen (Just $ unpackFS txt) @@ -960,6 +944,16 @@ You can think of the function composition operator as having this type: -- --------------------------------------------------------------------- -- Lenses +-- data EpAnn ann +-- = EpAnn { entry :: !Anchor +-- , anns :: !ann +-- , comments :: !EpAnnComments +-- } + +lepa :: Lens (EpAnn a) a +lepa k epAnn = fmap (\newAnns -> epAnn { anns = newAnns }) + (k (anns epAnn)) + -- data AnnsModule -- = AnnsModule { -- am_main :: [AddEpAnn], @@ -1289,26 +1283,20 @@ lsumPatVbarsAfter k parent = fmap (\new -> parent { sumPatVbarsAfter = new }) -- --------------------------------------------------------------------- markLensKwA :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensKwA (EpAnn anc a cs) l = do - loc <- markKw (view l a) - return (EpAnn anc (set l loc a) cs) - -markLensKwA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a -markLensKwA' a l = do +markLensKwA a l = do loc <- markKw (view l a) return (set l loc a) -markLensKw :: (Monad m, Monoid w) +markLensKw' :: (Monad m, Monoid w) => EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a) -markLensKw (EpAnn anc a cs) l kw = do +markLensKw' (EpAnn anc a cs) l kw = do loc <- markKwA kw (view l a) return (EpAnn anc (set l loc a) cs) -markLensKw' :: (Monad m, Monoid w) +markLensKw :: (Monad m, Monoid w) => a -> Lens a EpaLocation -> AnnKeywordId -> EP w m a -markLensKw' a l kw = do +markLensKw a l kw = do loc <- markKwA kw (view l a) return (set l loc a) @@ -1338,18 +1326,18 @@ markLensKwM' a l kw = do -- --------------------------------------------------------------------- -markEpAnnL :: (Monad m, Monoid w) +markEpAnnL' :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) -markEpAnnL (EpAnn anc a cs) l kw = do - anns <- mark' (view l a) kw - return (EpAnn anc (set l anns a) cs) +markEpAnnL' epann l kw = markEpAnnL epann (lepa . l) kw -markEpAnnL' :: (Monad m, Monoid w) +markEpAnnL :: (Monad m, Monoid w) => ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m ann -markEpAnnL' a l kw = do - anns <- mark' (view l a) kw +markEpAnnL a l kw = do + anns <- mark (view l a) kw return (set l anns a) +-- ------------------------------------- + markEpAnnAllL :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) markEpAnnAllL (EpAnn anc a cs) l kw = do @@ -1374,13 +1362,13 @@ markEpAnnAllL' a l kw = do markAddEpAnn :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn markAddEpAnn a@(AddEpAnn kw _) = do - r <- mark' [a] kw + r <- mark [a] kw case r of [a'] -> return a' _ -> error "Should not happen: markAddEpAnn" -mark' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] -mark' anns kw = do +mark :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] +mark anns kw = do case find' kw anns of (lead, Just aa, end) -> do aa' <- markKw aa @@ -1637,14 +1625,14 @@ instance ExactPrint (HsModule GhcPs) where case mmn of Nothing -> return (an, mmn, mdeprec, mexports) Just m -> do - an0 <- markEpAnnL an lam_main AnnModule + an0 <- markEpAnnL' an lam_main AnnModule m' <- markAnnotated m mdeprec' <- setLayoutTopLevelP $ markAnnotated mdeprec mexports' <- setLayoutTopLevelP $ markAnnotated mexports - an1 <- setLayoutTopLevelP $ markEpAnnL an0 lam_main AnnWhere + an1 <- setLayoutTopLevelP $ markEpAnnL' an0 lam_main AnnWhere return (an1, Just m', mdeprec', mexports') @@ -1708,17 +1696,17 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where exact (L an (WarningTxt mb_cat src ws)) = do an0 <- markAnnOpenP an src "{-# WARNING" mb_cat' <- markAnnotated mb_cat - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (WarningTxt mb_cat' src ws')) exact (L an (DeprecatedTxt src ws)) = do an0 <- markAnnOpenP an src "{-# DEPRECATED" - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (DeprecatedTxt src ws')) @@ -1751,7 +1739,7 @@ instance ExactPrint (ImportDecl GhcPs) where exact (ImportDecl (XImportDeclPass ann msrc impl) modname mpkg src safeflag qualFlag mAs hiding) = do - ann0 <- markLensKw ann limportDeclAnnImport AnnImport + ann0 <- markLensKw' ann limportDeclAnnImport AnnImport let (EpAnn _anc an _cs) = ann0 -- "{-# SOURCE" and "#-}" @@ -1955,7 +1943,7 @@ exactDataFamInstDecl an top_lvl , Maybe (LHsContext GhcPs)) pp_hdr mctxt = do an0 <- case top_lvl of - TopLevel -> markEpAnnL' an lidl AnnInstance -- TODO: maybe in toplevel + TopLevel -> markEpAnnL an lidl AnnInstance -- TODO: maybe in toplevel NotTopLevel -> return an exactHsFamInstLHS an0 tycon bndrs pats fixity mctxt @@ -1978,9 +1966,9 @@ instance ExactPrint (DerivDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DerivDecl (mw, an) typ ms mov) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving ms' <- mapM markAnnotated ms - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance mw' <- mapM markAnnotated mw mov' <- mapM markAnnotated mov typ' <- markAnnotated typ @@ -1993,22 +1981,22 @@ instance ExactPrint (ForeignDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (ForeignImport an n ty fimport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnImport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnImport fimport' <- markAnnotated fimport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignImport an2 n' ty' fimport') exact (ForeignExport an n ty fexport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnExport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnExport fexport' <- markAnnotated fexport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignExport an2 n' ty' fexport') @@ -2080,18 +2068,18 @@ instance ExactPrint (WarnDecl GhcPs) where mb_cat' <- markAnnotated mb_cat ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (WarningTxt mb_cat' src ls')) -- return (Warning an1 lns' (WarningTxt mb_cat' src ls')) exact (Warning (ns_spec, an) lns (DeprecatedTxt src ls)) = do ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (DeprecatedTxt src ls')) -- return (Warning an1 lns' (DeprecatedTxt src ls')) @@ -2162,7 +2150,7 @@ instance ExactPrint (RuleDecl GhcPs) where an3 <- markLensMAA' an2 lra_tmanns_snd -- AnnDot lhs' <- markAnnotated lhs - an4 <- markEpAnnL' an3 lra_rest AnnEqual + an4 <- markEpAnnL an3 lra_rest AnnEqual rhs' <- markAnnotated rhs return (HsRule (an4,nsrc) (L ln' n) act mtybndrs' termbndrs' lhs' rhs') @@ -2171,20 +2159,20 @@ markActivation :: (Monad m, Monoid w) markActivation an l act = do case act of ActiveBefore src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ an2 <- markEpAnnLMS'' an1 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an3 <- markEpAnnL' an2 l AnnCloseS -- ']' + an3 <- markEpAnnL an2 l AnnCloseS -- ']' return an3 ActiveAfter src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' + an0 <- markEpAnnL an l AnnOpenS -- '[' an1 <- markEpAnnLMS'' an0 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 NeverActive -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 _ -> return an @@ -2214,8 +2202,8 @@ instance ExactPrint (RoleAnnotDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (RoleAnnotDecl an ltycon roles) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnRole + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnRole ltycon' <- markAnnotated ltycon let markRole (L l (Just r)) = do (L _ r') <- markAnnotated (L l r) @@ -2243,11 +2231,11 @@ instance ExactPrint (RuleBndr GhcPs) where ln' <- markAnnotated ln return (RuleBndr x ln') exact (RuleBndrSig an ln (HsPS x ty)) = do - an0 <- markEpAnnL' an lidl AnnOpenP -- "(" + an0 <- markEpAnnL an lidl AnnOpenP -- "(" ln' <- markAnnotated ln - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty - an2 <- markEpAnnL' an1 lidl AnnCloseP -- ")" + an2 <- markEpAnnL an1 lidl AnnCloseP -- ")" return (RuleBndrSig an2 ln' (HsPS x ty')) -- --------------------------------------------------------------------- @@ -2262,7 +2250,7 @@ instance (ExactPrint body) => ExactPrint (FamEqn GhcPs body) where , feqn_fixity = fixity , feqn_rhs = rhs }) = do (an0, tycon', bndrs', pats', _) <- exactHsFamInstLHS an tycon bndrs pats fixity Nothing - an1 <- markEpAnnL' an0 lidl AnnEqual + an1 <- markEpAnnL an0 lidl AnnEqual rhs' <- markAnnotated rhs return (FamEqn { feqn_ext = an1 , feqn_tycon = tycon' @@ -2286,9 +2274,9 @@ exactHsFamInstLHS :: , HsOuterTyVarBndrs () GhcPs , HsFamEqnPats GhcPs, Maybe (LHsContext GhcPs)) exactHsFamInstLHS an thing bndrs typats fixity mb_ctxt = do - an0 <- markEpAnnL' an lidl AnnForall + an0 <- markEpAnnL an lidl AnnForall bndrs' <- markAnnotated bndrs - an1 <- markEpAnnL' an0 lidl AnnDot + an1 <- markEpAnnL an0 lidl AnnDot mb_ctxt' <- mapM markAnnotated mb_ctxt (an2, thing', typats') <- exact_pats an1 typats return (an2, thing', bndrs', typats', mb_ctxt') @@ -2342,7 +2330,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where , cid_datafam_insts = adts }) = do (mbWarn', an0, mbOverlap', inst_ty') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lid AnnSemi ds <- withSortKey sortKey [(ClsAtdTag, prepareListAnnotationA ats), @@ -2350,7 +2338,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where (ClsMethodTag, prepareListAnnotationA (bagToList binds)), (ClsSigTag, prepareListAnnotationA sigs) ] - an3 <- markEpAnnL' an2 lidl AnnCloseC -- '}' + an3 <- markEpAnnL an2 lidl AnnCloseC -- '}' let ats' = undynamic ds adts' = undynamic ds @@ -2364,11 +2352,11 @@ instance ExactPrint (ClsInstDecl GhcPs) where where top_matter = do - an0 <- markEpAnnL' an lidl AnnInstance + an0 <- markEpAnnL an lidl AnnInstance mw <- mapM markAnnotated mbWarn mo <- mapM markAnnotated mbOverlap it <- markAnnotated inst_ty - an1 <- markEpAnnL' an0 lidl AnnWhere -- Optional + an1 <- markEpAnnL an0 lidl AnnWhere -- Optional return (mw, an1, mo,it) -- --------------------------------------------------------------------- @@ -2378,8 +2366,8 @@ instance ExactPrint (TyFamInstDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact d@(TyFamInstDecl { tfid_xtn = an, tfid_eqn = eqn }) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnInstance + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnInstance eqn' <- markAnnotated eqn return (d { tfid_xtn = an1, tfid_eqn = eqn' }) @@ -2456,7 +2444,7 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where , psb_id = psyn, psb_args = details , psb_def = pat , psb_dir = dir }) = do - an0 <- markEpAnnL' an lidl AnnPattern + an0 <- markEpAnnL an lidl AnnPattern (an1, psyn', details') <- case details of InfixCon v1 v2 -> do @@ -2471,25 +2459,25 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where return (an0, psyn', PrefixCon tvs' vs') RecCon vs -> do psyn' <- markAnnotated psyn - an1 <- markEpAnnL' an0 lidl AnnOpenC -- '{' + an1 <- markEpAnnL an0 lidl AnnOpenC -- '{' vs' <- markAnnotated vs - an2 <- markEpAnnL' an1 lidl AnnCloseC -- '}' + an2 <- markEpAnnL an1 lidl AnnCloseC -- '}' return (an2, psyn', RecCon vs') (an2, pat', dir') <- case dir of Unidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat return (an2, pat', dir) ImplicitBidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual pat' <- markAnnotated pat return (an2, pat', dir) ExplicitBidirectional mg -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat - an3 <- markEpAnnL' an2 lidl AnnWhere + an3 <- markEpAnnL an2 lidl AnnWhere mg' <- markAnnotated mg return (an3, pat', ExplicitBidirectional mg') @@ -2539,7 +2527,7 @@ exactMatch (Match an mctxt pats grhss) = do debugM $ "exact Match FunRhs:" ++ showPprUnsafe fun an0' <- case strictness of - SrcStrict -> markEpAnnL' an lidl AnnBang + SrcStrict -> markEpAnnL an lidl AnnBang _ -> pure an case fixity of Prefix -> do @@ -2556,18 +2544,18 @@ exactMatch (Match an mctxt pats grhss) = do p2' <- markAnnotated p2 return (an0', FunRhs fun' fixity strictness, [p1',p2']) | otherwise -> do - an0 <- markEpAnnL' an0' lidl AnnOpenP + an0 <- markEpAnnL an0' lidl AnnOpenP p1' <- markAnnotated p1 fun' <- markAnnotated fun p2' <- markAnnotated p2 - an1 <- markEpAnnL' an0 lidl AnnCloseP + an1 <- markEpAnnL an0 lidl AnnCloseP rest' <- mapM markAnnotated rest return (an1, FunRhs fun' fixity strictness, p1':p2':rest') _ -> panic "FunRhs" -- ToDo: why is LamSingle treated differently? LamAlt LamSingle -> do - an0' <- markEpAnnL' an lidl AnnLam + an0' <- markEpAnnL an lidl AnnLam pats' <- markAnnotated pats return (an0', LamAlt LamSingle, pats') LamAlt v -> do @@ -2624,7 +2612,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where exact (HsValBinds an valbinds) = do debugM $ "exact HsValBinds: an=" ++ showAst an - an0 <- markEpAnnL an lal_rest AnnWhere + an0 <- markEpAnnL' an lal_rest AnnWhere case al_anchor $ anns an of Just anc -> do @@ -2636,7 +2624,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where return (HsValBinds an1 valbinds') exact (HsIPBinds an bs) = do - (as, ipb) <- markAnnList an (markEpAnnL an lal_rest AnnWhere + (as, ipb) <- markAnnList an (markEpAnnL' an lal_rest AnnWhere >> markAnnotated bs >>= \bs' -> return (HsIPBinds an bs'::HsLocalBinds GhcPs)) case ipb of @@ -2677,7 +2665,7 @@ instance ExactPrint (IPBind GhcPs) where exact (IPBind an lr rhs) = do lr' <- markAnnotated lr - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual rhs' <- markAnnotated rhs return (IPBind an0 lr' rhs') @@ -2731,7 +2719,7 @@ instance ExactPrint (Sig GhcPs) where return (TypeSig an' vars' ty') exact (PatSynSig an lns typ) = do - an0 <- markEpAnnL' an lasRest AnnPattern + an0 <- markEpAnnL an lasRest AnnPattern lns' <- markAnnotated lns an1 <- markLensAA' an0 lasDcolon typ' <- markAnnotated typ @@ -2739,7 +2727,7 @@ instance ExactPrint (Sig GhcPs) where exact (ClassOpSig an is_deflt vars ty) | is_deflt = do - an0 <- markEpAnnL' an lasRest AnnDefault + an0 <- markEpAnnL an lasRest AnnDefault (an1, vars',ty') <- exactVarSig an0 vars ty return (ClassOpSig an1 is_deflt vars' ty') | otherwise = do @@ -2767,14 +2755,14 @@ instance ExactPrint (Sig GhcPs) where an0 <- markAnnOpen an (inl_src inl) "{-# SPECIALISE" -- Note: may be {-# SPECIALISE_INLINE an1 <- markActivation an0 lidl (inl_act inl) ln' <- markAnnotated ln - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon typs' <- markAnnotated typs an3 <- markEpAnnLMS'' an2 lidl AnnClose (Just "#-}") return (SpecSig an3 ln' typs' inl) exact (SpecInstSig (an,src) typ) = do an0 <- markAnnOpen an src "{-# SPECIALISE" - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance typ' <- markAnnotated typ an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") return (SpecInstSig (an2,src) typ') @@ -2799,7 +2787,7 @@ instance ExactPrint (Sig GhcPs) where case mty of Nothing -> return (an0, mty) Just ty -> do - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty return (an1, Just ty') an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") @@ -2822,9 +2810,9 @@ instance ExactPrint (StandaloneKindSig GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StandaloneKindSig an vars sig) = do - an0 <- markEpAnnL' an lidl AnnType + an0 <- markEpAnnL an lidl AnnType vars' <- markAnnotated vars - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon sig' <- markAnnotated sig return (StandaloneKindSig an1 vars' sig') @@ -2835,10 +2823,10 @@ instance ExactPrint (DefaultDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DefaultDecl an tys) = do - an0 <- markEpAnnL' an lidl AnnDefault - an1 <- markEpAnnL' an0 lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnDefault + an1 <- markEpAnnL an0 lidl AnnOpenP tys' <- markAnnotated tys - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP return (DefaultDecl an2 tys') -- --------------------------------------------------------------------- @@ -2855,11 +2843,11 @@ instance ExactPrint (AnnDecl GhcPs) where n' <- markAnnotated n return (an0, ValueAnnProvenance n') (TypeAnnProvenance n) -> do - an1 <- markEpAnnL' an0 lapr_rest AnnType + an1 <- markEpAnnL an0 lapr_rest AnnType n' <- markAnnotated n return (an1, TypeAnnProvenance n') ModuleAnnProvenance -> do - an1 <- markEpAnnL' an lapr_rest AnnModule + an1 <- markEpAnnL an lapr_rest AnnModule return (an1, prov) e' <- markAnnotated e @@ -2969,11 +2957,11 @@ instance ExactPrint (HsExpr GhcPs) where return (HsLit an lit') exact (HsLam an lam_variant mg) = do - an0 <- mark' an AnnLam + an0 <- mark an AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> mark' an0 AnnCase - LamCases -> mark' an0 AnnCases + LamCase -> mark an0 AnnCase + LamCases -> mark an0 AnnCases mg' <- markAnnotated mg return (HsLam an1 lam_variant mg') @@ -2995,7 +2983,7 @@ instance ExactPrint (HsExpr GhcPs) where return (OpApp an e1' e2' e3') exact (NegApp an e s) = do - an0 <- markEpAnnL' an lidl AnnMinus + an0 <- markEpAnnL an lidl AnnMinus e' <- markAnnotated e return (NegApp an0 e' s) @@ -3018,50 +3006,50 @@ instance ExactPrint (HsExpr GhcPs) where return (SectionR an op' expr') exact (ExplicitTuple an args b) = do - an0 <- if b == Boxed then markEpAnnL' an lidl AnnOpenP - else markEpAnnL' an lidl AnnOpenPH + an0 <- if b == Boxed then markEpAnnL an lidl AnnOpenP + else markEpAnnL an lidl AnnOpenPH args' <- mapM markAnnotated args - an1 <- if b == Boxed then markEpAnnL' an0 lidl AnnCloseP - else markEpAnnL' an0 lidl AnnClosePH + an1 <- if b == Boxed then markEpAnnL an0 lidl AnnCloseP + else markEpAnnL an0 lidl AnnClosePH debugM $ "ExplicitTuple done" return (ExplicitTuple an1 args' b) exact (ExplicitSum an alt arity expr) = do - an0 <- markLensKw' an laesOpen AnnOpenPH + an0 <- markLensKw an laesOpen AnnOpenPH an1 <- markAnnKwAllL an0 laesBarsBefore AnnVbar expr' <- markAnnotated expr an2 <- markAnnKwAllL an1 laesBarsAfter AnnVbar - an3 <- markLensKw' an2 laesClose AnnClosePH + an3 <- markLensKw an2 laesClose AnnClosePH return (ExplicitSum an3 alt arity expr') exact (HsCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- setLayoutBoth $ markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCase an4 e' alts') exact (HsIf an e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsIf an4 e1' e2' e3') exact (HsMultiIf an mg) = do - an0 <- markEpAnnL' an lidl AnnIf - an1 <- markEpAnnL' an0 lidl AnnOpenC -- optional + an0 <- markEpAnnL an lidl AnnIf + an1 <- markEpAnnL an0 lidl AnnOpenC -- optional mg' <- markAnnotated mg - an2 <- markEpAnnL' an1 lidl AnnCloseC -- optional + an2 <- markEpAnnL an1 lidl AnnCloseC -- optional return (HsMultiIf an2 mg') exact (HsLet (tkLet, tkIn) binds e) = do @@ -3086,57 +3074,57 @@ instance ExactPrint (HsExpr GhcPs) where return (ExplicitList an1 es') exact (RecordCon an con_id binds) = do con_id' <- markAnnotated con_id - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC binds' <- markAnnotated binds - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordCon an1 con_id' binds') exact (RecordUpd an expr fields) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC fields' <- markAnnotated fields - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordUpd an1 expr' fields') exact (HsGetField an expr field) = do expr' <- markAnnotated expr field' <- markAnnotated field return (HsGetField an expr' field') exact (HsProjection an flds) = do - an0 <- markLensKw' an lapOpen AnnOpenP + an0 <- markLensKw an lapOpen AnnOpenP flds' <- mapM markAnnotated flds - an1 <- markLensKw' an0 lapClose AnnCloseP + an1 <- markLensKw an0 lapClose AnnCloseP return (HsProjection an1 flds') exact (ExprWithTySig an expr sig) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (ExprWithTySig an0 expr' sig') exact (ArithSeq an s seqInfo) = do - an0 <- markEpAnnL' an lidl AnnOpenS -- '[' + an0 <- markEpAnnL an lidl AnnOpenS -- '[' (an1, seqInfo') <- case seqInfo of From e -> do e' <- markAnnotated e - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot return (an', From e') FromTo e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot e2' <- markAnnotated e2 return (an', FromTo e1' e2') FromThen e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot return (an'', FromThen e1' e2') FromThenTo e1 e2 e3 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot e3' <- markAnnotated e3 return (an'', FromThenTo e1' e2' e3') - an2 <- markEpAnnL' an1 lidl AnnCloseS -- ']' + an2 <- markEpAnnL an1 lidl AnnCloseS -- ']' return (ArithSeq an2 s seqInfo') @@ -3148,46 +3136,46 @@ instance ExactPrint (HsExpr GhcPs) where return (HsTypedBracket an2 e') exact (HsUntypedBracket an (ExpBr a e)) = do - an0 <- markEpAnnL' an lidl AnnOpenEQ -- "[|" - an1 <- markEpAnnL' an0 lidl AnnOpenE -- "[e|" -- optional + an0 <- markEpAnnL an lidl AnnOpenEQ -- "[|" + an1 <- markEpAnnL an0 lidl AnnOpenE -- "[e|" -- optional e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an2 (ExpBr a e')) exact (HsUntypedBracket an (PatBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[p|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (PatBr a e')) exact (HsUntypedBracket an (DecBrL a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[d|") - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseC - an3 <- markEpAnnL' an2 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an3 (DecBrL a e')) exact (HsUntypedBracket an (TypBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[t|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (TypBr a e')) exact (HsUntypedBracket an (VarBr a b e)) = do (an0, e') <- if b then do - an' <- markEpAnnL' an lidl AnnSimpleQuote + an' <- markEpAnnL an lidl AnnSimpleQuote e' <- markAnnotated e return (an', e') else do - an' <- markEpAnnL' an lidl AnnThTyQuote + an' <- markEpAnnL an lidl AnnThTyQuote e' <- markAnnotated e return (an', e') return (HsUntypedBracket an0 (VarBr a b e')) exact (HsTypedSplice an s) = do - an0 <- markEpAnnL' an lidl AnnDollarDollar + an0 <- markEpAnnL an lidl AnnDollarDollar s' <- exact s return (HsTypedSplice an0 s') @@ -3197,15 +3185,15 @@ instance ExactPrint (HsExpr GhcPs) where exact (HsProc an p c) = do debugM $ "HsProc start" - an0 <- markEpAnnL' an lidl AnnProc + an0 <- markEpAnnL an lidl AnnProc p' <- markAnnotated p - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow debugM $ "HsProc after AnnRarrow" c' <- markAnnotated c return (HsProc an1 p' c') exact (HsStatic an e) = do - an0 <- markEpAnnL' an lidl AnnStatic + an0 <- markEpAnnL an lidl AnnStatic e' <- markAnnotated e return (HsStatic an0 e') @@ -3227,14 +3215,14 @@ exactDo :: (Monad m, Monoid w, ExactPrint (LocatedAn an a)) => AnnList -> HsDoFlavour -> LocatedAn an a -> EP w m (AnnList, LocatedAn an a) exactDo an (DoExpr m) stmts = exactMdo an m AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts -exactDo an GhciStmtCtxt stmts = markEpAnnL' an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts +exactDo an GhciStmtCtxt stmts = markEpAnnL an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an (MDoExpr m) stmts = exactMdo an m AnnMdo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an ListComp stmts = markMaybeDodgyStmts an stmts exactDo an MonadComp stmts = markMaybeDodgyStmts an stmts exactMdo :: (Monad m, Monoid w) => AnnList -> Maybe ModuleName -> AnnKeywordId -> EP w m AnnList -exactMdo an Nothing kw = markEpAnnL' an lal_rest kw +exactMdo an Nothing kw = markEpAnnL an lal_rest kw exactMdo an (Just module_name) kw = markEpAnnLMS'' an lal_rest kw (Just n) where n = (moduleNameString module_name) ++ "." ++ (keywordToString kw) @@ -3270,7 +3258,7 @@ instance ExactPrint (HsUntypedSplice GhcPs) where setAnnotationAnchor a _ _ _= a exact (HsUntypedSpliceExpr an e) = do - an0 <- markEpAnnL' an lidl AnnDollar + an0 <- markEpAnnL an lidl AnnDollar e' <- markAnnotated e return (HsUntypedSpliceExpr an0 e') @@ -3334,7 +3322,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3351,7 +3339,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3367,7 +3355,7 @@ instance (ExactPrint (LocatedA body)) debugM $ "HsRecUpdField" f' <- markAnnotated f an0 <- if isPun then return an - else markEpAnnL' an lidl AnnEqual + else markEpAnnL an lidl AnnEqual arg' <- if isPun then return arg else markAnnotated arg @@ -3470,11 +3458,11 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdApp an e1' e2') exact (HsCmdLam an lam_variant matches) = do - an0 <- markEpAnnL' an lidl AnnLam + an0 <- markEpAnnL an lidl AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> markEpAnnL' an0 lidl AnnCase - LamCases -> markEpAnnL' an0 lidl AnnCases + LamCase -> markEpAnnL an0 lidl AnnCase + LamCases -> markEpAnnL an0 lidl AnnCases matches' <- markAnnotated matches return (HsCmdLam an1 lam_variant matches') @@ -3485,23 +3473,23 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdPar (lpar', rpar') e') exact (HsCmdCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCmdCase an4 e' alts') exact (HsCmdIf an a e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsCmdIf an4 a e1' e2' e3') @@ -3515,7 +3503,7 @@ instance ExactPrint (HsCmd GhcPs) where exact (HsCmdDo an es) = do debugM $ "HsCmdDo" - an0 <- markEpAnnL' an lal_rest AnnDo + an0 <- markEpAnnL an lal_rest AnnDo es' <- markAnnotated es return (HsCmdDo an0 es') @@ -3538,7 +3526,7 @@ instance ( exact (BindStmt an pat body) = do debugM $ "BindStmt" pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnLarrow + an0 <- markEpAnnL an lidl AnnLarrow body' <- markAnnotated body return (BindStmt an0 pat' body') @@ -3552,7 +3540,7 @@ instance ( exact (LetStmt an binds) = do debugM $ "LetStmt" - an0 <- markEpAnnL' an lidl AnnLet + an0 <- markEpAnnL an lidl AnnLet binds' <- markAnnotated binds return (LetStmt an0 binds') @@ -3569,7 +3557,7 @@ instance ( exact (RecStmt an stmts a b c d e) = do debugM $ "RecStmt" - an0 <- markEpAnnL' an lal_rest AnnRec + an0 <- markEpAnnL an lal_rest AnnRec (an1, stmts') <- markAnnList' an0 (markAnnotated stmts) return (RecStmt an1 stmts' a b c d e) @@ -3587,25 +3575,25 @@ exactTransStmt :: (Monad m, Monoid w) -> EP w m ([AddEpAnn], Maybe (LHsExpr GhcPs), (LHsExpr GhcPs)) exactTransStmt an by using ThenForm = do debugM $ "exactTransStmt:ThenForm" - an0 <- markEpAnnL' an lidl AnnThen + an0 <- markEpAnnL an lidl AnnThen using' <- markAnnotated using case by of Nothing -> return (an0, by, using') Just b -> do - an1 <- markEpAnnL' an0 lidl AnnBy + an1 <- markEpAnnL an0 lidl AnnBy b' <- markAnnotated b return (an1, Just b', using') exactTransStmt an by using GroupForm = do debugM $ "exactTransStmt:GroupForm" - an0 <- markEpAnnL' an lidl AnnThen - an1 <- markEpAnnL' an0 lidl AnnGroup + an0 <- markEpAnnL an lidl AnnThen + an1 <- markEpAnnL an0 lidl AnnGroup (an2, by') <- case by of Nothing -> return (an1, by) Just b -> do - an2 <- markEpAnnL' an1 lidl AnnBy + an2 <- markEpAnnL an1 lidl AnnBy b' <- markAnnotated b return (an2, Just b') - an3 <- markEpAnnL' an2 lidl AnnUsing + an3 <- markEpAnnL an2 lidl AnnUsing using' <- markAnnotated using return (an3, by', using') @@ -3626,10 +3614,10 @@ instance ExactPrint (TyClDecl GhcPs) where -- that are infix. Turn these into comments so that they feed -- into the right place automatically an0 <- annotationsToComments an lidl [AnnOpenP,AnnCloseP] - an1 <- markEpAnnL' an0 lidl AnnType + an1 <- markEpAnnL an0 lidl AnnType (_anx, ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual rhs' <- markAnnotated rhs return (SynDecl { tcdSExt = an2 , tcdLName = ltycon', tcdTyVars = tyvars', tcdFixity = fixity @@ -3656,8 +3644,8 @@ instance ExactPrint (TyClDecl GhcPs) where | null sigs && isEmptyBag methods && null ats && null at_defs -- No "where" part = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC - an2 <- markEpAnnL' an1 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnOpenC + an2 <- markEpAnnL an1 lidl AnnCloseC return (ClassDecl {tcdCExt = (an2, lo, sortKey), tcdCtxt = context', tcdLName = lclas', tcdTyVars = tyvars', tcdFixity = fixity, @@ -3669,7 +3657,7 @@ instance ExactPrint (TyClDecl GhcPs) where | otherwise -- Laid out = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lidl AnnSemi ds <- withSortKey sortKey [(ClsSigTag, prepareListAnnotationA sigs), @@ -3678,7 +3666,7 @@ instance ExactPrint (TyClDecl GhcPs) where (ClsAtdTag, prepareListAnnotationA at_defs) -- ++ prepareListAnnotation docs ] - an3 <- markEpAnnL' an2 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseC let sigs' = undynamic ds methods' = listToBag $ undynamic ds @@ -3694,15 +3682,15 @@ instance ExactPrint (TyClDecl GhcPs) where where top_matter = do an' <- annotationsToComments an lidl [AnnOpenP, AnnCloseP] - an0 <- markEpAnnL' an' lidl AnnClass + an0 <- markEpAnnL an' lidl AnnClass (_, lclas', tyvars',_,context') <- exactVanillaDeclHead lclas tyvars fixity context (an1, fds') <- if (null fds) then return (an0, fds) else do - an1 <- markEpAnnL' an0 lidl AnnVbar + an1 <- markEpAnnL an0 lidl AnnVbar fds' <- markAnnotated fds return (an1, fds') - an2 <- markEpAnnL' an1 lidl AnnWhere + an2 <- markEpAnnL an1 lidl AnnWhere return (an2, fds', lclas', tyvars',context') @@ -3714,7 +3702,7 @@ instance ExactPrint (FunDep GhcPs) where exact (FunDep an ls rs') = do ls' <- markAnnotated ls - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow rs'' <- markAnnotated rs' return (FunDep an0 ls' rs'') @@ -3741,23 +3729,23 @@ instance ExactPrint (FamilyDecl GhcPs) where case mb_inj of Nothing -> return (an3, mb_inj) Just inj -> do - an4 <- markEpAnnL' an3 lidl AnnVbar + an4 <- markEpAnnL an3 lidl AnnVbar inj' <- markAnnotated inj return (an4, Just inj') (an5, info') <- case info of ClosedTypeFamily mb_eqns -> do - an5 <- markEpAnnL' an4 lidl AnnWhere - an6 <- markEpAnnL' an5 lidl AnnOpenC + an5 <- markEpAnnL an4 lidl AnnWhere + an6 <- markEpAnnL an5 lidl AnnOpenC (an7, mb_eqns') <- case mb_eqns of Nothing -> do - an7 <- markEpAnnL' an6 lidl AnnDotdot + an7 <- markEpAnnL an6 lidl AnnDotdot return (an7, mb_eqns) Just eqns -> do eqns' <- markAnnotated eqns return (an6, Just eqns') - an8 <- markEpAnnL' an7 lidl AnnCloseC + an8 <- markEpAnnL an7 lidl AnnCloseC return (an8, ClosedTypeFamily mb_eqns') _ -> return (an4, info) return (FamilyDecl { fdExt = an5 @@ -3771,30 +3759,30 @@ instance ExactPrint (FamilyDecl GhcPs) where where exact_top_level an' = case top_level of - TopLevel -> markEpAnnL' an' lidl AnnFamily + TopLevel -> markEpAnnL an' lidl AnnFamily NotTopLevel -> do -- It seems that in some kind of legacy -- mode the 'family' keyword is still -- accepted. - markEpAnnL' an' lidl AnnFamily + markEpAnnL an' lidl AnnFamily exact_kind an' = case result of NoSig _ -> return (an', result) KindSig x kind -> do - an0 <- markEpAnnL' an' lidl AnnDcolon + an0 <- markEpAnnL an' lidl AnnDcolon kind' <- markAnnotated kind return (an0, KindSig x kind') TyVarSig x tv_bndr -> do - an0 <- markEpAnnL' an' lidl AnnEqual + an0 <- markEpAnnL an' lidl AnnEqual tv_bndr' <- markAnnotated tv_bndr return (an0, TyVarSig x tv_bndr') exactFlavour :: (Monad m, Monoid w) => [AddEpAnn] -> FamilyInfo GhcPs -> EP w m [AddEpAnn] -exactFlavour an DataFamily = markEpAnnL' an lidl AnnData -exactFlavour an OpenTypeFamily = markEpAnnL' an lidl AnnType -exactFlavour an (ClosedTypeFamily {}) = markEpAnnL' an lidl AnnType +exactFlavour an DataFamily = markEpAnnL an lidl AnnData +exactFlavour an OpenTypeFamily = markEpAnnL an lidl AnnType +exactFlavour an (ClosedTypeFamily {}) = markEpAnnL an lidl AnnType -- --------------------------------------------------------------------- @@ -3821,31 +3809,31 @@ exactDataDefn an exactHdr an0 <- case condecls of DataTypeCons is_type_data _ -> do an0' <- if is_type_data - then markEpAnnL' an' lidl AnnType + then markEpAnnL an' lidl AnnType else return an' - markEpAnnL' an0' lidl AnnData - NewTypeCon _ -> markEpAnnL' an' lidl AnnNewtype + markEpAnnL an0' lidl AnnData + NewTypeCon _ -> markEpAnnL an' lidl AnnNewtype - an1 <- markEpAnnL' an0 lidl AnnInstance -- optional + an1 <- markEpAnnL an0 lidl AnnInstance -- optional mb_ct' <- mapM markAnnotated mb_ct (anx, ln', tvs', b, mctxt') <- exactHdr context (an2, mb_sig') <- case mb_sig of Nothing -> return (an1, Nothing) Just kind -> do - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon kind' <- markAnnotated kind return (an2, Just kind') an3 <- if (needsWhere condecls) - then markEpAnnL' an2 lidl AnnWhere + then markEpAnnL an2 lidl AnnWhere else return an2 - an4 <- markEpAnnL' an3 lidl AnnOpenC + an4 <- markEpAnnL an3 lidl AnnOpenC (an5, condecls') <- exact_condecls an4 (toList condecls) let condecls'' = case condecls of DataTypeCons d _ -> DataTypeCons d condecls' NewTypeCon _ -> case condecls' of [decl] -> NewTypeCon decl _ -> panic "exacprint NewTypeCon" - an6 <- markEpAnnL' an5 lidl AnnCloseC + an6 <- markEpAnnL an5 lidl AnnCloseC derivings' <- mapM markAnnotated derivings return (anx, an6, ln', tvs', b, mctxt', (HsDataDefn { dd_ext = x, dd_ctxt = context @@ -3895,9 +3883,9 @@ instance ExactPrint (InjectivityAnn GhcPs) where getAnnotationEntry _ = NoEntryVal setAnnotationAnchor a _ _ _ = a exact (InjectivityAnn an lhs rhs) = do - an0 <- markEpAnnL' an lidl AnnVbar + an0 <- markEpAnnL an lidl AnnVbar lhs' <- markAnnotated lhs - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow rhs' <- mapM markAnnotated rhs return (InjectivityAnn an1 lhs' rhs') @@ -3950,7 +3938,7 @@ instance ExactPrintTVFlag flag => ExactPrint (HsTyVarBndr flag GhcPs) where exact (KindedTyVar an flag n k) = do r <- exactTVDelimiters an flag $ do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (KindedTyVar an0 flag n' k') case r of @@ -3976,7 +3964,7 @@ instance ExactPrint (HsType GhcPs) where return (HsQualTy an ctxt' ty') exact (HsTyVar an promoted name) = do an0 <- if (promoted == IsPromoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an name' <- markAnnotated name return (HsTyVar an0 promoted name') @@ -4011,7 +3999,7 @@ instance ExactPrint (HsType GhcPs) where return (HsSumTy an1 tys') exact (HsOpTy an promoted t1 lo t2) = do an0 <- if (isPromoted promoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an t1' <- markAnnotated t1 lo' <- markAnnotated lo @@ -4024,7 +4012,7 @@ instance ExactPrint (HsType GhcPs) where return (HsParTy an1 ty') exact (HsIParamTy an n t) = do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon t' <- markAnnotated t return (HsIParamTy an0 n' t') exact (HsStarTy an isUnicode) = do @@ -4034,7 +4022,7 @@ instance ExactPrint (HsType GhcPs) where return (HsStarTy an isUnicode) exact (HsKindSig an ty k) = do ty' <- markAnnotated ty - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (HsKindSig an0 ty' k') exact (HsSpliceTy a splice) = do @@ -4055,24 +4043,24 @@ instance ExactPrint (HsType GhcPs) where return an1 an1 <- case str of - SrcLazy -> mark' an0 AnnTilde - SrcStrict -> mark' an0 AnnBang + SrcLazy -> mark an0 AnnTilde + SrcStrict -> mark an0 AnnBang NoSrcStrict -> return an0 ty' <- markAnnotated ty return (HsBangTy an1 (HsSrcBang mt up str) ty') exact (HsExplicitListTy an prom tys) = do an0 <- if (isPromoted prom) - then mark' an AnnSimpleQuote + then mark an AnnSimpleQuote else return an - an1 <- mark' an0 AnnOpenS + an1 <- mark an0 AnnOpenS tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseS + an2 <- mark an1 AnnCloseS return (HsExplicitListTy an2 prom tys') exact (HsExplicitTupleTy an tys) = do - an0 <- mark' an AnnSimpleQuote - an1 <- mark' an0 AnnOpenP + an0 <- mark an AnnSimpleQuote + an1 <- mark an0 AnnOpenP tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseP + an2 <- mark an1 AnnCloseP return (HsExplicitTupleTy an2 tys') exact (HsTyLit a lit) = do case lit of @@ -4113,7 +4101,7 @@ instance ExactPrint (HsDerivingClause GhcPs) where exact (HsDerivingClause { deriv_clause_ext = an , deriv_clause_strategy = dcs , deriv_clause_tys = dct }) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving exact_strat_before dct' <- markAnnotated dct exact_strat_after @@ -4133,16 +4121,16 @@ instance ExactPrint (DerivStrategy GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StockStrategy an) = do - an0 <- markEpAnnL' an lid AnnStock + an0 <- markEpAnnL an lid AnnStock return (StockStrategy an0) exact (AnyclassStrategy an) = do - an0 <- markEpAnnL' an lid AnnAnyclass + an0 <- markEpAnnL an lid AnnAnyclass return (AnyclassStrategy an0) exact (NewtypeStrategy an) = do - an0 <- markEpAnnL' an lid AnnNewtype + an0 <- markEpAnnL an lid AnnNewtype return (NewtypeStrategy an0) exact (ViaStrategy (XViaStrategyPs an ty)) = do - an0 <- markEpAnnL' an lid AnnVia + an0 <- markEpAnnL an lid AnnVia ty' <- markAnnotated ty return (ViaStrategy (XViaStrategyPs an0 ty')) @@ -4293,7 +4281,7 @@ exact_condecls an cs return (an, cs') | otherwise -- In H98 syntax = do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual cs' <- mapM markAnnotated cs return (an0, cs') where @@ -4317,15 +4305,15 @@ instance ExactPrint (ConDecl GhcPs) where , con_args = args , con_doc = doc }) = do an0 <- if has_forall - then markEpAnnL' an lidl AnnForall + then markEpAnnL an lidl AnnForall else return an ex_tvs' <- mapM markAnnotated ex_tvs an1 <- if has_forall - then markEpAnnL' an0 lidl AnnDot + then markEpAnnL an0 lidl AnnDot else return an0 mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 (con', args') <- exact_details args @@ -4373,7 +4361,7 @@ instance ExactPrint (ConDecl GhcPs) where mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 args' <- case args of @@ -4422,7 +4410,7 @@ instance ExactPrint (ConDeclField GhcPs) where exact (ConDeclField an names ftype mdoc) = do names' <- markAnnotated names - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon ftype' <- markAnnotated ftype return (ConDeclField an0 names' ftype' mdoc) @@ -4496,7 +4484,7 @@ instance ExactPrint (LocatedL [LocatedA (IE GhcPs)]) where exact (L an ies) = do debugM $ "LocatedL [LIE" - an0 <- markEpAnnL an lal_rest AnnHiding + an0 <- markEpAnnL' an lal_rest AnnHiding p <- getPosP debugM $ "LocatedL [LIE:p=" ++ showPprUnsafe p (an1, ies') <- markAnnList an0 (markAnnotated ies) @@ -4579,16 +4567,16 @@ instance ExactPrint (IE GhcPs) where exact (IEThingAll (depr, an) thing doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnCloseP + an0 <- markEpAnnL an lidl AnnOpenP + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingAll (depr', an2) thing' doc') exact (IEThingWith (depr, an) thing wc withs doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnOpenP (an1, wc', withs') <- case wc of NoIEWildcard -> do @@ -4597,17 +4585,17 @@ instance ExactPrint (IE GhcPs) where IEWildcard pos -> do let (bs, as) = splitAt pos withs bs' <- markAnnotated bs - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnComma + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnComma as' <- markAnnotated as return (an2, wc, bs'++as') - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingWith (depr', an2) thing' wc' withs' doc') exact (IEModuleContents (depr, an) m) = do depr' <- markAnnotated depr - an0 <- markEpAnnL' an lidl AnnModule + an0 <- markEpAnnL an lidl AnnModule m' <- markAnnotated m return (IEModuleContents (depr', an0) m') @@ -4658,7 +4646,7 @@ instance ExactPrint (Pat GhcPs) where else return n return (VarPat x n') exact (LazyPat an pat) = do - an0 <- markEpAnnL' an lidl AnnTilde + an0 <- markEpAnnL an lidl AnnTilde pat' <- markAnnotated pat return (LazyPat an0 pat') exact (AsPat at n pat) = do @@ -4673,7 +4661,7 @@ instance ExactPrint (Pat GhcPs) where return (ParPat (lpar', rpar') pat') exact (BangPat an pat) = do - an0 <- markEpAnnL' an lidl AnnBang + an0 <- markEpAnnL an lidl AnnBang pat' <- markAnnotated pat return (BangPat an0 pat') @@ -4683,20 +4671,20 @@ instance ExactPrint (Pat GhcPs) where exact (TuplePat an pats boxity) = do an0 <- case boxity of - Boxed -> markEpAnnL' an lidl AnnOpenP - Unboxed -> markEpAnnL' an lidl AnnOpenPH + Boxed -> markEpAnnL an lidl AnnOpenP + Unboxed -> markEpAnnL an lidl AnnOpenPH pats' <- markAnnotated pats an1 <- case boxity of - Boxed -> markEpAnnL' an0 lidl AnnCloseP - Unboxed -> markEpAnnL' an0 lidl AnnClosePH + Boxed -> markEpAnnL an0 lidl AnnCloseP + Unboxed -> markEpAnnL an0 lidl AnnClosePH return (TuplePat an1 pats' boxity) exact (SumPat an pat alt arity) = do - an0 <- markEpAnnL' an lsumPatParens AnnOpenPH + an0 <- markEpAnnL an lsumPatParens AnnOpenPH an1 <- markAnnKwAllL an0 lsumPatVbarsBefore AnnVbar pat' <- markAnnotated pat an2 <- markAnnKwAllL an1 lsumPatVbarsAfter AnnVbar - an3 <- markEpAnnL' an2 lsumPatParens AnnClosePH + an3 <- markEpAnnL an2 lsumPatParens AnnClosePH return (SumPat an3 pat' alt arity) exact (ConPat an con details) = do @@ -4704,7 +4692,7 @@ instance ExactPrint (Pat GhcPs) where return (ConPat an' con' details') exact (ViewPat an expr pat) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow pat' <- markAnnotated pat return (ViewPat an0 expr' pat') exact (SplicePat x splice) = do @@ -4713,7 +4701,7 @@ instance ExactPrint (Pat GhcPs) where exact p@(LitPat _ lit) = printStringAdvance (hsLit2String lit) >> return p exact (NPat an ol mn z) = do an0 <- if (isJust mn) - then markEpAnnL' an lidl AnnMinus + then markEpAnnL an lidl AnnMinus else return an ol' <- markAnnotated ol return (NPat an0 ol' mn z) @@ -4726,7 +4714,7 @@ instance ExactPrint (Pat GhcPs) where exact (SigPat an pat sig) = do pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (SigPat an0 pat' sig') @@ -4832,9 +4820,9 @@ exactUserCon an c (InfixCon p1 p2) = do return (an, c', InfixCon p1' p2') exactUserCon an c details = do c' <- markAnnotated c - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC details' <- exactConArgs details - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (an1, c', details') instance ExactPrint (HsConPatTyArg GhcPs) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f27517687c711593a23f1c9e5bd09ad9ec22fa4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f27517687c711593a23f1c9e5bd09ad9ec22fa4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 02:45:58 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 20 Mar 2024 22:45:58 -0400 Subject: [Git][ghc/ghc][master] Type operators in promoteOccName (#24570) Message-ID: <65fb9f6628499_17e2c469323707928d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 3 changed files: - compiler/GHC/Types/Name/Occurrence.hs - + testsuite/tests/vdq-rta/should_compile/T24570.hs - testsuite/tests/vdq-rta/should_compile/all.T Changes: ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -516,7 +516,9 @@ demoteOccTvName (OccName space name) = do -- See Note [Promotion] in GHC.Rename.Env. promoteOccName :: OccName -> Maybe OccName promoteOccName (OccName space name) = do - space' <- promoteNameSpace space + promoted_space <- promoteNameSpace space + let tyop = isTvNameSpace promoted_space && isLexVarSym name + space' = if tyop then tcClsName else promoted_space -- special case for type operators (#24570) return $ OccName space' name {- | Other names in the compiler add additional information to an OccName. ===================================== testsuite/tests/vdq-rta/should_compile/T24570.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE RequiredTypeArguments #-} + +module T24570 where + +import Language.Haskell.TH + +idee :: forall a -> a -> a +idee _ x = x + +type (:!@#) = Bool + +f :: Bool -> Bool +f = idee (:!@#) + +type (!@#) = Bool + +g :: Bool -> Bool +g = idee (!@#) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -22,6 +22,7 @@ test('T23739_sizeOf', normal, compile, ['']) test('T23739_symbolVal', normal, compile, ['']) test('T23739_typeRep', normal, compile, ['']) test('T23739_nested', normal, compile, ['']) +test('T24570', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T23739_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da2a10ceab7498fbbd5723dee0393ce75f2bb562 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da2a10ceab7498fbbd5723dee0393ce75f2bb562 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 09:08:14 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 21 Mar 2024 05:08:14 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/sand-witch/forall-tc-fix-th Message-ID: <65fbf8fe6c11e_1a8080903c749985d@gitlab.mail> Andrei Borzenkov pushed new branch wip/sand-witch/forall-tc-fix-th at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sand-witch/forall-tc-fix-th You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 09:12:28 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 21 Mar 2024 05:12:28 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/forall-tc-fix-th] Fix TH handling in `pat_to_type_pat` function (#24571) Message-ID: <65fbf9fc401cc_1a8080b4675c1000f9@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/forall-tc-fix-th at Glasgow Haskell Compiler / GHC Commits: e5ec2e06 by Andrei Borzenkov at 2024-03-21T13:09:09+04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 3 changed files: - compiler/GHC/Tc/Gen/Pat.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -534,6 +534,9 @@ pat_to_type_pat (SigPat _ pat sig_ty) pat_to_type_pat (ParPat _ pat) = do { HsTP x t <- pat_to_type_pat (unLoc pat) ; return (HsTP x (noLocA (HsParTy noAnn t))) } +pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { HsTP x t <- pat_to_type_pat pat + ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } pat_to_type_pat pat = -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to ===================================== testsuite/tests/th/T24571.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell, RequiredTypeArguments #-} +module T24571 where + +g :: forall a -> () +g $([p| a |]) = () ===================================== testsuite/tests/th/all.T ===================================== @@ -605,3 +605,4 @@ test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) test('T24559', normal, compile, ['']) +test('T24571', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5ec2e06f2bc4617fe15b5d17d68bdd64741d558 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5ec2e06f2bc4617fe15b5d17d68bdd64741d558 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 10:09:56 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 21 Mar 2024 06:09:56 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) Message-ID: <65fc0774d9d09_1a808024a7ca0113696@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 1420cc46 by Andrei Borzenkov at 2024-03-21T13:54:09+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 9 changed files: - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/Language/Haskell/Syntax/Type.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout - + testsuite/tests/th/T24299.hs - + testsuite/tests/th/T24299.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -677,7 +677,7 @@ References: [2] 'rnSpliceExpr' [3] 'GHC.Tc.Gen.Splice.qAddModFinalizer' [4] 'GHC.Tc.Gen.Expr.tcExpr' ('HsSpliceE' ('HsSpliced' ...)) -[5] 'GHC.Tc.Gen.HsType.tc_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) +[5] 'GHC.Tc.Gen.HsType.tc_check_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) [6] 'GHC.Tc.Gen.Pat.tc_pat' ('SplicePat' ('HsSpliced' ...)) -} ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -609,7 +609,7 @@ tc_top_lhs_type tyki ctxt (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs <- pushLevelAndSolveEqualitiesX "tc_top_lhs_type" $ tcOuterTKBndrs skol_info hs_outer_bndrs $ do { kind <- newExpectedKind (expectedKindInCtxt ctxt) - ; tc_lhs_type (mkMode tyki) body kind } + ; tc_check_lhs_type (mkMode tyki) body kind } ; outer_bndrs <- scopedSortOuter outer_bndrs ; let outer_tv_bndrs = outerTyVarBndrs outer_bndrs @@ -704,7 +704,7 @@ tcHsTypeApp wc_ty kind -- We are looking at a user-written type, very like a -- signature so we want to solve its equalities right now bindNamedWildCardBinders sig_wcs $ \ _ -> - tc_lhs_type mode hs_ty kind + tc_check_lhs_type mode hs_ty kind -- We do not kind-generalize type applications: we just -- instantiate with exactly what the user says. @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -1002,15 +1002,6 @@ that *can* be kind-polymorphic, we implement just the "up" (functions with "infer" in their name) version, as we gain nothing by also implementing the "down" version. -Note [Future-proofing the type checker] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As discussed in Note [Bidirectional type checking], each HsType form is -handled in *either* tc_infer_hs_type *or* tc_hs_type. These functions -are mutually recursive, so that either one can work for any type former. -But, we want to make sure that our pattern-matches are complete. So, -we have a bunch of repetitive code just so that we get warnings if we're -missing any patterns. - -} ------------------------------------------ @@ -1022,74 +1013,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tc_hs_type mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1135,14 +1065,24 @@ substitution to each HsCoreTy and all is well: ------------------------------------------ tcLHsType :: LHsType GhcRn -> TcKind -> TcM TcType tcLHsType hs_ty exp_kind - = tc_lhs_type typeLevelMode hs_ty exp_kind + = tc_check_lhs_type typeLevelMode hs_ty exp_kind + +tc_check_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_check_lhs_type mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_check_hs_type mode ty exp_kind + +tc_check_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +-- See Note [Bidirectional type checking] +tc_check_hs_type mode ty ek = tc_hs_type mode ty (Check ek) -tc_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_lhs_type :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType tc_lhs_type mode (L span ty) exp_kind = setSrcSpanA span $ tc_hs_type mode ty exp_kind -tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +tc_hs_type :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +-- The main workhorse for type kind checking -- See Note [Bidirectional type checking] tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind @@ -1187,8 +1127,8 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] @@ -1206,84 +1146,63 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind | null (unLoc ctxt) = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind + -- See Note [Body kind of a HsQualTy] + | Check kind <- exp_kind, isConstraintLikeKind kind = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } + ; ty' <- tc_check_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } | otherwise = do { ctxt' <- tc_hs_context mode ctxt - ; ek <- newOpenTypeKind -- The body kind (result of the function) can + ; ek <- newOpenTypeKind -- The body kind (result of the function) can -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + ; ty' <- tc_check_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpKind (unLoc rn_ty) res_ty + liftedTypeKind exp_kind } --------- Lists, arrays, and tuples tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind - = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind + = do { tau_ty <- tc_check_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } - --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } - - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind +tc_hs_type mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys - ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) hs_tys arg_kinds ; let arg_reps = map kindRep arg_kinds arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind - -- The '[] case is handled in tc_infer_hs_type. - -- See Note [Future-proofing the type checker]. + -- for empty list create a `forall a. [a]` kind + -- so it is not instantiated too early + -- + -- See Note [Bidirectional type checking] | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind - + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind + + -- for non-empty lists [t1, t2] unify all `t`'s kinds with + -- kappa, create a type of form + -- (:) @kappa t1 ((:) @kappa t2 ([] @kappa)) + -- and assign kind [kappa] to it | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] @@ -1292,54 +1211,114 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar - ; taus <- zipWithM (tc_lhs_type mode) tys ks + ; taus <- zipWithM (tc_check_lhs_type mode) tys ks ; let kind_con = tupleTyCon Boxed arity ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) - ; ty' <- tc_lhs_type mode ty liftedTypeKind + ; ty' <- tc_check_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tc_hs_type mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k + +--------- Infer +tc_hs_type mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek +tc_hs_type mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tc_hs_type:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_check_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tc_hs_type _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tc_hs_type tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * + + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind {- Note [Variable Specificity and Forall Visibility] @@ -1366,28 +1345,28 @@ Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in "GHC.Core.TyCo ------------------------------------------ tc_mult :: TcTyMode -> HsArrow GhcRn -> TcM Mult -tc_mult mode ty = tc_lhs_type mode (arrowToHsType ty) multiplicityTy +tc_mult mode ty = tc_check_lhs_type mode (arrowToHsType ty) multiplicityTy ------------------------------------------ -tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> TcKind +tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> ExpKind -> TcM TcType tc_fun_type mode mult ty1 ty2 exp_kind = case mode_tyki mode of TypeLevel -> do { traceTc "tc_fun_type" (ppr ty1 $$ ppr ty2) ; arg_k <- newOpenTypeKind ; res_k <- newOpenTypeKind - ; ty1' <- tc_lhs_type mode ty1 arg_k - ; ty2' <- tc_lhs_type mode ty2 res_k + ; ty1' <- tc_check_lhs_type mode ty1 arg_k + ; ty2' <- tc_check_lhs_type mode ty2 res_k ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } KindLevel -> -- no representation polymorphism in kinds. yet. - do { ty1' <- tc_lhs_type mode ty1 liftedTypeKind - ; ty2' <- tc_lhs_type mode ty2 liftedTypeKind + do { ty1' <- tc_check_lhs_type mode ty1 liftedTypeKind + ; ty2' <- tc_check_lhs_type mode ty2 liftedTypeKind ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } {- Note [Skolem escape and forall-types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1442,7 +1421,7 @@ tc_tuple rn_ty mode tup_sort tys exp_kind BoxedTuple -> return (replicate arity liftedTypeKind) UnboxedTuple -> replicateM arity newOpenTypeKind ConstraintTuple -> return (replicate arity constraintKind) - ; tau_tys <- zipWithM (tc_lhs_type mode) tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) tys arg_kinds ; finish_tuple rn_ty tup_sort tau_tys arg_kinds exp_kind } where arity = length tys @@ -1530,9 +1509,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1526,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -1570,6 +1553,14 @@ tcInferTyAppHead _ (L _ (HsTyVar _ _ (L _ tv))) tcInferTyAppHead mode ty = tc_infer_lhs_type mode ty +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty + --------------------------- -- | Apply a type of a given kind to a list of arguments. This instantiates -- invisible parameters as necessary. Always consumes all the arguments, @@ -1656,7 +1647,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args ; arg_mode <- mkHoleMode KindLevel HM_VTA -- HM_VKA: see Note [Wildcards in visible kind application] ; ki_arg <- addErrCtxt (funAppCtxt orig_hs_ty hs_ki_arg n) $ - tc_lhs_type arg_mode hs_ki_arg exp_kind + tc_check_lhs_type arg_mode hs_ki_arg exp_kind ; traceTc "tcInferTyApps (vis kind app)" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder ki_arg @@ -1687,7 +1678,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args , ppr subst ]) ; let exp_kind = substTy subst $ piTyBinderType ki_binder ; arg' <- addErrCtxt (funAppCtxt orig_hs_ty arg n) $ - tc_lhs_type mode arg exp_kind + tc_check_lhs_type mode arg exp_kind ; traceTc "tcInferTyApps (vis normal app) 2" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder arg' ; go (n+1) fun' subst' inner_ki args } @@ -1975,6 +1966,19 @@ checkExpectedKind hs_ty ty act_kind exp_kind n_act_invis_bndrs = invisibleTyBndrCount act_kind n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + +-- tyr <- checkExpKind hs_ty ty (act_ki :: Kind) (exp_ki :: ExpKind) +-- requires that `ty` has kind `act_ki` +-- It checks that the actual kind `act_ki` matches the expected kind `exp_ki` +-- and returns `tyr`, a possibly-casted form of `ty`, that has precisely kind `exp_ki` +-- `hs_ty` is purely for error messages +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + --------------------------- tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] @@ -1988,7 +1992,7 @@ tc_hs_context :: TcTyMode -> LHsContext GhcRn -> TcM [PredType] tc_hs_context mode ctxt = mapM (tc_lhs_pred mode) (unLoc ctxt) tc_lhs_pred :: TcTyMode -> LHsType GhcRn -> TcM PredType -tc_lhs_pred mode pred = tc_lhs_type mode pred constraintKind +tc_lhs_pred mode pred = tc_check_lhs_type mode pred constraintKind --------------------------- tcTyVar :: Name -> TcM (TcType, TcKind) @@ -4045,7 +4049,7 @@ tcHsPartialSigType ctxt sig_ty ; tau <- -- Don't do (addTypeCtxt hs_tau) here else we get -- In the type -- In the type signature: foo :: - tc_lhs_type mode hs_tau ek + tc_check_lhs_type mode hs_tau ek ; return (wcs, wcx, theta, tau) } @@ -4355,8 +4359,8 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind - ; ty <- tc_lhs_type mode hs_ty ek + do { ek <- newExpectedKind ctxt_kind + ; ty <- tc_check_lhs_type mode hs_ty ek ; return (wcs, ty) } ; mapM_ emitNamedTypeHole wcs @@ -4532,7 +4536,7 @@ tc_lhs_kind_sig mode ctxt hs_kind -- Result is zonked = do { kind <- addErrCtxt (text "In the kind" <+> quotes (ppr hs_kind)) $ solveEqualities "tcLHsKindSig" $ - tc_lhs_type mode hs_kind liftedTypeKind + tc_check_lhs_type mode hs_kind liftedTypeKind ; traceTc "tcLHsKindSig" (ppr hs_kind $$ ppr kind) -- No generalization: ; kindGeneralizeNone kind ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Tc.Utils.TcType ( TcKind, TcCoVar, TcTyCoVar, TcTyVarBinder, TcInvisTVBinder, TcReqTVBinder, TcTyCon, MonoTcTyCon, PolyTcTyCon, TcTyConBinder, KnotTied, - ExpType(..), InferResult(..), + ExpType(..), ExpKind, InferResult(..), ExpTypeFRR, ExpSigmaType, ExpSigmaTypeFRR, ExpRhoType, mkCheckExpType, @@ -433,6 +433,9 @@ type ExpSigmaTypeFRR = ExpTypeFRR type ExpRhoType = ExpType +-- | Like 'ExpType', but on kind level +type ExpKind = ExpType + instance Outputable ExpType where ppr (Check ty) = text "Check" <> braces (ppr ty) ppr (Infer ir) = ppr ir ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,8 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + fillInferResult, ) where import GHC.Prelude ===================================== compiler/Language/Haskell/Syntax/Type.hs ===================================== @@ -1006,7 +1006,7 @@ would mean that when we pretty-print it back, we don't know whether the user wrote '*' or 'Type', and lose the parse/ppr roundtrip property. As a workaround, we parse '*' as HsStarTy (if it stands for 'Data.Kind.Type') -and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_hs_type). +and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_check_hs_type). When '*' is a regular type operator (StarIsType is disabled), HsStarTy is not involved. ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * ===================================== testsuite/tests/th/T24299.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24299 where +import Language.Haskell.TH.Syntax (addModFinalizer, runIO) +import GHC.Types (Type) +import System.IO + +type Proxy :: forall a. a -> Type +data Proxy a = MkProxy + +check :: ($(addModFinalizer (runIO (do putStrLn "check"; hFlush stdout)) >> + [t| Proxy |]) :: Type -> Type) Int -- There is kind signature, we are in check mode +check = MkProxy + +infer :: ($(addModFinalizer (runIO (do putStrLn "infer"; hFlush stdout)) >> + [t| Proxy |]) ) Int -- no kind signature, inference mode is enabled +infer = MkProxy ===================================== testsuite/tests/th/T24299.stderr ===================================== @@ -0,0 +1,2 @@ +check +infer ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24299', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1420cc46a84086fbe762f3c173240ec1630ce653 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1420cc46a84086fbe762f3c173240ec1630ce653 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 10:58:00 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 21 Mar 2024 06:58:00 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24565 Message-ID: <65fc12b810928_1a80803988cc813048@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24565 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24565 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 11:49:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 07:49:34 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: EPA: Clean up Exactprint helper functions a bit Message-ID: <65fc1ece1ab0c_1a80805195e74151588@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - c06f1ea8 by Preetham Gujjula at 2024-03-21T07:49:06-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - e1028b0b by Andrei Borzenkov at 2024-03-21T07:49:06-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 8 changed files: - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Types/Name/Occurrence.hs - libraries/base/src/Data/Complex.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T - + testsuite/tests/vdq-rta/should_compile/T24570.hs - testsuite/tests/vdq-rta/should_compile/all.T - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -534,6 +534,9 @@ pat_to_type_pat (SigPat _ pat sig_ty) pat_to_type_pat (ParPat _ pat) = do { HsTP x t <- pat_to_type_pat (unLoc pat) ; return (HsTP x (noLocA (HsParTy noAnn t))) } +pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { HsTP x t <- pat_to_type_pat pat + ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } pat_to_type_pat pat = -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -516,7 +516,9 @@ demoteOccTvName (OccName space name) = do -- See Note [Promotion] in GHC.Rename.Env. promoteOccName :: OccName -> Maybe OccName promoteOccName (OccName space name) = do - space' <- promoteNameSpace space + promoted_space <- promoteNameSpace space + let tyop = isTvNameSpace promoted_space && isLexVarSym name + space' = if tyop then tcClsName else promoted_space -- special case for type operators (#24570) return $ OccName space' name {- | Other names in the compiler add additional information to an OccName. ===================================== libraries/base/src/Data/Complex.hs ===================================== @@ -62,7 +62,7 @@ infix 6 :+ -- it holds that @z == 'abs' z * 'signum' z at . -- -- Note that `Complex`'s instances inherit the deficiencies from the type --- parameter's. For example, @Complex Float@'s 'Ord' instance has similar +-- parameter's. For example, @Complex Float@'s 'Eq' instance has similar -- problems to `Float`'s. -- -- As can be seen in the examples, the 'Foldable' ===================================== testsuite/tests/th/T24571.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell, RequiredTypeArguments #-} +module T24571 where + +g :: forall a -> () +g $([p| a |]) = () ===================================== testsuite/tests/th/all.T ===================================== @@ -605,3 +605,4 @@ test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) test('T24559', normal, compile, ['']) +test('T24571', normal, compile, ['']) ===================================== testsuite/tests/vdq-rta/should_compile/T24570.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE RequiredTypeArguments #-} + +module T24570 where + +import Language.Haskell.TH + +idee :: forall a -> a -> a +idee _ x = x + +type (:!@#) = Bool + +f :: Bool -> Bool +f = idee (:!@#) + +type (!@#) = Bool + +g :: Bool -> Bool +g = idee (!@#) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -22,6 +22,7 @@ test('T23739_sizeOf', normal, compile, ['']) test('T23739_symbolVal', normal, compile, ['']) test('T23739_typeRep', normal, compile, ['']) test('T23739_nested', normal, compile, ['']) +test('T24570', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T23739_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -740,15 +740,12 @@ markExternalSourceText l (SourceText txt) _ = printStringAtRs (realSrcSpan l) (u -- --------------------------------------------------------------------- -markLensMAA :: (Monad m, Monoid w) => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) -markLensMAA (EpAnn anc a cs) l = - case view l a of - Nothing -> return (EpAnn anc a cs) - Just aa -> do - aa' <- markAddEpAnn aa - return (EpAnn anc (set l (Just aa') a) cs) +markLensMAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) +markLensMAA epann l = markLensMAA' epann (lepa . l) -markLensMAA' :: (Monad m, Monoid w) => a -> Lens a (Maybe AddEpAnn) -> EP w m a +markLensMAA' :: (Monad m, Monoid w) + => a -> Lens a (Maybe AddEpAnn) -> EP w m a markLensMAA' a l = case view l a of Nothing -> return a @@ -756,34 +753,27 @@ markLensMAA' a l = aa' <- markAddEpAnn aa return (set l (Just aa') a) -markLensAA :: (Monad m, Monoid w) => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensAA (EpAnn anc a cs) l = do - a' <- markKw (view l a) - return (EpAnn anc (set l a' a) cs) +-- ------------------------------------- + +markLensAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) +markLensAA epann l = markLensAA' epann (lepa . l) -markLensAA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a +markLensAA' :: (Monad m, Monoid w) + => a -> Lens a AddEpAnn -> EP w m a markLensAA' a l = do a' <- markKw (view l a) return (set l a' a) +-- ------------------------------------- markEpAnnLMS :: (Monad m, Monoid w) => EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS an l kw Nothing = markEpAnnL an l kw -markEpAnnLMS (EpAnn anc a cs) l kw (Just str) = do - anns <- mapM go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) +markEpAnnLMS epann l kw ms = markEpAnnLMS'' epann (lepa . l) kw ms markEpAnnLMS'' :: (Monad m, Monoid w) => a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS'' an l kw Nothing = markEpAnnL' an l kw +markEpAnnLMS'' an l kw Nothing = markEpAnnL an l kw markEpAnnLMS'' a l kw (Just str) = do anns <- mapM go (view l a) return (set l anns a) @@ -795,10 +785,11 @@ markEpAnnLMS'' a l kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- markEpAnnMS' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m [AddEpAnn] -markEpAnnMS' anns kw Nothing = mark' anns kw +markEpAnnMS' anns kw Nothing = mark anns kw markEpAnnMS' anns kw (Just str) = do mapM go anns where @@ -809,23 +800,15 @@ markEpAnnMS' anns kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- + markEpAnnLMS' :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS' an l _kw Nothing = markLensKwA an l -markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do - anns <- go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) + => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) +markEpAnnLMS' an l kw ms = markEpAnnLMS0 an (lepa . l) kw ms markEpAnnLMS0 :: (Monad m, Monoid w) - => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS0 an l _kw Nothing = markLensKwA' an l + => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a +markEpAnnLMS0 an l _kw Nothing = markLensKwA an l markEpAnnLMS0 a l kw (Just str) = do anns <- go (view l a) return (set l anns a) @@ -890,7 +873,8 @@ markAnnOpenP' :: (Monad m, Monoid w) => AnnPragma -> SourceText -> String -> EP markAnnOpenP' an NoSourceText txt = markEpAnnLMS0 an lapr_open AnnOpen (Just txt) markAnnOpenP' an (SourceText txt) _ = markEpAnnLMS0 an lapr_open AnnOpen (Just $ unpackFS txt) -markAnnOpen :: (Monad m, Monoid w) => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] +markAnnOpen :: (Monad m, Monoid w) + => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] markAnnOpen an NoSourceText txt = markEpAnnLMS'' an lidl AnnOpen (Just txt) markAnnOpen an (SourceText txt) _ = markEpAnnLMS'' an lidl AnnOpen (Just $ unpackFS txt) @@ -960,6 +944,16 @@ You can think of the function composition operator as having this type: -- --------------------------------------------------------------------- -- Lenses +-- data EpAnn ann +-- = EpAnn { entry :: !Anchor +-- , anns :: !ann +-- , comments :: !EpAnnComments +-- } + +lepa :: Lens (EpAnn a) a +lepa k epAnn = fmap (\newAnns -> epAnn { anns = newAnns }) + (k (anns epAnn)) + -- data AnnsModule -- = AnnsModule { -- am_main :: [AddEpAnn], @@ -1289,26 +1283,20 @@ lsumPatVbarsAfter k parent = fmap (\new -> parent { sumPatVbarsAfter = new }) -- --------------------------------------------------------------------- markLensKwA :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensKwA (EpAnn anc a cs) l = do - loc <- markKw (view l a) - return (EpAnn anc (set l loc a) cs) - -markLensKwA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a -markLensKwA' a l = do +markLensKwA a l = do loc <- markKw (view l a) return (set l loc a) -markLensKw :: (Monad m, Monoid w) +markLensKw' :: (Monad m, Monoid w) => EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a) -markLensKw (EpAnn anc a cs) l kw = do +markLensKw' (EpAnn anc a cs) l kw = do loc <- markKwA kw (view l a) return (EpAnn anc (set l loc a) cs) -markLensKw' :: (Monad m, Monoid w) +markLensKw :: (Monad m, Monoid w) => a -> Lens a EpaLocation -> AnnKeywordId -> EP w m a -markLensKw' a l kw = do +markLensKw a l kw = do loc <- markKwA kw (view l a) return (set l loc a) @@ -1338,18 +1326,18 @@ markLensKwM' a l kw = do -- --------------------------------------------------------------------- -markEpAnnL :: (Monad m, Monoid w) +markEpAnnL' :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) -markEpAnnL (EpAnn anc a cs) l kw = do - anns <- mark' (view l a) kw - return (EpAnn anc (set l anns a) cs) +markEpAnnL' epann l kw = markEpAnnL epann (lepa . l) kw -markEpAnnL' :: (Monad m, Monoid w) +markEpAnnL :: (Monad m, Monoid w) => ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m ann -markEpAnnL' a l kw = do - anns <- mark' (view l a) kw +markEpAnnL a l kw = do + anns <- mark (view l a) kw return (set l anns a) +-- ------------------------------------- + markEpAnnAllL :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) markEpAnnAllL (EpAnn anc a cs) l kw = do @@ -1374,13 +1362,13 @@ markEpAnnAllL' a l kw = do markAddEpAnn :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn markAddEpAnn a@(AddEpAnn kw _) = do - r <- mark' [a] kw + r <- mark [a] kw case r of [a'] -> return a' _ -> error "Should not happen: markAddEpAnn" -mark' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] -mark' anns kw = do +mark :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] +mark anns kw = do case find' kw anns of (lead, Just aa, end) -> do aa' <- markKw aa @@ -1637,14 +1625,14 @@ instance ExactPrint (HsModule GhcPs) where case mmn of Nothing -> return (an, mmn, mdeprec, mexports) Just m -> do - an0 <- markEpAnnL an lam_main AnnModule + an0 <- markEpAnnL' an lam_main AnnModule m' <- markAnnotated m mdeprec' <- setLayoutTopLevelP $ markAnnotated mdeprec mexports' <- setLayoutTopLevelP $ markAnnotated mexports - an1 <- setLayoutTopLevelP $ markEpAnnL an0 lam_main AnnWhere + an1 <- setLayoutTopLevelP $ markEpAnnL' an0 lam_main AnnWhere return (an1, Just m', mdeprec', mexports') @@ -1708,17 +1696,17 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where exact (L an (WarningTxt mb_cat src ws)) = do an0 <- markAnnOpenP an src "{-# WARNING" mb_cat' <- markAnnotated mb_cat - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (WarningTxt mb_cat' src ws')) exact (L an (DeprecatedTxt src ws)) = do an0 <- markAnnOpenP an src "{-# DEPRECATED" - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (DeprecatedTxt src ws')) @@ -1751,7 +1739,7 @@ instance ExactPrint (ImportDecl GhcPs) where exact (ImportDecl (XImportDeclPass ann msrc impl) modname mpkg src safeflag qualFlag mAs hiding) = do - ann0 <- markLensKw ann limportDeclAnnImport AnnImport + ann0 <- markLensKw' ann limportDeclAnnImport AnnImport let (EpAnn _anc an _cs) = ann0 -- "{-# SOURCE" and "#-}" @@ -1955,7 +1943,7 @@ exactDataFamInstDecl an top_lvl , Maybe (LHsContext GhcPs)) pp_hdr mctxt = do an0 <- case top_lvl of - TopLevel -> markEpAnnL' an lidl AnnInstance -- TODO: maybe in toplevel + TopLevel -> markEpAnnL an lidl AnnInstance -- TODO: maybe in toplevel NotTopLevel -> return an exactHsFamInstLHS an0 tycon bndrs pats fixity mctxt @@ -1978,9 +1966,9 @@ instance ExactPrint (DerivDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DerivDecl (mw, an) typ ms mov) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving ms' <- mapM markAnnotated ms - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance mw' <- mapM markAnnotated mw mov' <- mapM markAnnotated mov typ' <- markAnnotated typ @@ -1993,22 +1981,22 @@ instance ExactPrint (ForeignDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (ForeignImport an n ty fimport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnImport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnImport fimport' <- markAnnotated fimport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignImport an2 n' ty' fimport') exact (ForeignExport an n ty fexport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnExport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnExport fexport' <- markAnnotated fexport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignExport an2 n' ty' fexport') @@ -2080,18 +2068,18 @@ instance ExactPrint (WarnDecl GhcPs) where mb_cat' <- markAnnotated mb_cat ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (WarningTxt mb_cat' src ls')) -- return (Warning an1 lns' (WarningTxt mb_cat' src ls')) exact (Warning (ns_spec, an) lns (DeprecatedTxt src ls)) = do ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (DeprecatedTxt src ls')) -- return (Warning an1 lns' (DeprecatedTxt src ls')) @@ -2162,7 +2150,7 @@ instance ExactPrint (RuleDecl GhcPs) where an3 <- markLensMAA' an2 lra_tmanns_snd -- AnnDot lhs' <- markAnnotated lhs - an4 <- markEpAnnL' an3 lra_rest AnnEqual + an4 <- markEpAnnL an3 lra_rest AnnEqual rhs' <- markAnnotated rhs return (HsRule (an4,nsrc) (L ln' n) act mtybndrs' termbndrs' lhs' rhs') @@ -2171,20 +2159,20 @@ markActivation :: (Monad m, Monoid w) markActivation an l act = do case act of ActiveBefore src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ an2 <- markEpAnnLMS'' an1 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an3 <- markEpAnnL' an2 l AnnCloseS -- ']' + an3 <- markEpAnnL an2 l AnnCloseS -- ']' return an3 ActiveAfter src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' + an0 <- markEpAnnL an l AnnOpenS -- '[' an1 <- markEpAnnLMS'' an0 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 NeverActive -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 _ -> return an @@ -2214,8 +2202,8 @@ instance ExactPrint (RoleAnnotDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (RoleAnnotDecl an ltycon roles) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnRole + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnRole ltycon' <- markAnnotated ltycon let markRole (L l (Just r)) = do (L _ r') <- markAnnotated (L l r) @@ -2243,11 +2231,11 @@ instance ExactPrint (RuleBndr GhcPs) where ln' <- markAnnotated ln return (RuleBndr x ln') exact (RuleBndrSig an ln (HsPS x ty)) = do - an0 <- markEpAnnL' an lidl AnnOpenP -- "(" + an0 <- markEpAnnL an lidl AnnOpenP -- "(" ln' <- markAnnotated ln - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty - an2 <- markEpAnnL' an1 lidl AnnCloseP -- ")" + an2 <- markEpAnnL an1 lidl AnnCloseP -- ")" return (RuleBndrSig an2 ln' (HsPS x ty')) -- --------------------------------------------------------------------- @@ -2262,7 +2250,7 @@ instance (ExactPrint body) => ExactPrint (FamEqn GhcPs body) where , feqn_fixity = fixity , feqn_rhs = rhs }) = do (an0, tycon', bndrs', pats', _) <- exactHsFamInstLHS an tycon bndrs pats fixity Nothing - an1 <- markEpAnnL' an0 lidl AnnEqual + an1 <- markEpAnnL an0 lidl AnnEqual rhs' <- markAnnotated rhs return (FamEqn { feqn_ext = an1 , feqn_tycon = tycon' @@ -2286,9 +2274,9 @@ exactHsFamInstLHS :: , HsOuterTyVarBndrs () GhcPs , HsFamEqnPats GhcPs, Maybe (LHsContext GhcPs)) exactHsFamInstLHS an thing bndrs typats fixity mb_ctxt = do - an0 <- markEpAnnL' an lidl AnnForall + an0 <- markEpAnnL an lidl AnnForall bndrs' <- markAnnotated bndrs - an1 <- markEpAnnL' an0 lidl AnnDot + an1 <- markEpAnnL an0 lidl AnnDot mb_ctxt' <- mapM markAnnotated mb_ctxt (an2, thing', typats') <- exact_pats an1 typats return (an2, thing', bndrs', typats', mb_ctxt') @@ -2342,7 +2330,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where , cid_datafam_insts = adts }) = do (mbWarn', an0, mbOverlap', inst_ty') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lid AnnSemi ds <- withSortKey sortKey [(ClsAtdTag, prepareListAnnotationA ats), @@ -2350,7 +2338,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where (ClsMethodTag, prepareListAnnotationA (bagToList binds)), (ClsSigTag, prepareListAnnotationA sigs) ] - an3 <- markEpAnnL' an2 lidl AnnCloseC -- '}' + an3 <- markEpAnnL an2 lidl AnnCloseC -- '}' let ats' = undynamic ds adts' = undynamic ds @@ -2364,11 +2352,11 @@ instance ExactPrint (ClsInstDecl GhcPs) where where top_matter = do - an0 <- markEpAnnL' an lidl AnnInstance + an0 <- markEpAnnL an lidl AnnInstance mw <- mapM markAnnotated mbWarn mo <- mapM markAnnotated mbOverlap it <- markAnnotated inst_ty - an1 <- markEpAnnL' an0 lidl AnnWhere -- Optional + an1 <- markEpAnnL an0 lidl AnnWhere -- Optional return (mw, an1, mo,it) -- --------------------------------------------------------------------- @@ -2378,8 +2366,8 @@ instance ExactPrint (TyFamInstDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact d@(TyFamInstDecl { tfid_xtn = an, tfid_eqn = eqn }) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnInstance + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnInstance eqn' <- markAnnotated eqn return (d { tfid_xtn = an1, tfid_eqn = eqn' }) @@ -2456,7 +2444,7 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where , psb_id = psyn, psb_args = details , psb_def = pat , psb_dir = dir }) = do - an0 <- markEpAnnL' an lidl AnnPattern + an0 <- markEpAnnL an lidl AnnPattern (an1, psyn', details') <- case details of InfixCon v1 v2 -> do @@ -2471,25 +2459,25 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where return (an0, psyn', PrefixCon tvs' vs') RecCon vs -> do psyn' <- markAnnotated psyn - an1 <- markEpAnnL' an0 lidl AnnOpenC -- '{' + an1 <- markEpAnnL an0 lidl AnnOpenC -- '{' vs' <- markAnnotated vs - an2 <- markEpAnnL' an1 lidl AnnCloseC -- '}' + an2 <- markEpAnnL an1 lidl AnnCloseC -- '}' return (an2, psyn', RecCon vs') (an2, pat', dir') <- case dir of Unidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat return (an2, pat', dir) ImplicitBidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual pat' <- markAnnotated pat return (an2, pat', dir) ExplicitBidirectional mg -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat - an3 <- markEpAnnL' an2 lidl AnnWhere + an3 <- markEpAnnL an2 lidl AnnWhere mg' <- markAnnotated mg return (an3, pat', ExplicitBidirectional mg') @@ -2539,7 +2527,7 @@ exactMatch (Match an mctxt pats grhss) = do debugM $ "exact Match FunRhs:" ++ showPprUnsafe fun an0' <- case strictness of - SrcStrict -> markEpAnnL' an lidl AnnBang + SrcStrict -> markEpAnnL an lidl AnnBang _ -> pure an case fixity of Prefix -> do @@ -2556,18 +2544,18 @@ exactMatch (Match an mctxt pats grhss) = do p2' <- markAnnotated p2 return (an0', FunRhs fun' fixity strictness, [p1',p2']) | otherwise -> do - an0 <- markEpAnnL' an0' lidl AnnOpenP + an0 <- markEpAnnL an0' lidl AnnOpenP p1' <- markAnnotated p1 fun' <- markAnnotated fun p2' <- markAnnotated p2 - an1 <- markEpAnnL' an0 lidl AnnCloseP + an1 <- markEpAnnL an0 lidl AnnCloseP rest' <- mapM markAnnotated rest return (an1, FunRhs fun' fixity strictness, p1':p2':rest') _ -> panic "FunRhs" -- ToDo: why is LamSingle treated differently? LamAlt LamSingle -> do - an0' <- markEpAnnL' an lidl AnnLam + an0' <- markEpAnnL an lidl AnnLam pats' <- markAnnotated pats return (an0', LamAlt LamSingle, pats') LamAlt v -> do @@ -2624,7 +2612,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where exact (HsValBinds an valbinds) = do debugM $ "exact HsValBinds: an=" ++ showAst an - an0 <- markEpAnnL an lal_rest AnnWhere + an0 <- markEpAnnL' an lal_rest AnnWhere case al_anchor $ anns an of Just anc -> do @@ -2636,7 +2624,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where return (HsValBinds an1 valbinds') exact (HsIPBinds an bs) = do - (as, ipb) <- markAnnList an (markEpAnnL an lal_rest AnnWhere + (as, ipb) <- markAnnList an (markEpAnnL' an lal_rest AnnWhere >> markAnnotated bs >>= \bs' -> return (HsIPBinds an bs'::HsLocalBinds GhcPs)) case ipb of @@ -2677,7 +2665,7 @@ instance ExactPrint (IPBind GhcPs) where exact (IPBind an lr rhs) = do lr' <- markAnnotated lr - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual rhs' <- markAnnotated rhs return (IPBind an0 lr' rhs') @@ -2731,7 +2719,7 @@ instance ExactPrint (Sig GhcPs) where return (TypeSig an' vars' ty') exact (PatSynSig an lns typ) = do - an0 <- markEpAnnL' an lasRest AnnPattern + an0 <- markEpAnnL an lasRest AnnPattern lns' <- markAnnotated lns an1 <- markLensAA' an0 lasDcolon typ' <- markAnnotated typ @@ -2739,7 +2727,7 @@ instance ExactPrint (Sig GhcPs) where exact (ClassOpSig an is_deflt vars ty) | is_deflt = do - an0 <- markEpAnnL' an lasRest AnnDefault + an0 <- markEpAnnL an lasRest AnnDefault (an1, vars',ty') <- exactVarSig an0 vars ty return (ClassOpSig an1 is_deflt vars' ty') | otherwise = do @@ -2767,14 +2755,14 @@ instance ExactPrint (Sig GhcPs) where an0 <- markAnnOpen an (inl_src inl) "{-# SPECIALISE" -- Note: may be {-# SPECIALISE_INLINE an1 <- markActivation an0 lidl (inl_act inl) ln' <- markAnnotated ln - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon typs' <- markAnnotated typs an3 <- markEpAnnLMS'' an2 lidl AnnClose (Just "#-}") return (SpecSig an3 ln' typs' inl) exact (SpecInstSig (an,src) typ) = do an0 <- markAnnOpen an src "{-# SPECIALISE" - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance typ' <- markAnnotated typ an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") return (SpecInstSig (an2,src) typ') @@ -2799,7 +2787,7 @@ instance ExactPrint (Sig GhcPs) where case mty of Nothing -> return (an0, mty) Just ty -> do - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty return (an1, Just ty') an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") @@ -2822,9 +2810,9 @@ instance ExactPrint (StandaloneKindSig GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StandaloneKindSig an vars sig) = do - an0 <- markEpAnnL' an lidl AnnType + an0 <- markEpAnnL an lidl AnnType vars' <- markAnnotated vars - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon sig' <- markAnnotated sig return (StandaloneKindSig an1 vars' sig') @@ -2835,10 +2823,10 @@ instance ExactPrint (DefaultDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DefaultDecl an tys) = do - an0 <- markEpAnnL' an lidl AnnDefault - an1 <- markEpAnnL' an0 lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnDefault + an1 <- markEpAnnL an0 lidl AnnOpenP tys' <- markAnnotated tys - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP return (DefaultDecl an2 tys') -- --------------------------------------------------------------------- @@ -2855,11 +2843,11 @@ instance ExactPrint (AnnDecl GhcPs) where n' <- markAnnotated n return (an0, ValueAnnProvenance n') (TypeAnnProvenance n) -> do - an1 <- markEpAnnL' an0 lapr_rest AnnType + an1 <- markEpAnnL an0 lapr_rest AnnType n' <- markAnnotated n return (an1, TypeAnnProvenance n') ModuleAnnProvenance -> do - an1 <- markEpAnnL' an lapr_rest AnnModule + an1 <- markEpAnnL an lapr_rest AnnModule return (an1, prov) e' <- markAnnotated e @@ -2969,11 +2957,11 @@ instance ExactPrint (HsExpr GhcPs) where return (HsLit an lit') exact (HsLam an lam_variant mg) = do - an0 <- mark' an AnnLam + an0 <- mark an AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> mark' an0 AnnCase - LamCases -> mark' an0 AnnCases + LamCase -> mark an0 AnnCase + LamCases -> mark an0 AnnCases mg' <- markAnnotated mg return (HsLam an1 lam_variant mg') @@ -2995,7 +2983,7 @@ instance ExactPrint (HsExpr GhcPs) where return (OpApp an e1' e2' e3') exact (NegApp an e s) = do - an0 <- markEpAnnL' an lidl AnnMinus + an0 <- markEpAnnL an lidl AnnMinus e' <- markAnnotated e return (NegApp an0 e' s) @@ -3018,50 +3006,50 @@ instance ExactPrint (HsExpr GhcPs) where return (SectionR an op' expr') exact (ExplicitTuple an args b) = do - an0 <- if b == Boxed then markEpAnnL' an lidl AnnOpenP - else markEpAnnL' an lidl AnnOpenPH + an0 <- if b == Boxed then markEpAnnL an lidl AnnOpenP + else markEpAnnL an lidl AnnOpenPH args' <- mapM markAnnotated args - an1 <- if b == Boxed then markEpAnnL' an0 lidl AnnCloseP - else markEpAnnL' an0 lidl AnnClosePH + an1 <- if b == Boxed then markEpAnnL an0 lidl AnnCloseP + else markEpAnnL an0 lidl AnnClosePH debugM $ "ExplicitTuple done" return (ExplicitTuple an1 args' b) exact (ExplicitSum an alt arity expr) = do - an0 <- markLensKw' an laesOpen AnnOpenPH + an0 <- markLensKw an laesOpen AnnOpenPH an1 <- markAnnKwAllL an0 laesBarsBefore AnnVbar expr' <- markAnnotated expr an2 <- markAnnKwAllL an1 laesBarsAfter AnnVbar - an3 <- markLensKw' an2 laesClose AnnClosePH + an3 <- markLensKw an2 laesClose AnnClosePH return (ExplicitSum an3 alt arity expr') exact (HsCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- setLayoutBoth $ markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCase an4 e' alts') exact (HsIf an e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsIf an4 e1' e2' e3') exact (HsMultiIf an mg) = do - an0 <- markEpAnnL' an lidl AnnIf - an1 <- markEpAnnL' an0 lidl AnnOpenC -- optional + an0 <- markEpAnnL an lidl AnnIf + an1 <- markEpAnnL an0 lidl AnnOpenC -- optional mg' <- markAnnotated mg - an2 <- markEpAnnL' an1 lidl AnnCloseC -- optional + an2 <- markEpAnnL an1 lidl AnnCloseC -- optional return (HsMultiIf an2 mg') exact (HsLet (tkLet, tkIn) binds e) = do @@ -3086,57 +3074,57 @@ instance ExactPrint (HsExpr GhcPs) where return (ExplicitList an1 es') exact (RecordCon an con_id binds) = do con_id' <- markAnnotated con_id - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC binds' <- markAnnotated binds - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordCon an1 con_id' binds') exact (RecordUpd an expr fields) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC fields' <- markAnnotated fields - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordUpd an1 expr' fields') exact (HsGetField an expr field) = do expr' <- markAnnotated expr field' <- markAnnotated field return (HsGetField an expr' field') exact (HsProjection an flds) = do - an0 <- markLensKw' an lapOpen AnnOpenP + an0 <- markLensKw an lapOpen AnnOpenP flds' <- mapM markAnnotated flds - an1 <- markLensKw' an0 lapClose AnnCloseP + an1 <- markLensKw an0 lapClose AnnCloseP return (HsProjection an1 flds') exact (ExprWithTySig an expr sig) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (ExprWithTySig an0 expr' sig') exact (ArithSeq an s seqInfo) = do - an0 <- markEpAnnL' an lidl AnnOpenS -- '[' + an0 <- markEpAnnL an lidl AnnOpenS -- '[' (an1, seqInfo') <- case seqInfo of From e -> do e' <- markAnnotated e - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot return (an', From e') FromTo e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot e2' <- markAnnotated e2 return (an', FromTo e1' e2') FromThen e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot return (an'', FromThen e1' e2') FromThenTo e1 e2 e3 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot e3' <- markAnnotated e3 return (an'', FromThenTo e1' e2' e3') - an2 <- markEpAnnL' an1 lidl AnnCloseS -- ']' + an2 <- markEpAnnL an1 lidl AnnCloseS -- ']' return (ArithSeq an2 s seqInfo') @@ -3148,46 +3136,46 @@ instance ExactPrint (HsExpr GhcPs) where return (HsTypedBracket an2 e') exact (HsUntypedBracket an (ExpBr a e)) = do - an0 <- markEpAnnL' an lidl AnnOpenEQ -- "[|" - an1 <- markEpAnnL' an0 lidl AnnOpenE -- "[e|" -- optional + an0 <- markEpAnnL an lidl AnnOpenEQ -- "[|" + an1 <- markEpAnnL an0 lidl AnnOpenE -- "[e|" -- optional e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an2 (ExpBr a e')) exact (HsUntypedBracket an (PatBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[p|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (PatBr a e')) exact (HsUntypedBracket an (DecBrL a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[d|") - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseC - an3 <- markEpAnnL' an2 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an3 (DecBrL a e')) exact (HsUntypedBracket an (TypBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[t|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (TypBr a e')) exact (HsUntypedBracket an (VarBr a b e)) = do (an0, e') <- if b then do - an' <- markEpAnnL' an lidl AnnSimpleQuote + an' <- markEpAnnL an lidl AnnSimpleQuote e' <- markAnnotated e return (an', e') else do - an' <- markEpAnnL' an lidl AnnThTyQuote + an' <- markEpAnnL an lidl AnnThTyQuote e' <- markAnnotated e return (an', e') return (HsUntypedBracket an0 (VarBr a b e')) exact (HsTypedSplice an s) = do - an0 <- markEpAnnL' an lidl AnnDollarDollar + an0 <- markEpAnnL an lidl AnnDollarDollar s' <- exact s return (HsTypedSplice an0 s') @@ -3197,15 +3185,15 @@ instance ExactPrint (HsExpr GhcPs) where exact (HsProc an p c) = do debugM $ "HsProc start" - an0 <- markEpAnnL' an lidl AnnProc + an0 <- markEpAnnL an lidl AnnProc p' <- markAnnotated p - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow debugM $ "HsProc after AnnRarrow" c' <- markAnnotated c return (HsProc an1 p' c') exact (HsStatic an e) = do - an0 <- markEpAnnL' an lidl AnnStatic + an0 <- markEpAnnL an lidl AnnStatic e' <- markAnnotated e return (HsStatic an0 e') @@ -3227,14 +3215,14 @@ exactDo :: (Monad m, Monoid w, ExactPrint (LocatedAn an a)) => AnnList -> HsDoFlavour -> LocatedAn an a -> EP w m (AnnList, LocatedAn an a) exactDo an (DoExpr m) stmts = exactMdo an m AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts -exactDo an GhciStmtCtxt stmts = markEpAnnL' an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts +exactDo an GhciStmtCtxt stmts = markEpAnnL an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an (MDoExpr m) stmts = exactMdo an m AnnMdo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an ListComp stmts = markMaybeDodgyStmts an stmts exactDo an MonadComp stmts = markMaybeDodgyStmts an stmts exactMdo :: (Monad m, Monoid w) => AnnList -> Maybe ModuleName -> AnnKeywordId -> EP w m AnnList -exactMdo an Nothing kw = markEpAnnL' an lal_rest kw +exactMdo an Nothing kw = markEpAnnL an lal_rest kw exactMdo an (Just module_name) kw = markEpAnnLMS'' an lal_rest kw (Just n) where n = (moduleNameString module_name) ++ "." ++ (keywordToString kw) @@ -3270,7 +3258,7 @@ instance ExactPrint (HsUntypedSplice GhcPs) where setAnnotationAnchor a _ _ _= a exact (HsUntypedSpliceExpr an e) = do - an0 <- markEpAnnL' an lidl AnnDollar + an0 <- markEpAnnL an lidl AnnDollar e' <- markAnnotated e return (HsUntypedSpliceExpr an0 e') @@ -3334,7 +3322,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3351,7 +3339,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3367,7 +3355,7 @@ instance (ExactPrint (LocatedA body)) debugM $ "HsRecUpdField" f' <- markAnnotated f an0 <- if isPun then return an - else markEpAnnL' an lidl AnnEqual + else markEpAnnL an lidl AnnEqual arg' <- if isPun then return arg else markAnnotated arg @@ -3470,11 +3458,11 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdApp an e1' e2') exact (HsCmdLam an lam_variant matches) = do - an0 <- markEpAnnL' an lidl AnnLam + an0 <- markEpAnnL an lidl AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> markEpAnnL' an0 lidl AnnCase - LamCases -> markEpAnnL' an0 lidl AnnCases + LamCase -> markEpAnnL an0 lidl AnnCase + LamCases -> markEpAnnL an0 lidl AnnCases matches' <- markAnnotated matches return (HsCmdLam an1 lam_variant matches') @@ -3485,23 +3473,23 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdPar (lpar', rpar') e') exact (HsCmdCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCmdCase an4 e' alts') exact (HsCmdIf an a e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsCmdIf an4 a e1' e2' e3') @@ -3515,7 +3503,7 @@ instance ExactPrint (HsCmd GhcPs) where exact (HsCmdDo an es) = do debugM $ "HsCmdDo" - an0 <- markEpAnnL' an lal_rest AnnDo + an0 <- markEpAnnL an lal_rest AnnDo es' <- markAnnotated es return (HsCmdDo an0 es') @@ -3538,7 +3526,7 @@ instance ( exact (BindStmt an pat body) = do debugM $ "BindStmt" pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnLarrow + an0 <- markEpAnnL an lidl AnnLarrow body' <- markAnnotated body return (BindStmt an0 pat' body') @@ -3552,7 +3540,7 @@ instance ( exact (LetStmt an binds) = do debugM $ "LetStmt" - an0 <- markEpAnnL' an lidl AnnLet + an0 <- markEpAnnL an lidl AnnLet binds' <- markAnnotated binds return (LetStmt an0 binds') @@ -3569,7 +3557,7 @@ instance ( exact (RecStmt an stmts a b c d e) = do debugM $ "RecStmt" - an0 <- markEpAnnL' an lal_rest AnnRec + an0 <- markEpAnnL an lal_rest AnnRec (an1, stmts') <- markAnnList' an0 (markAnnotated stmts) return (RecStmt an1 stmts' a b c d e) @@ -3587,25 +3575,25 @@ exactTransStmt :: (Monad m, Monoid w) -> EP w m ([AddEpAnn], Maybe (LHsExpr GhcPs), (LHsExpr GhcPs)) exactTransStmt an by using ThenForm = do debugM $ "exactTransStmt:ThenForm" - an0 <- markEpAnnL' an lidl AnnThen + an0 <- markEpAnnL an lidl AnnThen using' <- markAnnotated using case by of Nothing -> return (an0, by, using') Just b -> do - an1 <- markEpAnnL' an0 lidl AnnBy + an1 <- markEpAnnL an0 lidl AnnBy b' <- markAnnotated b return (an1, Just b', using') exactTransStmt an by using GroupForm = do debugM $ "exactTransStmt:GroupForm" - an0 <- markEpAnnL' an lidl AnnThen - an1 <- markEpAnnL' an0 lidl AnnGroup + an0 <- markEpAnnL an lidl AnnThen + an1 <- markEpAnnL an0 lidl AnnGroup (an2, by') <- case by of Nothing -> return (an1, by) Just b -> do - an2 <- markEpAnnL' an1 lidl AnnBy + an2 <- markEpAnnL an1 lidl AnnBy b' <- markAnnotated b return (an2, Just b') - an3 <- markEpAnnL' an2 lidl AnnUsing + an3 <- markEpAnnL an2 lidl AnnUsing using' <- markAnnotated using return (an3, by', using') @@ -3626,10 +3614,10 @@ instance ExactPrint (TyClDecl GhcPs) where -- that are infix. Turn these into comments so that they feed -- into the right place automatically an0 <- annotationsToComments an lidl [AnnOpenP,AnnCloseP] - an1 <- markEpAnnL' an0 lidl AnnType + an1 <- markEpAnnL an0 lidl AnnType (_anx, ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual rhs' <- markAnnotated rhs return (SynDecl { tcdSExt = an2 , tcdLName = ltycon', tcdTyVars = tyvars', tcdFixity = fixity @@ -3656,8 +3644,8 @@ instance ExactPrint (TyClDecl GhcPs) where | null sigs && isEmptyBag methods && null ats && null at_defs -- No "where" part = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC - an2 <- markEpAnnL' an1 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnOpenC + an2 <- markEpAnnL an1 lidl AnnCloseC return (ClassDecl {tcdCExt = (an2, lo, sortKey), tcdCtxt = context', tcdLName = lclas', tcdTyVars = tyvars', tcdFixity = fixity, @@ -3669,7 +3657,7 @@ instance ExactPrint (TyClDecl GhcPs) where | otherwise -- Laid out = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lidl AnnSemi ds <- withSortKey sortKey [(ClsSigTag, prepareListAnnotationA sigs), @@ -3678,7 +3666,7 @@ instance ExactPrint (TyClDecl GhcPs) where (ClsAtdTag, prepareListAnnotationA at_defs) -- ++ prepareListAnnotation docs ] - an3 <- markEpAnnL' an2 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseC let sigs' = undynamic ds methods' = listToBag $ undynamic ds @@ -3694,15 +3682,15 @@ instance ExactPrint (TyClDecl GhcPs) where where top_matter = do an' <- annotationsToComments an lidl [AnnOpenP, AnnCloseP] - an0 <- markEpAnnL' an' lidl AnnClass + an0 <- markEpAnnL an' lidl AnnClass (_, lclas', tyvars',_,context') <- exactVanillaDeclHead lclas tyvars fixity context (an1, fds') <- if (null fds) then return (an0, fds) else do - an1 <- markEpAnnL' an0 lidl AnnVbar + an1 <- markEpAnnL an0 lidl AnnVbar fds' <- markAnnotated fds return (an1, fds') - an2 <- markEpAnnL' an1 lidl AnnWhere + an2 <- markEpAnnL an1 lidl AnnWhere return (an2, fds', lclas', tyvars',context') @@ -3714,7 +3702,7 @@ instance ExactPrint (FunDep GhcPs) where exact (FunDep an ls rs') = do ls' <- markAnnotated ls - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow rs'' <- markAnnotated rs' return (FunDep an0 ls' rs'') @@ -3741,23 +3729,23 @@ instance ExactPrint (FamilyDecl GhcPs) where case mb_inj of Nothing -> return (an3, mb_inj) Just inj -> do - an4 <- markEpAnnL' an3 lidl AnnVbar + an4 <- markEpAnnL an3 lidl AnnVbar inj' <- markAnnotated inj return (an4, Just inj') (an5, info') <- case info of ClosedTypeFamily mb_eqns -> do - an5 <- markEpAnnL' an4 lidl AnnWhere - an6 <- markEpAnnL' an5 lidl AnnOpenC + an5 <- markEpAnnL an4 lidl AnnWhere + an6 <- markEpAnnL an5 lidl AnnOpenC (an7, mb_eqns') <- case mb_eqns of Nothing -> do - an7 <- markEpAnnL' an6 lidl AnnDotdot + an7 <- markEpAnnL an6 lidl AnnDotdot return (an7, mb_eqns) Just eqns -> do eqns' <- markAnnotated eqns return (an6, Just eqns') - an8 <- markEpAnnL' an7 lidl AnnCloseC + an8 <- markEpAnnL an7 lidl AnnCloseC return (an8, ClosedTypeFamily mb_eqns') _ -> return (an4, info) return (FamilyDecl { fdExt = an5 @@ -3771,30 +3759,30 @@ instance ExactPrint (FamilyDecl GhcPs) where where exact_top_level an' = case top_level of - TopLevel -> markEpAnnL' an' lidl AnnFamily + TopLevel -> markEpAnnL an' lidl AnnFamily NotTopLevel -> do -- It seems that in some kind of legacy -- mode the 'family' keyword is still -- accepted. - markEpAnnL' an' lidl AnnFamily + markEpAnnL an' lidl AnnFamily exact_kind an' = case result of NoSig _ -> return (an', result) KindSig x kind -> do - an0 <- markEpAnnL' an' lidl AnnDcolon + an0 <- markEpAnnL an' lidl AnnDcolon kind' <- markAnnotated kind return (an0, KindSig x kind') TyVarSig x tv_bndr -> do - an0 <- markEpAnnL' an' lidl AnnEqual + an0 <- markEpAnnL an' lidl AnnEqual tv_bndr' <- markAnnotated tv_bndr return (an0, TyVarSig x tv_bndr') exactFlavour :: (Monad m, Monoid w) => [AddEpAnn] -> FamilyInfo GhcPs -> EP w m [AddEpAnn] -exactFlavour an DataFamily = markEpAnnL' an lidl AnnData -exactFlavour an OpenTypeFamily = markEpAnnL' an lidl AnnType -exactFlavour an (ClosedTypeFamily {}) = markEpAnnL' an lidl AnnType +exactFlavour an DataFamily = markEpAnnL an lidl AnnData +exactFlavour an OpenTypeFamily = markEpAnnL an lidl AnnType +exactFlavour an (ClosedTypeFamily {}) = markEpAnnL an lidl AnnType -- --------------------------------------------------------------------- @@ -3821,31 +3809,31 @@ exactDataDefn an exactHdr an0 <- case condecls of DataTypeCons is_type_data _ -> do an0' <- if is_type_data - then markEpAnnL' an' lidl AnnType + then markEpAnnL an' lidl AnnType else return an' - markEpAnnL' an0' lidl AnnData - NewTypeCon _ -> markEpAnnL' an' lidl AnnNewtype + markEpAnnL an0' lidl AnnData + NewTypeCon _ -> markEpAnnL an' lidl AnnNewtype - an1 <- markEpAnnL' an0 lidl AnnInstance -- optional + an1 <- markEpAnnL an0 lidl AnnInstance -- optional mb_ct' <- mapM markAnnotated mb_ct (anx, ln', tvs', b, mctxt') <- exactHdr context (an2, mb_sig') <- case mb_sig of Nothing -> return (an1, Nothing) Just kind -> do - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon kind' <- markAnnotated kind return (an2, Just kind') an3 <- if (needsWhere condecls) - then markEpAnnL' an2 lidl AnnWhere + then markEpAnnL an2 lidl AnnWhere else return an2 - an4 <- markEpAnnL' an3 lidl AnnOpenC + an4 <- markEpAnnL an3 lidl AnnOpenC (an5, condecls') <- exact_condecls an4 (toList condecls) let condecls'' = case condecls of DataTypeCons d _ -> DataTypeCons d condecls' NewTypeCon _ -> case condecls' of [decl] -> NewTypeCon decl _ -> panic "exacprint NewTypeCon" - an6 <- markEpAnnL' an5 lidl AnnCloseC + an6 <- markEpAnnL an5 lidl AnnCloseC derivings' <- mapM markAnnotated derivings return (anx, an6, ln', tvs', b, mctxt', (HsDataDefn { dd_ext = x, dd_ctxt = context @@ -3895,9 +3883,9 @@ instance ExactPrint (InjectivityAnn GhcPs) where getAnnotationEntry _ = NoEntryVal setAnnotationAnchor a _ _ _ = a exact (InjectivityAnn an lhs rhs) = do - an0 <- markEpAnnL' an lidl AnnVbar + an0 <- markEpAnnL an lidl AnnVbar lhs' <- markAnnotated lhs - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow rhs' <- mapM markAnnotated rhs return (InjectivityAnn an1 lhs' rhs') @@ -3950,7 +3938,7 @@ instance ExactPrintTVFlag flag => ExactPrint (HsTyVarBndr flag GhcPs) where exact (KindedTyVar an flag n k) = do r <- exactTVDelimiters an flag $ do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (KindedTyVar an0 flag n' k') case r of @@ -3976,7 +3964,7 @@ instance ExactPrint (HsType GhcPs) where return (HsQualTy an ctxt' ty') exact (HsTyVar an promoted name) = do an0 <- if (promoted == IsPromoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an name' <- markAnnotated name return (HsTyVar an0 promoted name') @@ -4011,7 +3999,7 @@ instance ExactPrint (HsType GhcPs) where return (HsSumTy an1 tys') exact (HsOpTy an promoted t1 lo t2) = do an0 <- if (isPromoted promoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an t1' <- markAnnotated t1 lo' <- markAnnotated lo @@ -4024,7 +4012,7 @@ instance ExactPrint (HsType GhcPs) where return (HsParTy an1 ty') exact (HsIParamTy an n t) = do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon t' <- markAnnotated t return (HsIParamTy an0 n' t') exact (HsStarTy an isUnicode) = do @@ -4034,7 +4022,7 @@ instance ExactPrint (HsType GhcPs) where return (HsStarTy an isUnicode) exact (HsKindSig an ty k) = do ty' <- markAnnotated ty - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (HsKindSig an0 ty' k') exact (HsSpliceTy a splice) = do @@ -4055,24 +4043,24 @@ instance ExactPrint (HsType GhcPs) where return an1 an1 <- case str of - SrcLazy -> mark' an0 AnnTilde - SrcStrict -> mark' an0 AnnBang + SrcLazy -> mark an0 AnnTilde + SrcStrict -> mark an0 AnnBang NoSrcStrict -> return an0 ty' <- markAnnotated ty return (HsBangTy an1 (HsSrcBang mt up str) ty') exact (HsExplicitListTy an prom tys) = do an0 <- if (isPromoted prom) - then mark' an AnnSimpleQuote + then mark an AnnSimpleQuote else return an - an1 <- mark' an0 AnnOpenS + an1 <- mark an0 AnnOpenS tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseS + an2 <- mark an1 AnnCloseS return (HsExplicitListTy an2 prom tys') exact (HsExplicitTupleTy an tys) = do - an0 <- mark' an AnnSimpleQuote - an1 <- mark' an0 AnnOpenP + an0 <- mark an AnnSimpleQuote + an1 <- mark an0 AnnOpenP tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseP + an2 <- mark an1 AnnCloseP return (HsExplicitTupleTy an2 tys') exact (HsTyLit a lit) = do case lit of @@ -4113,7 +4101,7 @@ instance ExactPrint (HsDerivingClause GhcPs) where exact (HsDerivingClause { deriv_clause_ext = an , deriv_clause_strategy = dcs , deriv_clause_tys = dct }) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving exact_strat_before dct' <- markAnnotated dct exact_strat_after @@ -4133,16 +4121,16 @@ instance ExactPrint (DerivStrategy GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StockStrategy an) = do - an0 <- markEpAnnL' an lid AnnStock + an0 <- markEpAnnL an lid AnnStock return (StockStrategy an0) exact (AnyclassStrategy an) = do - an0 <- markEpAnnL' an lid AnnAnyclass + an0 <- markEpAnnL an lid AnnAnyclass return (AnyclassStrategy an0) exact (NewtypeStrategy an) = do - an0 <- markEpAnnL' an lid AnnNewtype + an0 <- markEpAnnL an lid AnnNewtype return (NewtypeStrategy an0) exact (ViaStrategy (XViaStrategyPs an ty)) = do - an0 <- markEpAnnL' an lid AnnVia + an0 <- markEpAnnL an lid AnnVia ty' <- markAnnotated ty return (ViaStrategy (XViaStrategyPs an0 ty')) @@ -4293,7 +4281,7 @@ exact_condecls an cs return (an, cs') | otherwise -- In H98 syntax = do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual cs' <- mapM markAnnotated cs return (an0, cs') where @@ -4317,15 +4305,15 @@ instance ExactPrint (ConDecl GhcPs) where , con_args = args , con_doc = doc }) = do an0 <- if has_forall - then markEpAnnL' an lidl AnnForall + then markEpAnnL an lidl AnnForall else return an ex_tvs' <- mapM markAnnotated ex_tvs an1 <- if has_forall - then markEpAnnL' an0 lidl AnnDot + then markEpAnnL an0 lidl AnnDot else return an0 mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 (con', args') <- exact_details args @@ -4373,7 +4361,7 @@ instance ExactPrint (ConDecl GhcPs) where mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 args' <- case args of @@ -4422,7 +4410,7 @@ instance ExactPrint (ConDeclField GhcPs) where exact (ConDeclField an names ftype mdoc) = do names' <- markAnnotated names - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon ftype' <- markAnnotated ftype return (ConDeclField an0 names' ftype' mdoc) @@ -4496,7 +4484,7 @@ instance ExactPrint (LocatedL [LocatedA (IE GhcPs)]) where exact (L an ies) = do debugM $ "LocatedL [LIE" - an0 <- markEpAnnL an lal_rest AnnHiding + an0 <- markEpAnnL' an lal_rest AnnHiding p <- getPosP debugM $ "LocatedL [LIE:p=" ++ showPprUnsafe p (an1, ies') <- markAnnList an0 (markAnnotated ies) @@ -4579,16 +4567,16 @@ instance ExactPrint (IE GhcPs) where exact (IEThingAll (depr, an) thing doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnCloseP + an0 <- markEpAnnL an lidl AnnOpenP + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingAll (depr', an2) thing' doc') exact (IEThingWith (depr, an) thing wc withs doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnOpenP (an1, wc', withs') <- case wc of NoIEWildcard -> do @@ -4597,17 +4585,17 @@ instance ExactPrint (IE GhcPs) where IEWildcard pos -> do let (bs, as) = splitAt pos withs bs' <- markAnnotated bs - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnComma + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnComma as' <- markAnnotated as return (an2, wc, bs'++as') - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingWith (depr', an2) thing' wc' withs' doc') exact (IEModuleContents (depr, an) m) = do depr' <- markAnnotated depr - an0 <- markEpAnnL' an lidl AnnModule + an0 <- markEpAnnL an lidl AnnModule m' <- markAnnotated m return (IEModuleContents (depr', an0) m') @@ -4658,7 +4646,7 @@ instance ExactPrint (Pat GhcPs) where else return n return (VarPat x n') exact (LazyPat an pat) = do - an0 <- markEpAnnL' an lidl AnnTilde + an0 <- markEpAnnL an lidl AnnTilde pat' <- markAnnotated pat return (LazyPat an0 pat') exact (AsPat at n pat) = do @@ -4673,7 +4661,7 @@ instance ExactPrint (Pat GhcPs) where return (ParPat (lpar', rpar') pat') exact (BangPat an pat) = do - an0 <- markEpAnnL' an lidl AnnBang + an0 <- markEpAnnL an lidl AnnBang pat' <- markAnnotated pat return (BangPat an0 pat') @@ -4683,20 +4671,20 @@ instance ExactPrint (Pat GhcPs) where exact (TuplePat an pats boxity) = do an0 <- case boxity of - Boxed -> markEpAnnL' an lidl AnnOpenP - Unboxed -> markEpAnnL' an lidl AnnOpenPH + Boxed -> markEpAnnL an lidl AnnOpenP + Unboxed -> markEpAnnL an lidl AnnOpenPH pats' <- markAnnotated pats an1 <- case boxity of - Boxed -> markEpAnnL' an0 lidl AnnCloseP - Unboxed -> markEpAnnL' an0 lidl AnnClosePH + Boxed -> markEpAnnL an0 lidl AnnCloseP + Unboxed -> markEpAnnL an0 lidl AnnClosePH return (TuplePat an1 pats' boxity) exact (SumPat an pat alt arity) = do - an0 <- markEpAnnL' an lsumPatParens AnnOpenPH + an0 <- markEpAnnL an lsumPatParens AnnOpenPH an1 <- markAnnKwAllL an0 lsumPatVbarsBefore AnnVbar pat' <- markAnnotated pat an2 <- markAnnKwAllL an1 lsumPatVbarsAfter AnnVbar - an3 <- markEpAnnL' an2 lsumPatParens AnnClosePH + an3 <- markEpAnnL an2 lsumPatParens AnnClosePH return (SumPat an3 pat' alt arity) exact (ConPat an con details) = do @@ -4704,7 +4692,7 @@ instance ExactPrint (Pat GhcPs) where return (ConPat an' con' details') exact (ViewPat an expr pat) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow pat' <- markAnnotated pat return (ViewPat an0 expr' pat') exact (SplicePat x splice) = do @@ -4713,7 +4701,7 @@ instance ExactPrint (Pat GhcPs) where exact p@(LitPat _ lit) = printStringAdvance (hsLit2String lit) >> return p exact (NPat an ol mn z) = do an0 <- if (isJust mn) - then markEpAnnL' an lidl AnnMinus + then markEpAnnL an lidl AnnMinus else return an ol' <- markAnnotated ol return (NPat an0 ol' mn z) @@ -4726,7 +4714,7 @@ instance ExactPrint (Pat GhcPs) where exact (SigPat an pat sig) = do pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (SigPat an0 pat' sig') @@ -4832,9 +4820,9 @@ exactUserCon an c (InfixCon p1 p2) = do return (an, c', InfixCon p1' p2') exactUserCon an c details = do c' <- markAnnotated c - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC details' <- exactConArgs details - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (an1, c', details') instance ExactPrint (HsConPatTyArg GhcPs) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4373a99b39b63b663be83f01850a0f0b82572d8d...e1028b0bcbce3995ab257a7f3fcbed5386ae78f9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4373a99b39b63b663be83f01850a0f0b82572d8d...e1028b0bcbce3995ab257a7f3fcbed5386ae78f9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 11:53:48 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 21 Mar 2024 07:53:48 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) Message-ID: <65fc1fcce9637_1a8080547dfec1560c8@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 28dedd4e by Andrei Borzenkov at 2024-03-21T15:53:23+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 9 changed files: - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/Language/Haskell/Syntax/Type.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout - + testsuite/tests/th/T24299.hs - + testsuite/tests/th/T24299.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -677,7 +677,7 @@ References: [2] 'rnSpliceExpr' [3] 'GHC.Tc.Gen.Splice.qAddModFinalizer' [4] 'GHC.Tc.Gen.Expr.tcExpr' ('HsSpliceE' ('HsSpliced' ...)) -[5] 'GHC.Tc.Gen.HsType.tc_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) +[5] 'GHC.Tc.Gen.HsType.tc_check_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) [6] 'GHC.Tc.Gen.Pat.tc_pat' ('SplicePat' ('HsSpliced' ...)) -} ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -609,7 +609,7 @@ tc_top_lhs_type tyki ctxt (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs <- pushLevelAndSolveEqualitiesX "tc_top_lhs_type" $ tcOuterTKBndrs skol_info hs_outer_bndrs $ do { kind <- newExpectedKind (expectedKindInCtxt ctxt) - ; tc_lhs_type (mkMode tyki) body kind } + ; tc_check_lhs_type (mkMode tyki) body kind } ; outer_bndrs <- scopedSortOuter outer_bndrs ; let outer_tv_bndrs = outerTyVarBndrs outer_bndrs @@ -704,7 +704,7 @@ tcHsTypeApp wc_ty kind -- We are looking at a user-written type, very like a -- signature so we want to solve its equalities right now bindNamedWildCardBinders sig_wcs $ \ _ -> - tc_lhs_type mode hs_ty kind + tc_check_lhs_type mode hs_ty kind -- We do not kind-generalize type applications: we just -- instantiate with exactly what the user says. @@ -824,7 +824,7 @@ tcHsLiftedType hs_ty = addTypeCtxt hs_ty $ tcHsLiftedTypeNC hs_ty tcHsOpenTypeNC hs_ty = do { ek <- newOpenTypeKind; tcLHsType hs_ty ek } tcHsLiftedTypeNC hs_ty = tcLHsType hs_ty liftedTypeKind --- Like tcHsType, but takes an expected kind +-- Like tcLHsType, but takes an expected kind tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType tcCheckLHsType hs_ty exp_kind = addTypeCtxt hs_ty $ @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -890,12 +890,18 @@ Terms are eagerly instantiated. This means that if you say x = id then `id` gets instantiated to have type alpha -> alpha. The variable -alpha is then unconstrained and regeneralized. But we cannot do this -in types, as we have no type-level lambda. So, when we are sure -that we will not want to regeneralize later -- because we are done -checking a type, for example -- we can instantiate. But we do not -instantiate at variables, nor do we in tcInferLHsTypeUnsaturated, -which is used by :kind in GHCi. +alpha is then unconstrained and regeneralized. So we may well end up with + x = /\x. id @a +But we cannot do this in types, as we have no type-level lambda. + +So, we must be careful only to instantiate at the last possible moment, when +we're sure we're never going to want the lost polymorphism again. This is done +in calls to `tcInstInvisibleTyBinders`; a particular case in point is in +`checkExpectedKind`. + +Otherwise, we are careful /not/ to instantiate. For example: +* at a variable in `tcTyVar` +* in `tcInferLHsTypeUnsaturated`, which is used by :kind in GHCi. ************************************************************************ * * @@ -969,48 +975,18 @@ instance Outputable TcTyMode where {- Note [Bidirectional type checking] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In expressions, whenever we see a polymorphic identifier, say `id`, we are -free to instantiate it with metavariables, knowing that we can always -re-generalize with type-lambdas when necessary. For example: - - rank2 :: (forall a. a -> a) -> () - x = rank2 id - -When checking the body of `x`, we can instantiate `id` with a metavariable. -Then, when we're checking the application of `rank2`, we notice that we really -need a polymorphic `id`, and then re-generalize over the unconstrained -metavariable. - -In types, however, we're not so lucky, because *we cannot re-generalize*! -There is no lambda. So, we must be careful only to instantiate at the last -possible moment, when we're sure we're never going to want the lost polymorphism -again. This is done in calls to tcInstInvisibleTyBinders. - -To implement this behavior, we use bidirectional type checking, where we -explicitly think about whether we know the kind of the type we're checking -or not. Note that there is a difference between not knowing a kind and -knowing a metavariable kind: the metavariables are TauTvs, and cannot become -forall-quantified kinds. Previously (before dependent types), there were -no higher-rank kinds, and so we could instantiate early and be sure that -no types would have polymorphic kinds, and so we could always assume that -the kind of a type was a fresh metavariable. Not so anymore, thus the -need for two algorithms. - -For HsType forms that can never be kind-polymorphic, we implement only the -"down" direction, where we safely assume a metavariable kind. For HsType forms -that *can* be kind-polymorphic, we implement just the "up" (functions with -"infer" in their name) version, as we gain nothing by also implementing the -"down" version. - -Note [Future-proofing the type checker] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As discussed in Note [Bidirectional type checking], each HsType form is -handled in *either* tc_infer_hs_type *or* tc_hs_type. These functions -are mutually recursive, so that either one can work for any type former. -But, we want to make sure that our pattern-matches are complete. So, -we have a bunch of repetitive code just so that we get warnings if we're -missing any patterns. +In types, as in terms, we use bidirectional type infefence. The main workhorse +function looks like this: + + type ExpKind = ExpType + data ExpType = Check TcSigmaKind | Infer ...(hole TcRhoType)... + tc_hs_type :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType + +* When the `ExpKind` argument is (Check ki), we /check/ that the type has + kind `ki` +* When the `ExpKind` argument is (Infer hole), we /infer/ the kind of the + type, and fill the hole with that kind -} ------------------------------------------ @@ -1022,74 +998,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tc_hs_type mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1135,14 +1050,24 @@ substitution to each HsCoreTy and all is well: ------------------------------------------ tcLHsType :: LHsType GhcRn -> TcKind -> TcM TcType tcLHsType hs_ty exp_kind - = tc_lhs_type typeLevelMode hs_ty exp_kind + = tc_check_lhs_type typeLevelMode hs_ty exp_kind + +tc_check_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_check_lhs_type mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_check_hs_type mode ty exp_kind + +tc_check_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +-- See Note [Bidirectional type checking] +tc_check_hs_type mode ty ek = tc_hs_type mode ty (Check ek) -tc_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_lhs_type :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType tc_lhs_type mode (L span ty) exp_kind = setSrcSpanA span $ tc_hs_type mode ty exp_kind -tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +tc_hs_type :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +-- The main workhorse for type kind checking -- See Note [Bidirectional type checking] tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind @@ -1187,8 +1112,8 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] @@ -1206,84 +1131,57 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind | null (unLoc ctxt) = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind + -- See Note [Body kind of a HsQualTy] + | Check kind <- exp_kind, isConstraintLikeKind kind = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } + ; ty' <- tc_check_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } | otherwise = do { ctxt' <- tc_hs_context mode ctxt - ; ek <- newOpenTypeKind -- The body kind (result of the function) can + ; ek <- newOpenTypeKind -- The body kind (result of the function) can -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + ; ty' <- tc_check_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpKind (unLoc rn_ty) res_ty + liftedTypeKind exp_kind } --------- Lists, arrays, and tuples tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind - = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind + = do { tau_ty <- tc_check_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } - --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } - - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind +tc_hs_type mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys - ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) hs_tys arg_kinds ; let arg_reps = map kindRep arg_kinds arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind - -- The '[] case is handled in tc_infer_hs_type. - -- See Note [Future-proofing the type checker]. + -- See Note [Kind-checking explicit lists] + | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] @@ -1292,56 +1190,134 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar - ; taus <- zipWithM (tc_lhs_type mode) tys ks + ; taus <- zipWithM (tc_check_lhs_type mode) tys ks ; let kind_con = tupleTyCon Boxed arity ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) - ; ty' <- tc_lhs_type mode ty liftedTypeKind + ; ty' <- tc_check_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tc_hs_type mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek +--------- Type applications +tc_hs_type mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tc_hs_type mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind + +tc_hs_type mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tc_hs_type:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_check_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tc_hs_type _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tc_hs_type tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * + + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind {- +Note [Kind-checking explicit lists] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In a type, suppose we have an application (F [t1,t2]), +where [t1,t2] is an explicit list, and + F :: [ki] -> blah + +Then we want to return the type + F ((:) @ki t2 ((:) @ki t2 ([] @ki))) +where the argument list is instantiated to F's argument kind `ki`. + +But what about (G []), where + G :: (forall k. [k]) -> blah + +Here we want to return (G []), with no instantiation at all. But since we have +no lambda in types, we must be careful not to instantiate that `[]`, because we +can't re-generalise it. Hence, when kind-checking an explicit list, we need a +special case for `[]`. + Note [Variable Specificity and Forall Visibility] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A HsForAllTy contains an HsForAllTelescope to denote the visibility of the forall @@ -1366,28 +1342,28 @@ Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in "GHC.Core.TyCo ------------------------------------------ tc_mult :: TcTyMode -> HsArrow GhcRn -> TcM Mult -tc_mult mode ty = tc_lhs_type mode (arrowToHsType ty) multiplicityTy +tc_mult mode ty = tc_check_lhs_type mode (arrowToHsType ty) multiplicityTy ------------------------------------------ -tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> TcKind +tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> ExpKind -> TcM TcType tc_fun_type mode mult ty1 ty2 exp_kind = case mode_tyki mode of TypeLevel -> do { traceTc "tc_fun_type" (ppr ty1 $$ ppr ty2) ; arg_k <- newOpenTypeKind ; res_k <- newOpenTypeKind - ; ty1' <- tc_lhs_type mode ty1 arg_k - ; ty2' <- tc_lhs_type mode ty2 res_k + ; ty1' <- tc_check_lhs_type mode ty1 arg_k + ; ty2' <- tc_check_lhs_type mode ty2 res_k ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } KindLevel -> -- no representation polymorphism in kinds. yet. - do { ty1' <- tc_lhs_type mode ty1 liftedTypeKind - ; ty2' <- tc_lhs_type mode ty2 liftedTypeKind + do { ty1' <- tc_check_lhs_type mode ty1 liftedTypeKind + ; ty2' <- tc_check_lhs_type mode ty2 liftedTypeKind ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } {- Note [Skolem escape and forall-types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1442,7 +1418,7 @@ tc_tuple rn_ty mode tup_sort tys exp_kind BoxedTuple -> return (replicate arity liftedTypeKind) UnboxedTuple -> replicateM arity newOpenTypeKind ConstraintTuple -> return (replicate arity constraintKind) - ; tau_tys <- zipWithM (tc_lhs_type mode) tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) tys arg_kinds ; finish_tuple rn_ty tup_sort tau_tys arg_kinds exp_kind } where arity = length tys @@ -1530,9 +1506,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1523,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -1570,6 +1550,14 @@ tcInferTyAppHead _ (L _ (HsTyVar _ _ (L _ tv))) tcInferTyAppHead mode ty = tc_infer_lhs_type mode ty +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty + --------------------------- -- | Apply a type of a given kind to a list of arguments. This instantiates -- invisible parameters as necessary. Always consumes all the arguments, @@ -1656,7 +1644,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args ; arg_mode <- mkHoleMode KindLevel HM_VTA -- HM_VKA: see Note [Wildcards in visible kind application] ; ki_arg <- addErrCtxt (funAppCtxt orig_hs_ty hs_ki_arg n) $ - tc_lhs_type arg_mode hs_ki_arg exp_kind + tc_check_lhs_type arg_mode hs_ki_arg exp_kind ; traceTc "tcInferTyApps (vis kind app)" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder ki_arg @@ -1687,7 +1675,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args , ppr subst ]) ; let exp_kind = substTy subst $ piTyBinderType ki_binder ; arg' <- addErrCtxt (funAppCtxt orig_hs_ty arg n) $ - tc_lhs_type mode arg exp_kind + tc_check_lhs_type mode arg exp_kind ; traceTc "tcInferTyApps (vis normal app) 2" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder arg' ; go (n+1) fun' subst' inner_ki args } @@ -1975,6 +1963,19 @@ checkExpectedKind hs_ty ty act_kind exp_kind n_act_invis_bndrs = invisibleTyBndrCount act_kind n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + +-- tyr <- checkExpKind hs_ty ty (act_ki :: Kind) (exp_ki :: ExpKind) +-- requires that `ty` has kind `act_ki` +-- It checks that the actual kind `act_ki` matches the expected kind `exp_ki` +-- and returns `tyr`, a possibly-casted form of `ty`, that has precisely kind `exp_ki` +-- `hs_ty` is purely for error messages +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + --------------------------- tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] @@ -1988,7 +1989,7 @@ tc_hs_context :: TcTyMode -> LHsContext GhcRn -> TcM [PredType] tc_hs_context mode ctxt = mapM (tc_lhs_pred mode) (unLoc ctxt) tc_lhs_pred :: TcTyMode -> LHsType GhcRn -> TcM PredType -tc_lhs_pred mode pred = tc_lhs_type mode pred constraintKind +tc_lhs_pred mode pred = tc_check_lhs_type mode pred constraintKind --------------------------- tcTyVar :: Name -> TcM (TcType, TcKind) @@ -4045,7 +4046,7 @@ tcHsPartialSigType ctxt sig_ty ; tau <- -- Don't do (addTypeCtxt hs_tau) here else we get -- In the type -- In the type signature: foo :: - tc_lhs_type mode hs_tau ek + tc_check_lhs_type mode hs_tau ek ; return (wcs, wcx, theta, tau) } @@ -4355,8 +4356,8 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind - ; ty <- tc_lhs_type mode hs_ty ek + do { ek <- newExpectedKind ctxt_kind + ; ty <- tc_check_lhs_type mode hs_ty ek ; return (wcs, ty) } ; mapM_ emitNamedTypeHole wcs @@ -4532,7 +4533,7 @@ tc_lhs_kind_sig mode ctxt hs_kind -- Result is zonked = do { kind <- addErrCtxt (text "In the kind" <+> quotes (ppr hs_kind)) $ solveEqualities "tcLHsKindSig" $ - tc_lhs_type mode hs_kind liftedTypeKind + tc_check_lhs_type mode hs_kind liftedTypeKind ; traceTc "tcLHsKindSig" (ppr hs_kind $$ ppr kind) -- No generalization: ; kindGeneralizeNone kind ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Tc.Utils.TcType ( TcKind, TcCoVar, TcTyCoVar, TcTyVarBinder, TcInvisTVBinder, TcReqTVBinder, TcTyCon, MonoTcTyCon, PolyTcTyCon, TcTyConBinder, KnotTied, - ExpType(..), InferResult(..), + ExpType(..), ExpKind, InferResult(..), ExpTypeFRR, ExpSigmaType, ExpSigmaTypeFRR, ExpRhoType, mkCheckExpType, @@ -433,6 +433,9 @@ type ExpSigmaTypeFRR = ExpTypeFRR type ExpRhoType = ExpType +-- | Like 'ExpType', but on kind level +type ExpKind = ExpType + instance Outputable ExpType where ppr (Check ty) = text "Check" <> braces (ppr ty) ppr (Infer ir) = ppr ir ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,8 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + fillInferResult, ) where import GHC.Prelude ===================================== compiler/Language/Haskell/Syntax/Type.hs ===================================== @@ -1006,7 +1006,7 @@ would mean that when we pretty-print it back, we don't know whether the user wrote '*' or 'Type', and lose the parse/ppr roundtrip property. As a workaround, we parse '*' as HsStarTy (if it stands for 'Data.Kind.Type') -and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_hs_type). +and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_check_hs_type). When '*' is a regular type operator (StarIsType is disabled), HsStarTy is not involved. ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * ===================================== testsuite/tests/th/T24299.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24299 where +import Language.Haskell.TH.Syntax (addModFinalizer, runIO) +import GHC.Types (Type) +import System.IO + +type Proxy :: forall a. a -> Type +data Proxy a = MkProxy + +check :: ($(addModFinalizer (runIO (do putStrLn "check"; hFlush stdout)) >> + [t| Proxy |]) :: Type -> Type) Int -- There is kind signature, we are in check mode +check = MkProxy + +infer :: ($(addModFinalizer (runIO (do putStrLn "infer"; hFlush stdout)) >> + [t| Proxy |]) ) Int -- no kind signature, inference mode is enabled +infer = MkProxy ===================================== testsuite/tests/th/T24299.stderr ===================================== @@ -0,0 +1,2 @@ +check +infer ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24299', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28dedd4eb5b5ad5e0de0d0129b9230755c42ed9d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28dedd4eb5b5ad5e0de0d0129b9230755c42ed9d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 13:31:06 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 21 Mar 2024 09:31:06 -0400 Subject: [Git][ghc/ghc][wip/T24553] 4 commits: Expand untyped splices in tcPolyExprCheck Message-ID: <65fc369a15db9_1068ad57da78965e9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 4c4740b2 by Simon Peyton Jones at 2024-03-21T13:30:28+00:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 23 changed files: - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Types/Name/Occurrence.hs - + testsuite/tests/th/T24559.hs - testsuite/tests/th/all.T - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T - + testsuite/tests/vdq-rta/should_compile/T24570.hs - testsuite/tests/vdq-rta/should_compile/all.T - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -228,7 +228,7 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = andEq TEQX e = hasCast e andEq TEQ e = e - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare go (D _ (TyConApp tc1 [])) (D _ (TyConApp tc2 [])) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -12,8 +12,9 @@ module GHC.Core.TyCo.Compare ( nonDetCmpTypesX, nonDetCmpTc, eqVarBndrs, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTyConApps, + mayLookIdentical, -- * Visiblity comparision eqForAllVis, cmpForAllVis @@ -22,7 +23,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -129,52 +131,114 @@ Cabal. See #19226. -} +mayLookIdentical :: Type -> Type -> Bool +-- | Returns True if the /visible/ part of the types +-- might look equal, even if they are really unequal (in the invisible bits) +-- Always safe to return True -- this affects error messages only +mayLookIdentical orig_ty1 orig_ty2 + = go orig_env orig_ty1 orig_ty2 + where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + + go :: RnEnv2 -> Type -> Type -> Bool + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True + + go env t1 t2 | Just t1' <- coreView t1 = go env t1' t2 + go env t1 t2 | Just t2' <- coreView t2 = go env t1 t2' + + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True + + go env (ForAllTy (Bndr tv1 vis1) ty1) + (ForAllTy (Bndr tv2 vis2) ty2) + = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] + && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- Visible stuff only: ignore kinds of binders + + -- If we have (forall (r::RunTimeRep). ty1 ~ blah) then respond + -- with True. Reason: the type pretty-printer defaults RuntimeRep + -- foralls (see Ghc.Iface.Type.hideNonStandardTypes). That can make, + -- say (forall r. TYPE r -> Type) into (Type -> Type), so it looks the + -- same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of mayLookIdentical) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | isDefaultableBndr b = True + go _ _ (ForAllTy b _) | isDefaultableBndr b = True + + go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) + = go env arg1 arg2 && go env res1 res2 && go env w1 w2 + -- Visible stuff only: ignore agg kinds + + -- See Note [Equality on AppTys] in GHC.Core.Type + go env (AppTy s1 t1) ty2 + | Just (s2, t2) <- tcSplitAppTyNoView_maybe ty2 + = go env s1 s2 && go env t1 t2 + go env ty1 (AppTy s2 t2) + | Just (s1, t1) <- tcSplitAppTyNoView_maybe ty1 + = go env s1 s2 && go env t1 t2 + + go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) + = tc1 == tc2 && gos env (tyConBinders tc1) ts1 ts2 + + go _ _ _ = False + + gos :: RnEnv2 -> [TyConBinder] -> [Type] -> [Type] -> Bool + gos _ _ [] [] = True + gos env bs (t1:ts1) (t2:ts2) + | (invisible, bs') <- case bs of + [] -> (True,[]) + (b:bs) -> (isInvisibleTyConBinder b, bs) + = (invisible || go env t1 t2) && gos env bs' ts1 ts2 + + gos _ _ _ _ = False + + -- | Type equality comparing both visible and invisible arguments and expanding -- type synonyms. tcEqTypeNoSyns :: Type -> Type -> Bool -tcEqTypeNoSyns ta tb = tc_eq_type False False ta tb - --- | Like 'tcEqType', but returns True if the /visible/ part of the types --- are equal, even if they are really unequal (in the invisible bits) -tcEqTypeVis :: Type -> Type -> Bool -tcEqTypeVis ty1 ty2 = tc_eq_type False True ty1 ty2 +tcEqTypeNoSyns ta tb = tc_eq_type False ta tb -- | Like 'pickyEqTypeVis', but returns a Bool for convenience pickyEqType :: Type -> Type -> Bool -- Check when two types _look_ the same, _including_ synonyms. -- So (pickyEqType String [Char]) returns False -- This ignores kinds and coercions, because this is used only for printing. -pickyEqType ty1 ty2 = tc_eq_type True False ty1 ty2 +pickyEqType ty1 ty2 = tc_eq_type True ty1 ty2 -- | Real worker for 'tcEqType'. No kind check! tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms - -> Bool -- ^ True <=> compare visible args only -> Type -> Type -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type -tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +tc_eq_type keep_syns orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + go :: RnEnv2 -> Type -> Type -> Bool - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. - go _ (TyConApp tc1 []) (TyConApp tc2 []) - | tc1 == tc2 - = True + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True go env t1 t2 | not keep_syns, Just t1' <- coreView t1 = go env t1' t2 go env t1 t2 | not keep_syns, Just t2' <- coreView t2 = go env t1 t2' - go env (TyVarTy tv1) (TyVarTy tv2) - = rnOccL env tv1 == rnOccR env tv2 - - go _ (LitTy lit1) (LitTy lit2) - = lit1 == lit2 + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] - && (vis_only || go env (varType tv1) (varType tv2)) + && go env (varType tv1) (varType tv2) && go (rnBndr2 env tv1 tv2) ty1 ty2 -- Make sure we handle all FunTy cases since falling through to the @@ -183,11 +247,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- See Note [Equality on FunTys] in GHC.Core.TyCo.Rep: we must check -- kinds here go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) - = kinds_eq && go env arg1 arg2 && go env res1 res2 && go env w1 w2 - where - kinds_eq | vis_only = True - | otherwise = go env (typeKind arg1) (typeKind arg2) && - go env (typeKind res1) (typeKind res2) + = go env (typeKind arg1) (typeKind arg2) && + go env (typeKind res1) (typeKind res2) && + go env arg1 arg2 && go env res1 res2 && go env w1 w2 -- See Note [Equality on AppTys] in GHC.Core.Type go env (AppTy s1 t1) ty2 @@ -198,32 +260,24 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go env s1 s2 && go env t1 t2 go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) - = tc1 == tc2 && gos env (tc_vis tc1) ts1 ts2 - - go env (CastTy t1 _) t2 = go env t1 t2 - go env t1 (CastTy t2 _) = go env t1 t2 - go _ (CoercionTy {}) (CoercionTy {}) = True + = tc1 == tc2 && gos env ts1 ts2 go _ _ _ = False - gos _ _ [] [] = True - gos env (ig:igs) (t1:ts1) (t2:ts2) = (ig || go env t1 t2) - && gos env igs ts1 ts2 - gos _ _ _ _ = False + gos _ [] [] = True + gos env (t1:ts1) (t2:ts2) = go env t1 t2 && gos env ts1 ts2 + gos _ _ _ = False - tc_vis :: TyCon -> [Bool] -- True for the fields we should ignore - tc_vis tc | vis_only = inviss ++ repeat False -- Ignore invisibles - | otherwise = repeat False -- Ignore nothing - -- The repeat False is necessary because tycons - -- can legitimately be oversaturated - where - bndrs = tyConBinders tc - inviss = map isInvisibleTyConBinder bndrs - - orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] - -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function @@ -543,7 +597,7 @@ nonDetCmpTypeX env orig_t1 orig_t2 = -- Returns both the resulting ordering relation between -- the two types and whether either contains a cast. go :: RnEnv2 -> Type -> Type -> TypeOrdering - -- See Note [Comparing nullary type synonyms]. + -- See Note [Comparing nullary type synonyms] go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1066,7 +1066,7 @@ unify_ty :: UMEnv -- Respects newtypes, PredTypes -- See Note [Computing equality on types] in GHC.Core.Type unify_ty _env (TyConApp tc1 []) (TyConApp tc2 []) _kco - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare | tc1 == tc2 = return () ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,60 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = mayLookIdentical act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = mayLookIdentical ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when we find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by + `GHC.Core.TyCo.Compare.mayLookIdentical` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6089,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6172,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6434,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6458,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -30,7 +30,7 @@ import GHC.Prelude import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import {-# SOURCE #-} GHC.Tc.Gen.Splice - ( tcTypedSplice, tcTypedBracket, tcUntypedBracket ) + ( tcTypedSplice, tcTypedBracket, tcUntypedBracket, getUntypedSpliceBody ) import GHC.Hs import GHC.Hs.Syn.Type @@ -169,6 +169,12 @@ tcPolyExprCheck expr res_ty do { e' <- tc_body e ; return (HsPar x (L loc e')) } + -- Look through any untyped splices (#24559) + -- c.f. Note [Looking through Template Haskell splices in splitHsApps] + tc_body (HsUntypedSplice splice_res _) + = do { body <- getUntypedSpliceBody splice_res + ; tc_body body } + -- The special case for lambda: go to tcLambdaMatches, passing pat_tys tc_body e@(HsLam x lam_variant matches) = do { (wrap, matches') <- tcLambdaMatches e lam_variant matches pat_tys @@ -673,11 +679,8 @@ tcExpr (HsUntypedSplice splice _) res_ty -- for `HsUntypedSplice`; to see why, read Wrinkle (UTS1) in -- Note [Looking through Template Haskell splices in splitHsApps] in -- GHC.Tc.Gen.Head. - = case splice of - HsUntypedSpliceTop mod_finalizers expr - -> do { addModFinalizersWithLclEnv mod_finalizers - ; tcExpr expr res_ty } - HsUntypedSpliceNested {} -> panic "tcExpr: invalid nested splice" + = do { expr <- getUntypedSpliceBody splice + ; tcExpr expr res_ty } {- ************************************************************************ ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -30,6 +30,7 @@ module GHC.Tc.Gen.Head , addHeadCtxt, addExprCtxt, addStmtCtxt, addFunResCtxt ) where import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcExpr, tcCheckPolyExprNC, tcPolyLExprSig ) +import {-# SOURCE #-} GHC.Tc.Gen.Splice( getUntypedSpliceBody ) import GHC.Prelude import GHC.Hs @@ -310,15 +311,11 @@ splitHsApps e = go e (top_ctxt 0 e) [] -- See Note [Looking through Template Haskell splices in splitHsApps] go e@(HsUntypedSplice splice_res splice) ctxt args - = case splice_res of - HsUntypedSpliceTop mod_finalizers fun - -> do addModFinalizersWithLclEnv mod_finalizers - go fun ctxt' (EWrap (EExpand (OrigExpr e)) : args) - HsUntypedSpliceNested {} -> panic "splitHsApps: invalid nested splice" + = do { fun <- getUntypedSpliceBody splice_res + ; go fun ctxt' (EWrap (EExpand (OrigExpr e)) : args) } where ctxt' :: AppCtxt - ctxt' = - case splice of + ctxt' = case splice of HsUntypedSpliceExpr _ (L l _) -> set l ctxt -- l :: SrcAnn AnnListItem HsQuasiQuote _ _ (L l _) -> set l ctxt -- l :: SrcAnn NoEpAnns @@ -840,7 +837,7 @@ handling splices and quasiquotes has already been performed by the renamer by the time we get to `splitHsApps`. Wrinkle (UTS1): - `tcExpr` has a separate case for `HsUntypedSplice`s that do not occur at the + `tcExpr` has a separate case for `HsUntypedSplice`s that do /not/ occur at the head of an application. This is important to handle programs like this one: foo :: (forall a. a -> a) -> b -> b ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -21,7 +21,7 @@ -- | Template Haskell splices module GHC.Tc.Gen.Splice( tcTypedSplice, tcTypedBracket, tcUntypedBracket, - runAnnotation, + runAnnotation, getUntypedSpliceBody, runMetaE, runMetaP, runMetaT, runMetaD, runQuasi, tcTopSpliceExpr, lookupThName_maybe, @@ -639,13 +639,16 @@ Example: ************************************************************************ -} +-- None of these functions add constraints to the LIE + tcTypedBracket :: HsExpr GhcRn -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcUntypedBracket :: HsExpr GhcRn -> HsQuote GhcRn -> [PendingRnSplice] -> ExpRhoType -> TcM (HsExpr GhcTc) -tcTypedSplice :: Name -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) - -- None of these functions add constraints to the LIE +tcTypedSplice :: Name -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) + +getUntypedSpliceBody :: HsUntypedSpliceResult (HsExpr GhcRn) -> TcM (HsExpr GhcRn) +runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation -runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation {- ************************************************************************ * * @@ -815,6 +818,16 @@ quotationCtxtDoc br_body ************************************************************************ -} +-- getUntypedSpliceBody: the renamer has expanded the splice. +-- Just run the finalizers that it produced, and return +-- the renamed expression +getUntypedSpliceBody (HsUntypedSpliceTop { utsplice_result_finalizers = mod_finalizers + , utsplice_result = rn_expr }) + = do { addModFinalizersWithLclEnv mod_finalizers + ; return rn_expr } +getUntypedSpliceBody (HsUntypedSpliceNested {}) + = panic "tcTopUntypedSplice: invalid nested splice" + tcTypedSplice splice_name expr res_ty = addErrCtxt (typedSpliceCtxtDoc splice_name expr) $ setSrcSpan (getLocA expr) $ do ===================================== compiler/GHC/Tc/Gen/Splice.hs-boot ===================================== @@ -10,7 +10,7 @@ import GHC.Tc.Utils.TcType ( ExpRhoType ) import GHC.Types.Annotations ( Annotation, CoreAnnTarget ) import GHC.Hs.Extension ( GhcRn, GhcPs, GhcTc ) -import GHC.Hs ( HsQuote, HsExpr, LHsExpr, LHsType, LPat, LHsDecl, ThModFinalizers ) +import GHC.Hs ( HsQuote, HsExpr, LHsExpr, LHsType, LPat, LHsDecl, ThModFinalizers, HsUntypedSpliceResult ) import qualified Language.Haskell.TH as TH tcTypedSplice :: Name @@ -30,7 +30,8 @@ tcUntypedBracket :: HsExpr GhcRn runTopSplice :: DelayedSplice -> TcM (HsExpr GhcTc) -runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation +runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation +getUntypedSpliceBody :: HsUntypedSpliceResult (HsExpr GhcRn) -> TcM (HsExpr GhcRn) tcTopSpliceExpr :: SpliceType -> TcM (LHsExpr GhcTc) -> TcM (LHsExpr GhcTc) ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -311,7 +311,7 @@ can_eq_nc -> Type -> Type -- RHS, after and before type-synonym expansion, resp -> TcS (StopOrContinue (Either IrredCt EqCt)) --- See Note [Comparing nullary type synonyms] in GHC.Core.Type. +-- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare can_eq_nc _flat _rdr_env _envs ev eq_rel ty1@(TyConApp tc1 []) _ps_ty1 (TyConApp tc2 []) _ps_ty2 | tc1 == tc2 = canEqReflexive ev eq_rel ty1 ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -95,7 +95,7 @@ module GHC.Tc.Utils.TcType ( -- Re-exported from GHC.Core.TyCo.Compare -- mainly just for back-compat reasons eqType, eqTypes, nonDetCmpType, nonDetCmpTypes, eqTypeX, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, mayLookIdentical, tcEqTyConApps, eqForAllVis, eqVarBndrs, --------------------------------- @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -516,7 +516,9 @@ demoteOccTvName (OccName space name) = do -- See Note [Promotion] in GHC.Rename.Env. promoteOccName :: OccName -> Maybe OccName promoteOccName (OccName space name) = do - space' <- promoteNameSpace space + promoted_space <- promoteNameSpace space + let tyop = isTvNameSpace promoted_space && isLexVarSym name + space' = if tyop then tcClsName else promoted_space -- special case for type operators (#24570) return $ OccName space' name {- | Other names in the compiler add additional information to an OccName. ===================================== testsuite/tests/th/T24559.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeAbstractions #-} +module Foo where + +import Data.Kind +import Data.Proxy + +f :: (forall (a :: Type). Proxy a) -> Proxy Bool +f k = k @Bool + +g1 :: Proxy Bool +g1 = f (\ @a -> Proxy @a) + +g2 :: Proxy Bool +g2 = f $([| \ @a -> Proxy @a |]) ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24559', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + ===================================== testsuite/tests/vdq-rta/should_compile/T24570.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE GHC2024 #-} +{-# LANGUAGE RequiredTypeArguments #-} + +module T24570 where + +import Language.Haskell.TH + +idee :: forall a -> a -> a +idee _ x = x + +type (:!@#) = Bool + +f :: Bool -> Bool +f = idee (:!@#) + +type (!@#) = Bool + +g :: Bool -> Bool +g = idee (!@#) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -22,6 +22,7 @@ test('T23739_sizeOf', normal, compile, ['']) test('T23739_symbolVal', normal, compile, ['']) test('T23739_typeRep', normal, compile, ['']) test('T23739_nested', normal, compile, ['']) +test('T24570', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T23739_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -740,15 +740,12 @@ markExternalSourceText l (SourceText txt) _ = printStringAtRs (realSrcSpan l) (u -- --------------------------------------------------------------------- -markLensMAA :: (Monad m, Monoid w) => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) -markLensMAA (EpAnn anc a cs) l = - case view l a of - Nothing -> return (EpAnn anc a cs) - Just aa -> do - aa' <- markAddEpAnn aa - return (EpAnn anc (set l (Just aa') a) cs) +markLensMAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a) +markLensMAA epann l = markLensMAA' epann (lepa . l) -markLensMAA' :: (Monad m, Monoid w) => a -> Lens a (Maybe AddEpAnn) -> EP w m a +markLensMAA' :: (Monad m, Monoid w) + => a -> Lens a (Maybe AddEpAnn) -> EP w m a markLensMAA' a l = case view l a of Nothing -> return a @@ -756,34 +753,27 @@ markLensMAA' a l = aa' <- markAddEpAnn aa return (set l (Just aa') a) -markLensAA :: (Monad m, Monoid w) => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensAA (EpAnn anc a cs) l = do - a' <- markKw (view l a) - return (EpAnn anc (set l a' a) cs) +-- ------------------------------------- + +markLensAA :: (Monad m, Monoid w) + => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) +markLensAA epann l = markLensAA' epann (lepa . l) -markLensAA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a +markLensAA' :: (Monad m, Monoid w) + => a -> Lens a AddEpAnn -> EP w m a markLensAA' a l = do a' <- markKw (view l a) return (set l a' a) +-- ------------------------------------- markEpAnnLMS :: (Monad m, Monoid w) => EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS an l kw Nothing = markEpAnnL an l kw -markEpAnnLMS (EpAnn anc a cs) l kw (Just str) = do - anns <- mapM go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) +markEpAnnLMS epann l kw ms = markEpAnnLMS'' epann (lepa . l) kw ms markEpAnnLMS'' :: (Monad m, Monoid w) => a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS'' an l kw Nothing = markEpAnnL' an l kw +markEpAnnLMS'' an l kw Nothing = markEpAnnL an l kw markEpAnnLMS'' a l kw (Just str) = do anns <- mapM go (view l a) return (set l anns a) @@ -795,10 +785,11 @@ markEpAnnLMS'' a l kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- markEpAnnMS' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m [AddEpAnn] -markEpAnnMS' anns kw Nothing = mark' anns kw +markEpAnnMS' anns kw Nothing = mark anns kw markEpAnnMS' anns kw (Just str) = do mapM go anns where @@ -809,23 +800,15 @@ markEpAnnMS' anns kw (Just str) = do return (AddEpAnn kw' r') | otherwise = return (AddEpAnn kw' r) +-- ------------------------------------- + markEpAnnLMS' :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) -markEpAnnLMS' an l _kw Nothing = markLensKwA an l -markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do - anns <- go (view l a) - return (EpAnn anc (set l anns a) cs) - where - go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn - go (AddEpAnn kw' r) - | kw' == kw = do - r' <- printStringAtAA r str - return (AddEpAnn kw' r') - | otherwise = return (AddEpAnn kw' r) + => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a) +markEpAnnLMS' an l kw ms = markEpAnnLMS0 an (lepa . l) kw ms markEpAnnLMS0 :: (Monad m, Monoid w) - => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a -markEpAnnLMS0 an l _kw Nothing = markLensKwA' an l + => a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m a +markEpAnnLMS0 an l _kw Nothing = markLensKwA an l markEpAnnLMS0 a l kw (Just str) = do anns <- go (view l a) return (set l anns a) @@ -890,7 +873,8 @@ markAnnOpenP' :: (Monad m, Monoid w) => AnnPragma -> SourceText -> String -> EP markAnnOpenP' an NoSourceText txt = markEpAnnLMS0 an lapr_open AnnOpen (Just txt) markAnnOpenP' an (SourceText txt) _ = markEpAnnLMS0 an lapr_open AnnOpen (Just $ unpackFS txt) -markAnnOpen :: (Monad m, Monoid w) => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] +markAnnOpen :: (Monad m, Monoid w) + => [AddEpAnn] -> SourceText -> String -> EP w m [AddEpAnn] markAnnOpen an NoSourceText txt = markEpAnnLMS'' an lidl AnnOpen (Just txt) markAnnOpen an (SourceText txt) _ = markEpAnnLMS'' an lidl AnnOpen (Just $ unpackFS txt) @@ -960,6 +944,16 @@ You can think of the function composition operator as having this type: -- --------------------------------------------------------------------- -- Lenses +-- data EpAnn ann +-- = EpAnn { entry :: !Anchor +-- , anns :: !ann +-- , comments :: !EpAnnComments +-- } + +lepa :: Lens (EpAnn a) a +lepa k epAnn = fmap (\newAnns -> epAnn { anns = newAnns }) + (k (anns epAnn)) + -- data AnnsModule -- = AnnsModule { -- am_main :: [AddEpAnn], @@ -1289,26 +1283,20 @@ lsumPatVbarsAfter k parent = fmap (\new -> parent { sumPatVbarsAfter = new }) -- --------------------------------------------------------------------- markLensKwA :: (Monad m, Monoid w) - => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a) -markLensKwA (EpAnn anc a cs) l = do - loc <- markKw (view l a) - return (EpAnn anc (set l loc a) cs) - -markLensKwA' :: (Monad m, Monoid w) => a -> Lens a AddEpAnn -> EP w m a -markLensKwA' a l = do +markLensKwA a l = do loc <- markKw (view l a) return (set l loc a) -markLensKw :: (Monad m, Monoid w) +markLensKw' :: (Monad m, Monoid w) => EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a) -markLensKw (EpAnn anc a cs) l kw = do +markLensKw' (EpAnn anc a cs) l kw = do loc <- markKwA kw (view l a) return (EpAnn anc (set l loc a) cs) -markLensKw' :: (Monad m, Monoid w) +markLensKw :: (Monad m, Monoid w) => a -> Lens a EpaLocation -> AnnKeywordId -> EP w m a -markLensKw' a l kw = do +markLensKw a l kw = do loc <- markKwA kw (view l a) return (set l loc a) @@ -1338,18 +1326,18 @@ markLensKwM' a l kw = do -- --------------------------------------------------------------------- -markEpAnnL :: (Monad m, Monoid w) +markEpAnnL' :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) -markEpAnnL (EpAnn anc a cs) l kw = do - anns <- mark' (view l a) kw - return (EpAnn anc (set l anns a) cs) +markEpAnnL' epann l kw = markEpAnnL epann (lepa . l) kw -markEpAnnL' :: (Monad m, Monoid w) +markEpAnnL :: (Monad m, Monoid w) => ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m ann -markEpAnnL' a l kw = do - anns <- mark' (view l a) kw +markEpAnnL a l kw = do + anns <- mark (view l a) kw return (set l anns a) +-- ------------------------------------- + markEpAnnAllL :: (Monad m, Monoid w) => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann) markEpAnnAllL (EpAnn anc a cs) l kw = do @@ -1374,13 +1362,13 @@ markEpAnnAllL' a l kw = do markAddEpAnn :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn markAddEpAnn a@(AddEpAnn kw _) = do - r <- mark' [a] kw + r <- mark [a] kw case r of [a'] -> return a' _ -> error "Should not happen: markAddEpAnn" -mark' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] -mark' anns kw = do +mark :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn] +mark anns kw = do case find' kw anns of (lead, Just aa, end) -> do aa' <- markKw aa @@ -1637,14 +1625,14 @@ instance ExactPrint (HsModule GhcPs) where case mmn of Nothing -> return (an, mmn, mdeprec, mexports) Just m -> do - an0 <- markEpAnnL an lam_main AnnModule + an0 <- markEpAnnL' an lam_main AnnModule m' <- markAnnotated m mdeprec' <- setLayoutTopLevelP $ markAnnotated mdeprec mexports' <- setLayoutTopLevelP $ markAnnotated mexports - an1 <- setLayoutTopLevelP $ markEpAnnL an0 lam_main AnnWhere + an1 <- setLayoutTopLevelP $ markEpAnnL' an0 lam_main AnnWhere return (an1, Just m', mdeprec', mexports') @@ -1708,17 +1696,17 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where exact (L an (WarningTxt mb_cat src ws)) = do an0 <- markAnnOpenP an src "{-# WARNING" mb_cat' <- markAnnotated mb_cat - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (WarningTxt mb_cat' src ws')) exact (L an (DeprecatedTxt src ws)) = do an0 <- markAnnOpenP an src "{-# DEPRECATED" - an1 <- markEpAnnL an0 lapr_rest AnnOpenS + an1 <- markEpAnnL' an0 lapr_rest AnnOpenS ws' <- markAnnotated ws - an2 <- markEpAnnL an1 lapr_rest AnnCloseS + an2 <- markEpAnnL' an1 lapr_rest AnnCloseS an3 <- markAnnCloseP an2 return (L an3 (DeprecatedTxt src ws')) @@ -1751,7 +1739,7 @@ instance ExactPrint (ImportDecl GhcPs) where exact (ImportDecl (XImportDeclPass ann msrc impl) modname mpkg src safeflag qualFlag mAs hiding) = do - ann0 <- markLensKw ann limportDeclAnnImport AnnImport + ann0 <- markLensKw' ann limportDeclAnnImport AnnImport let (EpAnn _anc an _cs) = ann0 -- "{-# SOURCE" and "#-}" @@ -1955,7 +1943,7 @@ exactDataFamInstDecl an top_lvl , Maybe (LHsContext GhcPs)) pp_hdr mctxt = do an0 <- case top_lvl of - TopLevel -> markEpAnnL' an lidl AnnInstance -- TODO: maybe in toplevel + TopLevel -> markEpAnnL an lidl AnnInstance -- TODO: maybe in toplevel NotTopLevel -> return an exactHsFamInstLHS an0 tycon bndrs pats fixity mctxt @@ -1978,9 +1966,9 @@ instance ExactPrint (DerivDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DerivDecl (mw, an) typ ms mov) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving ms' <- mapM markAnnotated ms - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance mw' <- mapM markAnnotated mw mov' <- mapM markAnnotated mov typ' <- markAnnotated typ @@ -1993,22 +1981,22 @@ instance ExactPrint (ForeignDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (ForeignImport an n ty fimport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnImport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnImport fimport' <- markAnnotated fimport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignImport an2 n' ty' fimport') exact (ForeignExport an n ty fexport) = do - an0 <- markEpAnnL' an lidl AnnForeign - an1 <- markEpAnnL' an0 lidl AnnExport + an0 <- markEpAnnL an lidl AnnForeign + an1 <- markEpAnnL an0 lidl AnnExport fexport' <- markAnnotated fexport n' <- markAnnotated n - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon ty' <- markAnnotated ty return (ForeignExport an2 n' ty' fexport') @@ -2080,18 +2068,18 @@ instance ExactPrint (WarnDecl GhcPs) where mb_cat' <- markAnnotated mb_cat ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (WarningTxt mb_cat' src ls')) -- return (Warning an1 lns' (WarningTxt mb_cat' src ls')) exact (Warning (ns_spec, an) lns (DeprecatedTxt src ls)) = do ns_spec' <- exactNsSpec ns_spec lns' <- markAnnotated lns - an0 <- markEpAnnL' an lidl AnnOpenS -- "[" + an0 <- markEpAnnL an lidl AnnOpenS -- "[" ls' <- markAnnotated ls - an1 <- markEpAnnL' an0 lidl AnnCloseS -- "]" + an1 <- markEpAnnL an0 lidl AnnCloseS -- "]" return (Warning (ns_spec', an1) lns' (DeprecatedTxt src ls')) -- return (Warning an1 lns' (DeprecatedTxt src ls')) @@ -2162,7 +2150,7 @@ instance ExactPrint (RuleDecl GhcPs) where an3 <- markLensMAA' an2 lra_tmanns_snd -- AnnDot lhs' <- markAnnotated lhs - an4 <- markEpAnnL' an3 lra_rest AnnEqual + an4 <- markEpAnnL an3 lra_rest AnnEqual rhs' <- markAnnotated rhs return (HsRule (an4,nsrc) (L ln' n) act mtybndrs' termbndrs' lhs' rhs') @@ -2171,20 +2159,20 @@ markActivation :: (Monad m, Monoid w) markActivation an l act = do case act of ActiveBefore src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ an2 <- markEpAnnLMS'' an1 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an3 <- markEpAnnL' an2 l AnnCloseS -- ']' + an3 <- markEpAnnL an2 l AnnCloseS -- ']' return an3 ActiveAfter src phase -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' + an0 <- markEpAnnL an l AnnOpenS -- '[' an1 <- markEpAnnLMS'' an0 l AnnVal (Just (toSourceTextWithSuffix src (show phase) "")) - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 NeverActive -> do - an0 <- markEpAnnL' an l AnnOpenS -- '[' - an1 <- markEpAnnL' an0 l AnnTilde -- ~ - an2 <- markEpAnnL' an1 l AnnCloseS -- ']' + an0 <- markEpAnnL an l AnnOpenS -- '[' + an1 <- markEpAnnL an0 l AnnTilde -- ~ + an2 <- markEpAnnL an1 l AnnCloseS -- ']' return an2 _ -> return an @@ -2214,8 +2202,8 @@ instance ExactPrint (RoleAnnotDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (RoleAnnotDecl an ltycon roles) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnRole + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnRole ltycon' <- markAnnotated ltycon let markRole (L l (Just r)) = do (L _ r') <- markAnnotated (L l r) @@ -2243,11 +2231,11 @@ instance ExactPrint (RuleBndr GhcPs) where ln' <- markAnnotated ln return (RuleBndr x ln') exact (RuleBndrSig an ln (HsPS x ty)) = do - an0 <- markEpAnnL' an lidl AnnOpenP -- "(" + an0 <- markEpAnnL an lidl AnnOpenP -- "(" ln' <- markAnnotated ln - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty - an2 <- markEpAnnL' an1 lidl AnnCloseP -- ")" + an2 <- markEpAnnL an1 lidl AnnCloseP -- ")" return (RuleBndrSig an2 ln' (HsPS x ty')) -- --------------------------------------------------------------------- @@ -2262,7 +2250,7 @@ instance (ExactPrint body) => ExactPrint (FamEqn GhcPs body) where , feqn_fixity = fixity , feqn_rhs = rhs }) = do (an0, tycon', bndrs', pats', _) <- exactHsFamInstLHS an tycon bndrs pats fixity Nothing - an1 <- markEpAnnL' an0 lidl AnnEqual + an1 <- markEpAnnL an0 lidl AnnEqual rhs' <- markAnnotated rhs return (FamEqn { feqn_ext = an1 , feqn_tycon = tycon' @@ -2286,9 +2274,9 @@ exactHsFamInstLHS :: , HsOuterTyVarBndrs () GhcPs , HsFamEqnPats GhcPs, Maybe (LHsContext GhcPs)) exactHsFamInstLHS an thing bndrs typats fixity mb_ctxt = do - an0 <- markEpAnnL' an lidl AnnForall + an0 <- markEpAnnL an lidl AnnForall bndrs' <- markAnnotated bndrs - an1 <- markEpAnnL' an0 lidl AnnDot + an1 <- markEpAnnL an0 lidl AnnDot mb_ctxt' <- mapM markAnnotated mb_ctxt (an2, thing', typats') <- exact_pats an1 typats return (an2, thing', bndrs', typats', mb_ctxt') @@ -2342,7 +2330,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where , cid_datafam_insts = adts }) = do (mbWarn', an0, mbOverlap', inst_ty') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lid AnnSemi ds <- withSortKey sortKey [(ClsAtdTag, prepareListAnnotationA ats), @@ -2350,7 +2338,7 @@ instance ExactPrint (ClsInstDecl GhcPs) where (ClsMethodTag, prepareListAnnotationA (bagToList binds)), (ClsSigTag, prepareListAnnotationA sigs) ] - an3 <- markEpAnnL' an2 lidl AnnCloseC -- '}' + an3 <- markEpAnnL an2 lidl AnnCloseC -- '}' let ats' = undynamic ds adts' = undynamic ds @@ -2364,11 +2352,11 @@ instance ExactPrint (ClsInstDecl GhcPs) where where top_matter = do - an0 <- markEpAnnL' an lidl AnnInstance + an0 <- markEpAnnL an lidl AnnInstance mw <- mapM markAnnotated mbWarn mo <- mapM markAnnotated mbOverlap it <- markAnnotated inst_ty - an1 <- markEpAnnL' an0 lidl AnnWhere -- Optional + an1 <- markEpAnnL an0 lidl AnnWhere -- Optional return (mw, an1, mo,it) -- --------------------------------------------------------------------- @@ -2378,8 +2366,8 @@ instance ExactPrint (TyFamInstDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact d@(TyFamInstDecl { tfid_xtn = an, tfid_eqn = eqn }) = do - an0 <- markEpAnnL' an lidl AnnType - an1 <- markEpAnnL' an0 lidl AnnInstance + an0 <- markEpAnnL an lidl AnnType + an1 <- markEpAnnL an0 lidl AnnInstance eqn' <- markAnnotated eqn return (d { tfid_xtn = an1, tfid_eqn = eqn' }) @@ -2456,7 +2444,7 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where , psb_id = psyn, psb_args = details , psb_def = pat , psb_dir = dir }) = do - an0 <- markEpAnnL' an lidl AnnPattern + an0 <- markEpAnnL an lidl AnnPattern (an1, psyn', details') <- case details of InfixCon v1 v2 -> do @@ -2471,25 +2459,25 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where return (an0, psyn', PrefixCon tvs' vs') RecCon vs -> do psyn' <- markAnnotated psyn - an1 <- markEpAnnL' an0 lidl AnnOpenC -- '{' + an1 <- markEpAnnL an0 lidl AnnOpenC -- '{' vs' <- markAnnotated vs - an2 <- markEpAnnL' an1 lidl AnnCloseC -- '}' + an2 <- markEpAnnL an1 lidl AnnCloseC -- '}' return (an2, psyn', RecCon vs') (an2, pat', dir') <- case dir of Unidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat return (an2, pat', dir) ImplicitBidirectional -> do - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual pat' <- markAnnotated pat return (an2, pat', dir) ExplicitBidirectional mg -> do - an2 <- markEpAnnL' an1 lidl AnnLarrow + an2 <- markEpAnnL an1 lidl AnnLarrow pat' <- markAnnotated pat - an3 <- markEpAnnL' an2 lidl AnnWhere + an3 <- markEpAnnL an2 lidl AnnWhere mg' <- markAnnotated mg return (an3, pat', ExplicitBidirectional mg') @@ -2539,7 +2527,7 @@ exactMatch (Match an mctxt pats grhss) = do debugM $ "exact Match FunRhs:" ++ showPprUnsafe fun an0' <- case strictness of - SrcStrict -> markEpAnnL' an lidl AnnBang + SrcStrict -> markEpAnnL an lidl AnnBang _ -> pure an case fixity of Prefix -> do @@ -2556,18 +2544,18 @@ exactMatch (Match an mctxt pats grhss) = do p2' <- markAnnotated p2 return (an0', FunRhs fun' fixity strictness, [p1',p2']) | otherwise -> do - an0 <- markEpAnnL' an0' lidl AnnOpenP + an0 <- markEpAnnL an0' lidl AnnOpenP p1' <- markAnnotated p1 fun' <- markAnnotated fun p2' <- markAnnotated p2 - an1 <- markEpAnnL' an0 lidl AnnCloseP + an1 <- markEpAnnL an0 lidl AnnCloseP rest' <- mapM markAnnotated rest return (an1, FunRhs fun' fixity strictness, p1':p2':rest') _ -> panic "FunRhs" -- ToDo: why is LamSingle treated differently? LamAlt LamSingle -> do - an0' <- markEpAnnL' an lidl AnnLam + an0' <- markEpAnnL an lidl AnnLam pats' <- markAnnotated pats return (an0', LamAlt LamSingle, pats') LamAlt v -> do @@ -2624,7 +2612,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where exact (HsValBinds an valbinds) = do debugM $ "exact HsValBinds: an=" ++ showAst an - an0 <- markEpAnnL an lal_rest AnnWhere + an0 <- markEpAnnL' an lal_rest AnnWhere case al_anchor $ anns an of Just anc -> do @@ -2636,7 +2624,7 @@ instance ExactPrint (HsLocalBinds GhcPs) where return (HsValBinds an1 valbinds') exact (HsIPBinds an bs) = do - (as, ipb) <- markAnnList an (markEpAnnL an lal_rest AnnWhere + (as, ipb) <- markAnnList an (markEpAnnL' an lal_rest AnnWhere >> markAnnotated bs >>= \bs' -> return (HsIPBinds an bs'::HsLocalBinds GhcPs)) case ipb of @@ -2677,7 +2665,7 @@ instance ExactPrint (IPBind GhcPs) where exact (IPBind an lr rhs) = do lr' <- markAnnotated lr - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual rhs' <- markAnnotated rhs return (IPBind an0 lr' rhs') @@ -2731,7 +2719,7 @@ instance ExactPrint (Sig GhcPs) where return (TypeSig an' vars' ty') exact (PatSynSig an lns typ) = do - an0 <- markEpAnnL' an lasRest AnnPattern + an0 <- markEpAnnL an lasRest AnnPattern lns' <- markAnnotated lns an1 <- markLensAA' an0 lasDcolon typ' <- markAnnotated typ @@ -2739,7 +2727,7 @@ instance ExactPrint (Sig GhcPs) where exact (ClassOpSig an is_deflt vars ty) | is_deflt = do - an0 <- markEpAnnL' an lasRest AnnDefault + an0 <- markEpAnnL an lasRest AnnDefault (an1, vars',ty') <- exactVarSig an0 vars ty return (ClassOpSig an1 is_deflt vars' ty') | otherwise = do @@ -2767,14 +2755,14 @@ instance ExactPrint (Sig GhcPs) where an0 <- markAnnOpen an (inl_src inl) "{-# SPECIALISE" -- Note: may be {-# SPECIALISE_INLINE an1 <- markActivation an0 lidl (inl_act inl) ln' <- markAnnotated ln - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon typs' <- markAnnotated typs an3 <- markEpAnnLMS'' an2 lidl AnnClose (Just "#-}") return (SpecSig an3 ln' typs' inl) exact (SpecInstSig (an,src) typ) = do an0 <- markAnnOpen an src "{-# SPECIALISE" - an1 <- markEpAnnL' an0 lidl AnnInstance + an1 <- markEpAnnL an0 lidl AnnInstance typ' <- markAnnotated typ an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") return (SpecInstSig (an2,src) typ') @@ -2799,7 +2787,7 @@ instance ExactPrint (Sig GhcPs) where case mty of Nothing -> return (an0, mty) Just ty -> do - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon ty' <- markAnnotated ty return (an1, Just ty') an2 <- markEpAnnLMS'' an1 lidl AnnClose (Just "#-}") @@ -2822,9 +2810,9 @@ instance ExactPrint (StandaloneKindSig GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StandaloneKindSig an vars sig) = do - an0 <- markEpAnnL' an lidl AnnType + an0 <- markEpAnnL an lidl AnnType vars' <- markAnnotated vars - an1 <- markEpAnnL' an0 lidl AnnDcolon + an1 <- markEpAnnL an0 lidl AnnDcolon sig' <- markAnnotated sig return (StandaloneKindSig an1 vars' sig') @@ -2835,10 +2823,10 @@ instance ExactPrint (DefaultDecl GhcPs) where setAnnotationAnchor a _ _ _ = a exact (DefaultDecl an tys) = do - an0 <- markEpAnnL' an lidl AnnDefault - an1 <- markEpAnnL' an0 lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnDefault + an1 <- markEpAnnL an0 lidl AnnOpenP tys' <- markAnnotated tys - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP return (DefaultDecl an2 tys') -- --------------------------------------------------------------------- @@ -2855,11 +2843,11 @@ instance ExactPrint (AnnDecl GhcPs) where n' <- markAnnotated n return (an0, ValueAnnProvenance n') (TypeAnnProvenance n) -> do - an1 <- markEpAnnL' an0 lapr_rest AnnType + an1 <- markEpAnnL an0 lapr_rest AnnType n' <- markAnnotated n return (an1, TypeAnnProvenance n') ModuleAnnProvenance -> do - an1 <- markEpAnnL' an lapr_rest AnnModule + an1 <- markEpAnnL an lapr_rest AnnModule return (an1, prov) e' <- markAnnotated e @@ -2969,11 +2957,11 @@ instance ExactPrint (HsExpr GhcPs) where return (HsLit an lit') exact (HsLam an lam_variant mg) = do - an0 <- mark' an AnnLam + an0 <- mark an AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> mark' an0 AnnCase - LamCases -> mark' an0 AnnCases + LamCase -> mark an0 AnnCase + LamCases -> mark an0 AnnCases mg' <- markAnnotated mg return (HsLam an1 lam_variant mg') @@ -2995,7 +2983,7 @@ instance ExactPrint (HsExpr GhcPs) where return (OpApp an e1' e2' e3') exact (NegApp an e s) = do - an0 <- markEpAnnL' an lidl AnnMinus + an0 <- markEpAnnL an lidl AnnMinus e' <- markAnnotated e return (NegApp an0 e' s) @@ -3018,50 +3006,50 @@ instance ExactPrint (HsExpr GhcPs) where return (SectionR an op' expr') exact (ExplicitTuple an args b) = do - an0 <- if b == Boxed then markEpAnnL' an lidl AnnOpenP - else markEpAnnL' an lidl AnnOpenPH + an0 <- if b == Boxed then markEpAnnL an lidl AnnOpenP + else markEpAnnL an lidl AnnOpenPH args' <- mapM markAnnotated args - an1 <- if b == Boxed then markEpAnnL' an0 lidl AnnCloseP - else markEpAnnL' an0 lidl AnnClosePH + an1 <- if b == Boxed then markEpAnnL an0 lidl AnnCloseP + else markEpAnnL an0 lidl AnnClosePH debugM $ "ExplicitTuple done" return (ExplicitTuple an1 args' b) exact (ExplicitSum an alt arity expr) = do - an0 <- markLensKw' an laesOpen AnnOpenPH + an0 <- markLensKw an laesOpen AnnOpenPH an1 <- markAnnKwAllL an0 laesBarsBefore AnnVbar expr' <- markAnnotated expr an2 <- markAnnKwAllL an1 laesBarsAfter AnnVbar - an3 <- markLensKw' an2 laesClose AnnClosePH + an3 <- markLensKw an2 laesClose AnnClosePH return (ExplicitSum an3 alt arity expr') exact (HsCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- setLayoutBoth $ markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCase an4 e' alts') exact (HsIf an e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsIf an4 e1' e2' e3') exact (HsMultiIf an mg) = do - an0 <- markEpAnnL' an lidl AnnIf - an1 <- markEpAnnL' an0 lidl AnnOpenC -- optional + an0 <- markEpAnnL an lidl AnnIf + an1 <- markEpAnnL an0 lidl AnnOpenC -- optional mg' <- markAnnotated mg - an2 <- markEpAnnL' an1 lidl AnnCloseC -- optional + an2 <- markEpAnnL an1 lidl AnnCloseC -- optional return (HsMultiIf an2 mg') exact (HsLet (tkLet, tkIn) binds e) = do @@ -3086,57 +3074,57 @@ instance ExactPrint (HsExpr GhcPs) where return (ExplicitList an1 es') exact (RecordCon an con_id binds) = do con_id' <- markAnnotated con_id - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC binds' <- markAnnotated binds - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordCon an1 con_id' binds') exact (RecordUpd an expr fields) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC fields' <- markAnnotated fields - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (RecordUpd an1 expr' fields') exact (HsGetField an expr field) = do expr' <- markAnnotated expr field' <- markAnnotated field return (HsGetField an expr' field') exact (HsProjection an flds) = do - an0 <- markLensKw' an lapOpen AnnOpenP + an0 <- markLensKw an lapOpen AnnOpenP flds' <- mapM markAnnotated flds - an1 <- markLensKw' an0 lapClose AnnCloseP + an1 <- markLensKw an0 lapClose AnnCloseP return (HsProjection an1 flds') exact (ExprWithTySig an expr sig) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (ExprWithTySig an0 expr' sig') exact (ArithSeq an s seqInfo) = do - an0 <- markEpAnnL' an lidl AnnOpenS -- '[' + an0 <- markEpAnnL an lidl AnnOpenS -- '[' (an1, seqInfo') <- case seqInfo of From e -> do e' <- markAnnotated e - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot return (an', From e') FromTo e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnDotdot + an' <- markEpAnnL an0 lidl AnnDotdot e2' <- markAnnotated e2 return (an', FromTo e1' e2') FromThen e1 e2 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot return (an'', FromThen e1' e2') FromThenTo e1 e2 e3 -> do e1' <- markAnnotated e1 - an' <- markEpAnnL' an0 lidl AnnComma + an' <- markEpAnnL an0 lidl AnnComma e2' <- markAnnotated e2 - an'' <- markEpAnnL' an' lidl AnnDotdot + an'' <- markEpAnnL an' lidl AnnDotdot e3' <- markAnnotated e3 return (an'', FromThenTo e1' e2' e3') - an2 <- markEpAnnL' an1 lidl AnnCloseS -- ']' + an2 <- markEpAnnL an1 lidl AnnCloseS -- ']' return (ArithSeq an2 s seqInfo') @@ -3148,46 +3136,46 @@ instance ExactPrint (HsExpr GhcPs) where return (HsTypedBracket an2 e') exact (HsUntypedBracket an (ExpBr a e)) = do - an0 <- markEpAnnL' an lidl AnnOpenEQ -- "[|" - an1 <- markEpAnnL' an0 lidl AnnOpenE -- "[e|" -- optional + an0 <- markEpAnnL an lidl AnnOpenEQ -- "[|" + an1 <- markEpAnnL an0 lidl AnnOpenE -- "[e|" -- optional e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an2 (ExpBr a e')) exact (HsUntypedBracket an (PatBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[p|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (PatBr a e')) exact (HsUntypedBracket an (DecBrL a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[d|") - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC e' <- markAnnotated e - an2 <- markEpAnnL' an1 lidl AnnCloseC - an3 <- markEpAnnL' an2 lidl AnnCloseQ -- "|]" + an2 <- markEpAnnL an1 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an3 (DecBrL a e')) exact (HsUntypedBracket an (TypBr a e)) = do an0 <- markEpAnnLMS'' an lidl AnnOpen (Just "[t|") e' <- markAnnotated e - an1 <- markEpAnnL' an0 lidl AnnCloseQ -- "|]" + an1 <- markEpAnnL an0 lidl AnnCloseQ -- "|]" return (HsUntypedBracket an1 (TypBr a e')) exact (HsUntypedBracket an (VarBr a b e)) = do (an0, e') <- if b then do - an' <- markEpAnnL' an lidl AnnSimpleQuote + an' <- markEpAnnL an lidl AnnSimpleQuote e' <- markAnnotated e return (an', e') else do - an' <- markEpAnnL' an lidl AnnThTyQuote + an' <- markEpAnnL an lidl AnnThTyQuote e' <- markAnnotated e return (an', e') return (HsUntypedBracket an0 (VarBr a b e')) exact (HsTypedSplice an s) = do - an0 <- markEpAnnL' an lidl AnnDollarDollar + an0 <- markEpAnnL an lidl AnnDollarDollar s' <- exact s return (HsTypedSplice an0 s') @@ -3197,15 +3185,15 @@ instance ExactPrint (HsExpr GhcPs) where exact (HsProc an p c) = do debugM $ "HsProc start" - an0 <- markEpAnnL' an lidl AnnProc + an0 <- markEpAnnL an lidl AnnProc p' <- markAnnotated p - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow debugM $ "HsProc after AnnRarrow" c' <- markAnnotated c return (HsProc an1 p' c') exact (HsStatic an e) = do - an0 <- markEpAnnL' an lidl AnnStatic + an0 <- markEpAnnL an lidl AnnStatic e' <- markAnnotated e return (HsStatic an0 e') @@ -3227,14 +3215,14 @@ exactDo :: (Monad m, Monoid w, ExactPrint (LocatedAn an a)) => AnnList -> HsDoFlavour -> LocatedAn an a -> EP w m (AnnList, LocatedAn an a) exactDo an (DoExpr m) stmts = exactMdo an m AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts -exactDo an GhciStmtCtxt stmts = markEpAnnL' an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts +exactDo an GhciStmtCtxt stmts = markEpAnnL an lal_rest AnnDo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an (MDoExpr m) stmts = exactMdo an m AnnMdo >>= \an0 -> markMaybeDodgyStmts an0 stmts exactDo an ListComp stmts = markMaybeDodgyStmts an stmts exactDo an MonadComp stmts = markMaybeDodgyStmts an stmts exactMdo :: (Monad m, Monoid w) => AnnList -> Maybe ModuleName -> AnnKeywordId -> EP w m AnnList -exactMdo an Nothing kw = markEpAnnL' an lal_rest kw +exactMdo an Nothing kw = markEpAnnL an lal_rest kw exactMdo an (Just module_name) kw = markEpAnnLMS'' an lal_rest kw (Just n) where n = (moduleNameString module_name) ++ "." ++ (keywordToString kw) @@ -3270,7 +3258,7 @@ instance ExactPrint (HsUntypedSplice GhcPs) where setAnnotationAnchor a _ _ _= a exact (HsUntypedSpliceExpr an e) = do - an0 <- markEpAnnL' an lidl AnnDollar + an0 <- markEpAnnL an lidl AnnDollar e' <- markAnnotated e return (HsUntypedSpliceExpr an0 e') @@ -3334,7 +3322,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3351,7 +3339,7 @@ instance (ExactPrint body) f' <- markAnnotated f (an0, arg') <- if isPun then return (an, arg) else do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual arg' <- markAnnotated arg return (an0, arg') return (HsFieldBind an0 f' arg' isPun) @@ -3367,7 +3355,7 @@ instance (ExactPrint (LocatedA body)) debugM $ "HsRecUpdField" f' <- markAnnotated f an0 <- if isPun then return an - else markEpAnnL' an lidl AnnEqual + else markEpAnnL an lidl AnnEqual arg' <- if isPun then return arg else markAnnotated arg @@ -3470,11 +3458,11 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdApp an e1' e2') exact (HsCmdLam an lam_variant matches) = do - an0 <- markEpAnnL' an lidl AnnLam + an0 <- markEpAnnL an lidl AnnLam an1 <- case lam_variant of LamSingle -> return an0 - LamCase -> markEpAnnL' an0 lidl AnnCase - LamCases -> markEpAnnL' an0 lidl AnnCases + LamCase -> markEpAnnL an0 lidl AnnCase + LamCases -> markEpAnnL an0 lidl AnnCases matches' <- markAnnotated matches return (HsCmdLam an1 lam_variant matches') @@ -3485,23 +3473,23 @@ instance ExactPrint (HsCmd GhcPs) where return (HsCmdPar (lpar', rpar') e') exact (HsCmdCase an e alts) = do - an0 <- markLensKw' an lhsCaseAnnCase AnnCase + an0 <- markLensKw an lhsCaseAnnCase AnnCase e' <- markAnnotated e - an1 <- markLensKw' an0 lhsCaseAnnOf AnnOf - an2 <- markEpAnnL' an1 lhsCaseAnnsRest AnnOpenC + an1 <- markLensKw an0 lhsCaseAnnOf AnnOf + an2 <- markEpAnnL an1 lhsCaseAnnsRest AnnOpenC an3 <- markEpAnnAllL' an2 lhsCaseAnnsRest AnnSemi alts' <- markAnnotated alts - an4 <- markEpAnnL' an3 lhsCaseAnnsRest AnnCloseC + an4 <- markEpAnnL an3 lhsCaseAnnsRest AnnCloseC return (HsCmdCase an4 e' alts') exact (HsCmdIf an a e1 e2 e3) = do - an0 <- markLensKw' an laiIf AnnIf + an0 <- markLensKw an laiIf AnnIf e1' <- markAnnotated e1 an1 <- markLensKwM' an0 laiThenSemi AnnSemi - an2 <- markLensKw' an1 laiThen AnnThen + an2 <- markLensKw an1 laiThen AnnThen e2' <- markAnnotated e2 an3 <- markLensKwM' an2 laiElseSemi AnnSemi - an4 <- markLensKw' an3 laiElse AnnElse + an4 <- markLensKw an3 laiElse AnnElse e3' <- markAnnotated e3 return (HsCmdIf an4 a e1' e2' e3') @@ -3515,7 +3503,7 @@ instance ExactPrint (HsCmd GhcPs) where exact (HsCmdDo an es) = do debugM $ "HsCmdDo" - an0 <- markEpAnnL' an lal_rest AnnDo + an0 <- markEpAnnL an lal_rest AnnDo es' <- markAnnotated es return (HsCmdDo an0 es') @@ -3538,7 +3526,7 @@ instance ( exact (BindStmt an pat body) = do debugM $ "BindStmt" pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnLarrow + an0 <- markEpAnnL an lidl AnnLarrow body' <- markAnnotated body return (BindStmt an0 pat' body') @@ -3552,7 +3540,7 @@ instance ( exact (LetStmt an binds) = do debugM $ "LetStmt" - an0 <- markEpAnnL' an lidl AnnLet + an0 <- markEpAnnL an lidl AnnLet binds' <- markAnnotated binds return (LetStmt an0 binds') @@ -3569,7 +3557,7 @@ instance ( exact (RecStmt an stmts a b c d e) = do debugM $ "RecStmt" - an0 <- markEpAnnL' an lal_rest AnnRec + an0 <- markEpAnnL an lal_rest AnnRec (an1, stmts') <- markAnnList' an0 (markAnnotated stmts) return (RecStmt an1 stmts' a b c d e) @@ -3587,25 +3575,25 @@ exactTransStmt :: (Monad m, Monoid w) -> EP w m ([AddEpAnn], Maybe (LHsExpr GhcPs), (LHsExpr GhcPs)) exactTransStmt an by using ThenForm = do debugM $ "exactTransStmt:ThenForm" - an0 <- markEpAnnL' an lidl AnnThen + an0 <- markEpAnnL an lidl AnnThen using' <- markAnnotated using case by of Nothing -> return (an0, by, using') Just b -> do - an1 <- markEpAnnL' an0 lidl AnnBy + an1 <- markEpAnnL an0 lidl AnnBy b' <- markAnnotated b return (an1, Just b', using') exactTransStmt an by using GroupForm = do debugM $ "exactTransStmt:GroupForm" - an0 <- markEpAnnL' an lidl AnnThen - an1 <- markEpAnnL' an0 lidl AnnGroup + an0 <- markEpAnnL an lidl AnnThen + an1 <- markEpAnnL an0 lidl AnnGroup (an2, by') <- case by of Nothing -> return (an1, by) Just b -> do - an2 <- markEpAnnL' an1 lidl AnnBy + an2 <- markEpAnnL an1 lidl AnnBy b' <- markAnnotated b return (an2, Just b') - an3 <- markEpAnnL' an2 lidl AnnUsing + an3 <- markEpAnnL an2 lidl AnnUsing using' <- markAnnotated using return (an3, by', using') @@ -3626,10 +3614,10 @@ instance ExactPrint (TyClDecl GhcPs) where -- that are infix. Turn these into comments so that they feed -- into the right place automatically an0 <- annotationsToComments an lidl [AnnOpenP,AnnCloseP] - an1 <- markEpAnnL' an0 lidl AnnType + an1 <- markEpAnnL an0 lidl AnnType (_anx, ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing - an2 <- markEpAnnL' an1 lidl AnnEqual + an2 <- markEpAnnL an1 lidl AnnEqual rhs' <- markAnnotated rhs return (SynDecl { tcdSExt = an2 , tcdLName = ltycon', tcdTyVars = tyvars', tcdFixity = fixity @@ -3656,8 +3644,8 @@ instance ExactPrint (TyClDecl GhcPs) where | null sigs && isEmptyBag methods && null ats && null at_defs -- No "where" part = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC - an2 <- markEpAnnL' an1 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnOpenC + an2 <- markEpAnnL an1 lidl AnnCloseC return (ClassDecl {tcdCExt = (an2, lo, sortKey), tcdCtxt = context', tcdLName = lclas', tcdTyVars = tyvars', tcdFixity = fixity, @@ -3669,7 +3657,7 @@ instance ExactPrint (TyClDecl GhcPs) where | otherwise -- Laid out = do (an0, fds', lclas', tyvars',context') <- top_matter - an1 <- markEpAnnL' an0 lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC an2 <- markEpAnnAllL' an1 lidl AnnSemi ds <- withSortKey sortKey [(ClsSigTag, prepareListAnnotationA sigs), @@ -3678,7 +3666,7 @@ instance ExactPrint (TyClDecl GhcPs) where (ClsAtdTag, prepareListAnnotationA at_defs) -- ++ prepareListAnnotation docs ] - an3 <- markEpAnnL' an2 lidl AnnCloseC + an3 <- markEpAnnL an2 lidl AnnCloseC let sigs' = undynamic ds methods' = listToBag $ undynamic ds @@ -3694,15 +3682,15 @@ instance ExactPrint (TyClDecl GhcPs) where where top_matter = do an' <- annotationsToComments an lidl [AnnOpenP, AnnCloseP] - an0 <- markEpAnnL' an' lidl AnnClass + an0 <- markEpAnnL an' lidl AnnClass (_, lclas', tyvars',_,context') <- exactVanillaDeclHead lclas tyvars fixity context (an1, fds') <- if (null fds) then return (an0, fds) else do - an1 <- markEpAnnL' an0 lidl AnnVbar + an1 <- markEpAnnL an0 lidl AnnVbar fds' <- markAnnotated fds return (an1, fds') - an2 <- markEpAnnL' an1 lidl AnnWhere + an2 <- markEpAnnL an1 lidl AnnWhere return (an2, fds', lclas', tyvars',context') @@ -3714,7 +3702,7 @@ instance ExactPrint (FunDep GhcPs) where exact (FunDep an ls rs') = do ls' <- markAnnotated ls - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow rs'' <- markAnnotated rs' return (FunDep an0 ls' rs'') @@ -3741,23 +3729,23 @@ instance ExactPrint (FamilyDecl GhcPs) where case mb_inj of Nothing -> return (an3, mb_inj) Just inj -> do - an4 <- markEpAnnL' an3 lidl AnnVbar + an4 <- markEpAnnL an3 lidl AnnVbar inj' <- markAnnotated inj return (an4, Just inj') (an5, info') <- case info of ClosedTypeFamily mb_eqns -> do - an5 <- markEpAnnL' an4 lidl AnnWhere - an6 <- markEpAnnL' an5 lidl AnnOpenC + an5 <- markEpAnnL an4 lidl AnnWhere + an6 <- markEpAnnL an5 lidl AnnOpenC (an7, mb_eqns') <- case mb_eqns of Nothing -> do - an7 <- markEpAnnL' an6 lidl AnnDotdot + an7 <- markEpAnnL an6 lidl AnnDotdot return (an7, mb_eqns) Just eqns -> do eqns' <- markAnnotated eqns return (an6, Just eqns') - an8 <- markEpAnnL' an7 lidl AnnCloseC + an8 <- markEpAnnL an7 lidl AnnCloseC return (an8, ClosedTypeFamily mb_eqns') _ -> return (an4, info) return (FamilyDecl { fdExt = an5 @@ -3771,30 +3759,30 @@ instance ExactPrint (FamilyDecl GhcPs) where where exact_top_level an' = case top_level of - TopLevel -> markEpAnnL' an' lidl AnnFamily + TopLevel -> markEpAnnL an' lidl AnnFamily NotTopLevel -> do -- It seems that in some kind of legacy -- mode the 'family' keyword is still -- accepted. - markEpAnnL' an' lidl AnnFamily + markEpAnnL an' lidl AnnFamily exact_kind an' = case result of NoSig _ -> return (an', result) KindSig x kind -> do - an0 <- markEpAnnL' an' lidl AnnDcolon + an0 <- markEpAnnL an' lidl AnnDcolon kind' <- markAnnotated kind return (an0, KindSig x kind') TyVarSig x tv_bndr -> do - an0 <- markEpAnnL' an' lidl AnnEqual + an0 <- markEpAnnL an' lidl AnnEqual tv_bndr' <- markAnnotated tv_bndr return (an0, TyVarSig x tv_bndr') exactFlavour :: (Monad m, Monoid w) => [AddEpAnn] -> FamilyInfo GhcPs -> EP w m [AddEpAnn] -exactFlavour an DataFamily = markEpAnnL' an lidl AnnData -exactFlavour an OpenTypeFamily = markEpAnnL' an lidl AnnType -exactFlavour an (ClosedTypeFamily {}) = markEpAnnL' an lidl AnnType +exactFlavour an DataFamily = markEpAnnL an lidl AnnData +exactFlavour an OpenTypeFamily = markEpAnnL an lidl AnnType +exactFlavour an (ClosedTypeFamily {}) = markEpAnnL an lidl AnnType -- --------------------------------------------------------------------- @@ -3821,31 +3809,31 @@ exactDataDefn an exactHdr an0 <- case condecls of DataTypeCons is_type_data _ -> do an0' <- if is_type_data - then markEpAnnL' an' lidl AnnType + then markEpAnnL an' lidl AnnType else return an' - markEpAnnL' an0' lidl AnnData - NewTypeCon _ -> markEpAnnL' an' lidl AnnNewtype + markEpAnnL an0' lidl AnnData + NewTypeCon _ -> markEpAnnL an' lidl AnnNewtype - an1 <- markEpAnnL' an0 lidl AnnInstance -- optional + an1 <- markEpAnnL an0 lidl AnnInstance -- optional mb_ct' <- mapM markAnnotated mb_ct (anx, ln', tvs', b, mctxt') <- exactHdr context (an2, mb_sig') <- case mb_sig of Nothing -> return (an1, Nothing) Just kind -> do - an2 <- markEpAnnL' an1 lidl AnnDcolon + an2 <- markEpAnnL an1 lidl AnnDcolon kind' <- markAnnotated kind return (an2, Just kind') an3 <- if (needsWhere condecls) - then markEpAnnL' an2 lidl AnnWhere + then markEpAnnL an2 lidl AnnWhere else return an2 - an4 <- markEpAnnL' an3 lidl AnnOpenC + an4 <- markEpAnnL an3 lidl AnnOpenC (an5, condecls') <- exact_condecls an4 (toList condecls) let condecls'' = case condecls of DataTypeCons d _ -> DataTypeCons d condecls' NewTypeCon _ -> case condecls' of [decl] -> NewTypeCon decl _ -> panic "exacprint NewTypeCon" - an6 <- markEpAnnL' an5 lidl AnnCloseC + an6 <- markEpAnnL an5 lidl AnnCloseC derivings' <- mapM markAnnotated derivings return (anx, an6, ln', tvs', b, mctxt', (HsDataDefn { dd_ext = x, dd_ctxt = context @@ -3895,9 +3883,9 @@ instance ExactPrint (InjectivityAnn GhcPs) where getAnnotationEntry _ = NoEntryVal setAnnotationAnchor a _ _ _ = a exact (InjectivityAnn an lhs rhs) = do - an0 <- markEpAnnL' an lidl AnnVbar + an0 <- markEpAnnL an lidl AnnVbar lhs' <- markAnnotated lhs - an1 <- markEpAnnL' an0 lidl AnnRarrow + an1 <- markEpAnnL an0 lidl AnnRarrow rhs' <- mapM markAnnotated rhs return (InjectivityAnn an1 lhs' rhs') @@ -3950,7 +3938,7 @@ instance ExactPrintTVFlag flag => ExactPrint (HsTyVarBndr flag GhcPs) where exact (KindedTyVar an flag n k) = do r <- exactTVDelimiters an flag $ do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (KindedTyVar an0 flag n' k') case r of @@ -3976,7 +3964,7 @@ instance ExactPrint (HsType GhcPs) where return (HsQualTy an ctxt' ty') exact (HsTyVar an promoted name) = do an0 <- if (promoted == IsPromoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an name' <- markAnnotated name return (HsTyVar an0 promoted name') @@ -4011,7 +3999,7 @@ instance ExactPrint (HsType GhcPs) where return (HsSumTy an1 tys') exact (HsOpTy an promoted t1 lo t2) = do an0 <- if (isPromoted promoted) - then markEpAnnL' an lidl AnnSimpleQuote + then markEpAnnL an lidl AnnSimpleQuote else return an t1' <- markAnnotated t1 lo' <- markAnnotated lo @@ -4024,7 +4012,7 @@ instance ExactPrint (HsType GhcPs) where return (HsParTy an1 ty') exact (HsIParamTy an n t) = do n' <- markAnnotated n - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon t' <- markAnnotated t return (HsIParamTy an0 n' t') exact (HsStarTy an isUnicode) = do @@ -4034,7 +4022,7 @@ instance ExactPrint (HsType GhcPs) where return (HsStarTy an isUnicode) exact (HsKindSig an ty k) = do ty' <- markAnnotated ty - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon k' <- markAnnotated k return (HsKindSig an0 ty' k') exact (HsSpliceTy a splice) = do @@ -4055,24 +4043,24 @@ instance ExactPrint (HsType GhcPs) where return an1 an1 <- case str of - SrcLazy -> mark' an0 AnnTilde - SrcStrict -> mark' an0 AnnBang + SrcLazy -> mark an0 AnnTilde + SrcStrict -> mark an0 AnnBang NoSrcStrict -> return an0 ty' <- markAnnotated ty return (HsBangTy an1 (HsSrcBang mt up str) ty') exact (HsExplicitListTy an prom tys) = do an0 <- if (isPromoted prom) - then mark' an AnnSimpleQuote + then mark an AnnSimpleQuote else return an - an1 <- mark' an0 AnnOpenS + an1 <- mark an0 AnnOpenS tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseS + an2 <- mark an1 AnnCloseS return (HsExplicitListTy an2 prom tys') exact (HsExplicitTupleTy an tys) = do - an0 <- mark' an AnnSimpleQuote - an1 <- mark' an0 AnnOpenP + an0 <- mark an AnnSimpleQuote + an1 <- mark an0 AnnOpenP tys' <- markAnnotated tys - an2 <- mark' an1 AnnCloseP + an2 <- mark an1 AnnCloseP return (HsExplicitTupleTy an2 tys') exact (HsTyLit a lit) = do case lit of @@ -4113,7 +4101,7 @@ instance ExactPrint (HsDerivingClause GhcPs) where exact (HsDerivingClause { deriv_clause_ext = an , deriv_clause_strategy = dcs , deriv_clause_tys = dct }) = do - an0 <- markEpAnnL' an lidl AnnDeriving + an0 <- markEpAnnL an lidl AnnDeriving exact_strat_before dct' <- markAnnotated dct exact_strat_after @@ -4133,16 +4121,16 @@ instance ExactPrint (DerivStrategy GhcPs) where setAnnotationAnchor a _ _ _ = a exact (StockStrategy an) = do - an0 <- markEpAnnL' an lid AnnStock + an0 <- markEpAnnL an lid AnnStock return (StockStrategy an0) exact (AnyclassStrategy an) = do - an0 <- markEpAnnL' an lid AnnAnyclass + an0 <- markEpAnnL an lid AnnAnyclass return (AnyclassStrategy an0) exact (NewtypeStrategy an) = do - an0 <- markEpAnnL' an lid AnnNewtype + an0 <- markEpAnnL an lid AnnNewtype return (NewtypeStrategy an0) exact (ViaStrategy (XViaStrategyPs an ty)) = do - an0 <- markEpAnnL' an lid AnnVia + an0 <- markEpAnnL an lid AnnVia ty' <- markAnnotated ty return (ViaStrategy (XViaStrategyPs an0 ty')) @@ -4293,7 +4281,7 @@ exact_condecls an cs return (an, cs') | otherwise -- In H98 syntax = do - an0 <- markEpAnnL' an lidl AnnEqual + an0 <- markEpAnnL an lidl AnnEqual cs' <- mapM markAnnotated cs return (an0, cs') where @@ -4317,15 +4305,15 @@ instance ExactPrint (ConDecl GhcPs) where , con_args = args , con_doc = doc }) = do an0 <- if has_forall - then markEpAnnL' an lidl AnnForall + then markEpAnnL an lidl AnnForall else return an ex_tvs' <- mapM markAnnotated ex_tvs an1 <- if has_forall - then markEpAnnL' an0 lidl AnnDot + then markEpAnnL an0 lidl AnnDot else return an0 mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 (con', args') <- exact_details args @@ -4373,7 +4361,7 @@ instance ExactPrint (ConDecl GhcPs) where mcxt' <- mapM markAnnotated mcxt an2 <- if (isJust mcxt) - then markEpAnnL' an1 lidl AnnDarrow + then markEpAnnL an1 lidl AnnDarrow else return an1 args' <- case args of @@ -4422,7 +4410,7 @@ instance ExactPrint (ConDeclField GhcPs) where exact (ConDeclField an names ftype mdoc) = do names' <- markAnnotated names - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon ftype' <- markAnnotated ftype return (ConDeclField an0 names' ftype' mdoc) @@ -4496,7 +4484,7 @@ instance ExactPrint (LocatedL [LocatedA (IE GhcPs)]) where exact (L an ies) = do debugM $ "LocatedL [LIE" - an0 <- markEpAnnL an lal_rest AnnHiding + an0 <- markEpAnnL' an lal_rest AnnHiding p <- getPosP debugM $ "LocatedL [LIE:p=" ++ showPprUnsafe p (an1, ies') <- markAnnList an0 (markAnnotated ies) @@ -4579,16 +4567,16 @@ instance ExactPrint (IE GhcPs) where exact (IEThingAll (depr, an) thing doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnCloseP + an0 <- markEpAnnL an lidl AnnOpenP + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingAll (depr', an2) thing' doc') exact (IEThingWith (depr, an) thing wc withs doc) = do depr' <- markAnnotated depr thing' <- markAnnotated thing - an0 <- markEpAnnL' an lidl AnnOpenP + an0 <- markEpAnnL an lidl AnnOpenP (an1, wc', withs') <- case wc of NoIEWildcard -> do @@ -4597,17 +4585,17 @@ instance ExactPrint (IE GhcPs) where IEWildcard pos -> do let (bs, as) = splitAt pos withs bs' <- markAnnotated bs - an1 <- markEpAnnL' an0 lidl AnnDotdot - an2 <- markEpAnnL' an1 lidl AnnComma + an1 <- markEpAnnL an0 lidl AnnDotdot + an2 <- markEpAnnL an1 lidl AnnComma as' <- markAnnotated as return (an2, wc, bs'++as') - an2 <- markEpAnnL' an1 lidl AnnCloseP + an2 <- markEpAnnL an1 lidl AnnCloseP doc' <- markAnnotated doc return (IEThingWith (depr', an2) thing' wc' withs' doc') exact (IEModuleContents (depr, an) m) = do depr' <- markAnnotated depr - an0 <- markEpAnnL' an lidl AnnModule + an0 <- markEpAnnL an lidl AnnModule m' <- markAnnotated m return (IEModuleContents (depr', an0) m') @@ -4658,7 +4646,7 @@ instance ExactPrint (Pat GhcPs) where else return n return (VarPat x n') exact (LazyPat an pat) = do - an0 <- markEpAnnL' an lidl AnnTilde + an0 <- markEpAnnL an lidl AnnTilde pat' <- markAnnotated pat return (LazyPat an0 pat') exact (AsPat at n pat) = do @@ -4673,7 +4661,7 @@ instance ExactPrint (Pat GhcPs) where return (ParPat (lpar', rpar') pat') exact (BangPat an pat) = do - an0 <- markEpAnnL' an lidl AnnBang + an0 <- markEpAnnL an lidl AnnBang pat' <- markAnnotated pat return (BangPat an0 pat') @@ -4683,20 +4671,20 @@ instance ExactPrint (Pat GhcPs) where exact (TuplePat an pats boxity) = do an0 <- case boxity of - Boxed -> markEpAnnL' an lidl AnnOpenP - Unboxed -> markEpAnnL' an lidl AnnOpenPH + Boxed -> markEpAnnL an lidl AnnOpenP + Unboxed -> markEpAnnL an lidl AnnOpenPH pats' <- markAnnotated pats an1 <- case boxity of - Boxed -> markEpAnnL' an0 lidl AnnCloseP - Unboxed -> markEpAnnL' an0 lidl AnnClosePH + Boxed -> markEpAnnL an0 lidl AnnCloseP + Unboxed -> markEpAnnL an0 lidl AnnClosePH return (TuplePat an1 pats' boxity) exact (SumPat an pat alt arity) = do - an0 <- markEpAnnL' an lsumPatParens AnnOpenPH + an0 <- markEpAnnL an lsumPatParens AnnOpenPH an1 <- markAnnKwAllL an0 lsumPatVbarsBefore AnnVbar pat' <- markAnnotated pat an2 <- markAnnKwAllL an1 lsumPatVbarsAfter AnnVbar - an3 <- markEpAnnL' an2 lsumPatParens AnnClosePH + an3 <- markEpAnnL an2 lsumPatParens AnnClosePH return (SumPat an3 pat' alt arity) exact (ConPat an con details) = do @@ -4704,7 +4692,7 @@ instance ExactPrint (Pat GhcPs) where return (ConPat an' con' details') exact (ViewPat an expr pat) = do expr' <- markAnnotated expr - an0 <- markEpAnnL' an lidl AnnRarrow + an0 <- markEpAnnL an lidl AnnRarrow pat' <- markAnnotated pat return (ViewPat an0 expr' pat') exact (SplicePat x splice) = do @@ -4713,7 +4701,7 @@ instance ExactPrint (Pat GhcPs) where exact p@(LitPat _ lit) = printStringAdvance (hsLit2String lit) >> return p exact (NPat an ol mn z) = do an0 <- if (isJust mn) - then markEpAnnL' an lidl AnnMinus + then markEpAnnL an lidl AnnMinus else return an ol' <- markAnnotated ol return (NPat an0 ol' mn z) @@ -4726,7 +4714,7 @@ instance ExactPrint (Pat GhcPs) where exact (SigPat an pat sig) = do pat' <- markAnnotated pat - an0 <- markEpAnnL' an lidl AnnDcolon + an0 <- markEpAnnL an lidl AnnDcolon sig' <- markAnnotated sig return (SigPat an0 pat' sig') @@ -4832,9 +4820,9 @@ exactUserCon an c (InfixCon p1 p2) = do return (an, c', InfixCon p1' p2') exactUserCon an c details = do c' <- markAnnotated c - an0 <- markEpAnnL' an lidl AnnOpenC + an0 <- markEpAnnL an lidl AnnOpenC details' <- exactConArgs details - an1 <- markEpAnnL' an0 lidl AnnCloseC + an1 <- markEpAnnL an0 lidl AnnCloseC return (an1, c', details') instance ExactPrint (HsConPatTyArg GhcPs) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a38450dc9f054949d091006efdf219d07fc6d9d1...4c4740b22cd166bbede9683c1d7be01c096cb311 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a38450dc9f054949d091006efdf219d07fc6d9d1...4c4740b22cd166bbede9683c1d7be01c096cb311 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 14:18:03 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 21 Mar 2024 10:18:03 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24551 Message-ID: <65fc419b4d18c_1068ad184d1d01025a3@gitlab.mail> Sebastian Graf pushed new branch wip/T24551 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24551 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 14:19:46 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 21 Mar 2024 10:19:46 -0400 Subject: [Git][ghc/ghc][wip/T24551] Simplifier: Re-do dependency analysis in abstractFloats (#24551) Message-ID: <65fc42023c189_1068ad1a3482c10964a@gitlab.mail> Sebastian Graf pushed to branch wip/T24551 at Glasgow Haskell Compiler / GHC Commits: 5950745d by Sebastian Graf at 2024-03-21T15:19:33+01:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/simplCore/should_compile/T24551.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -85,6 +85,8 @@ import GHC.Utils.Panic import Control.Monad ( when ) import Data.List ( sortBy ) +import GHC.Types.Name.Env +import Data.Graph {- ********************************************************************* * * @@ -2108,6 +2110,27 @@ new binding is abstracted. Several points worth noting which showed that it's harder to do polymorphic specialisation well if there are dictionaries abstracted over unnecessary type variables. See Note [Weird special case for SpecDict] in GHC.Core.Opt.Specialise + +(AB5) We do dependency analysis on recursive groups prior to determining + which variables to abstract over. + This is useful, because ANFisation in prepareBinding may float out + values out of a complex recursive binding, e.g., + letrec { xs = g @a "blah"# ((:) 1 []) xs } in ... + ==> { prepareBinding } + letrec { foo = "blah"# + bar = [42] + xs = g @a foo bar xs } in + ... + and we don't want to abstract foo and bar over @a. + + (Why is it OK to float the unlifted `foo` there? + See Note [Core top-level string literals] in GHC.Core; + it is controlled by GHC.Core.Opt.Simplify.Env.unitLetFloat.) + + It is also necessary to do dependency analysis, because + otherwise (in #24551) we might get `foo = \@_ -> "missing"#` at the + top-level, and that triggers a CoreLint error because `foo` is *not* + manifestly a literal string. -} abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats @@ -2115,15 +2138,27 @@ abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats abstractFloats uf_opts top_lvl main_tvs floats body = assert (notNull body_floats) $ assert (isNilOL (sfJoinFloats floats)) $ - do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats + do { let sccs = concatMap to_sccs body_floats + ; (subst, float_binds) <- mapAccumLM abstract empty_subst sccs ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl body_floats = letFloatBinds (sfLetFloats floats) empty_subst = GHC.Core.Subst.mkEmptySubst (sfInScope floats) - abstract :: GHC.Core.Subst.Subst -> OutBind -> SimplM (GHC.Core.Subst.Subst, OutBind) - abstract subst (NonRec id rhs) + -- See wrinkle (AB5) in Note [Which type variables to abstract over] + -- for why we need to re-do dependency analysis + to_sccs :: OutBind -> [SCC (Id, CoreExpr, VarSet)] + to_sccs (NonRec id e) = [AcyclicSCC (id, e, emptyVarSet)] -- emptyVarSet: abstract doesn't need it + to_sccs (Rec prs) = sccs + where + (ids,rhss) = unzip prs + sccs = depAnal (\(id,_rhs,_fvs) -> [getName id]) + (\(_id,_rhs,fvs) -> nonDetStrictFoldVarSet ((:) . getName) [] fvs) -- Wrinkle (AB3) + (zip3 ids rhss (map exprFreeVars rhss)) + + abstract :: GHC.Core.Subst.Subst -> SCC (Id, CoreExpr, VarSet) -> SimplM (GHC.Core.Subst.Subst, OutBind) + abstract subst (AcyclicSCC (id, rhs, _empty_var_set)) = do { (poly_id1, poly_app) <- mk_poly1 tvs_here id ; let (poly_id2, poly_rhs) = mk_poly2 poly_id1 tvs_here rhs' !subst' = GHC.Core.Subst.extendIdSubst subst id poly_app @@ -2134,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body -- tvs_here: see Note [Which type variables to abstract over] tvs_here = choose_tvs (exprSomeFreeVars isTyVar rhs') - abstract subst (Rec prs) + abstract subst (CyclicSCC trpls) = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' @@ -2142,15 +2177,15 @@ abstractFloats uf_opts top_lvl main_tvs floats body , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where - (ids,rhss) = unzip prs - + (ids,rhss,_fvss) = unzip3 trpls -- tvs_here: see Note [Which type variables to abstract over] - tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs prs) + tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs trpls) -- See wrinkle (AB4) in Note [Which type variables to abstract over] - get_bind_fvs (id,rhs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs - get_rec_rhs_tvs rhs = nonDetStrictFoldVarSet get_tvs emptyVarSet (exprFreeVars rhs) + get_bind_fvs (id,_rhs,rhs_fvs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs_fvs + get_rec_rhs_tvs rhs_fvs = nonDetStrictFoldVarSet get_tvs emptyVarSet rhs_fvs + -- nonDet is safe because of wrinkle (AB3) get_tvs :: Var -> VarSet -> VarSet get_tvs var free_tvs ===================================== testsuite/tests/simplCore/should_compile/T24551.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module T24551 (f) where + +import GHC.Exts + +f :: a -> a +f = repeatFB g + +repeatFB :: (Addr# -> (a -> a) -> a -> a) -> a -> a +repeatFB c = let xs = c "missing"# xs in xs +{-# INLINE [0] repeatFB #-} + +g :: Addr# -> (a -> a) -> a -> a +g _ _ x = x +{-# NOINLINE g #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T23209', [extra_files(['T23209_Aux.hs'])], multimod_compile, ['T23209', '- test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) +test('T24551', normal, compile, ['-O -dcore-lint']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5950745d193b5516efba539313fde8e3c36cf99e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5950745d193b5516efba539313fde8e3c36cf99e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 14:19:48 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 10:19:48 -0400 Subject: [Git][ghc/ghc][master] docs: Remove mention of non-existent Ord instance for Complex Message-ID: <65fc4204ad102_1068ad1a8a44810989e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 1 changed file: - libraries/base/src/Data/Complex.hs Changes: ===================================== libraries/base/src/Data/Complex.hs ===================================== @@ -62,7 +62,7 @@ infix 6 :+ -- it holds that @z == 'abs' z * 'signum' z at . -- -- Note that `Complex`'s instances inherit the deficiencies from the type --- parameter's. For example, @Complex Float@'s 'Ord' instance has similar +-- parameter's. For example, @Complex Float@'s 'Eq' instance has similar -- problems to `Float`'s. -- -- As can be seen in the examples, the 'Foldable' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/247fc0fa9a0fe1f37fabc5a28640b41d7f665aac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/247fc0fa9a0fe1f37fabc5a28640b41d7f665aac You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 14:20:44 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 10:20:44 -0400 Subject: [Git][ghc/ghc][master] Fix TH handling in `pat_to_type_pat` function (#24571) Message-ID: <65fc423c8745b_1068ad1b149b811275@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 3 changed files: - compiler/GHC/Tc/Gen/Pat.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -534,6 +534,9 @@ pat_to_type_pat (SigPat _ pat sig_ty) pat_to_type_pat (ParPat _ pat) = do { HsTP x t <- pat_to_type_pat (unLoc pat) ; return (HsTP x (noLocA (HsParTy noAnn t))) } +pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { HsTP x t <- pat_to_type_pat pat + ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } pat_to_type_pat pat = -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to ===================================== testsuite/tests/th/T24571.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell, RequiredTypeArguments #-} +module T24571 where + +g :: forall a -> () +g $([p| a |]) = () ===================================== testsuite/tests/th/all.T ===================================== @@ -605,3 +605,4 @@ test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) test('T24559', normal, compile, ['']) +test('T24571', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fafc51e9206abd62881131c282ec3b9e1584c5b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fafc51e9206abd62881131c282ec3b9e1584c5b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 14:51:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 10:51:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: docs: Remove mention of non-existent Ord instance for Complex Message-ID: <65fc497813d6b_1068ad315b1e01222a0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - e46c227c by Sylvain Henry at 2024-03-21T10:51:16-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 3a854011 by Sylvain Henry at 2024-03-21T10:51:19-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - c7543596 by Sylvain Henry at 2024-03-21T10:51:19-04:00 JS: fix some comments - - - - - 11 changed files: - compiler/GHC/Parser/Lexer.x - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Module.hs - libraries/base/src/Data/Complex.hs - libraries/ghc-internal/src/GHC/Internal/Maybe.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T - testsuite/tests/typecheck/should_compile/Makefile - + testsuite/tests/typecheck/should_compile/T24566.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2814,19 +2814,19 @@ characters into single bytes. {-# INLINE adjustChar #-} adjustChar :: Char -> Word8 -adjustChar c = fromIntegral $ ord adj_c - where non_graphic = '\x00' - upper = '\x01' - lower = '\x02' - digit = '\x03' - symbol = '\x04' - space = '\x05' - other_graphic = '\x06' - uniidchar = '\x07' +adjustChar c = adj_c + where non_graphic = 0x00 + upper = 0x01 + lower = 0x02 + digit = 0x03 + symbol = 0x04 + space = 0x05 + other_graphic = 0x06 + uniidchar = 0x07 adj_c | c <= '\x07' = non_graphic - | c <= '\x7f' = c + | c <= '\x7f' = fromIntegral (ord c) -- Alex doesn't handle Unicode, so when Unicode -- character is encountered we output these values -- with the actual character value hidden in the state. @@ -2866,15 +2866,18 @@ adjustChar c = fromIntegral $ ord adj_c -- -- See Note [Unicode in Alex] and #13986. alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (AI _ buf) = chr (fromIntegral (adjustChar pc)) +alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' +unsafeChr :: Int -> Char +unsafeChr (I# c) = C# (chr# c) + -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) alexGetChar inp = case alexGetByte inp of Nothing -> Nothing Just (b,i) -> c `seq` Just (c,i) - where c = chr $ fromIntegral b + where c = unsafeChr $ fromIntegral b -- See Note [Unicode in Alex] alexGetByte :: AlexInput -> Maybe (Word8,AlexInput) ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -738,7 +738,7 @@ writeExterns out = writeFile (out "all.js.externs") -- | Get all block dependencies for a given set of roots -- --- Returns the update block info map and the blocks. +-- Returns the updated block info map and the blocks. getDeps :: Map Module LocatedBlockInfo -- ^ Block info per module -> (Module -> IO LocatedBlockInfo) -- ^ Used to load block info if missing -> Set ExportedFun -- ^ start here @@ -754,7 +754,7 @@ getDeps init_infos load_info root_funs root_blocks = traverse_funs init_infos S. -- 1. We use the BlockInfos to find the block corresponding to every -- exported root functions. -- - -- 2. We had these blocks to the set of root_blocks if they aren't already + -- 2. We add these blocks to the set of root_blocks if they aren't already -- added to the result. -- -- 3. Then we traverse the root_blocks to find their dependencies and we ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -534,6 +534,9 @@ pat_to_type_pat (SigPat _ pat sig_ty) pat_to_type_pat (ParPat _ pat) = do { HsTP x t <- pat_to_type_pat (unLoc pat) ; return (HsTP x (noLocA (HsParTy noAnn t))) } +pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { HsTP x t <- pat_to_type_pat pat + ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } pat_to_type_pat pat = -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -709,7 +709,7 @@ tcRnHsBootDecls boot_or_sig decls -- Typecheck type/class/instance decls ; traceTc "Tc2 (boot)" empty ; (tcg_env, inst_infos, _deriv_binds, _th_bndrs) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds + <- tcTyClsInstDecls tycl_decls deriv_decls def_decls val_binds ; setGblEnv tcg_env $ do { -- Emit Typeable bindings @@ -1612,7 +1612,7 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, traceTc "Tc3" empty ; (tcg_env, inst_infos, th_bndrs, XValBindsLR (NValBinds deriv_binds deriv_sigs)) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds ; + <- tcTyClsInstDecls tycl_decls deriv_decls default_decls val_binds ; updLclCtxt (\tcl_env -> tcl_env { tcl_th_bndrs = th_bndrs `plusNameEnv` tcl_th_bndrs tcl_env }) $ setGblEnv tcg_env $ do { @@ -1622,11 +1622,6 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, (fi_ids, fi_decls, fi_gres) <- tcForeignImports foreign_decls ; tcExtendGlobalValEnv fi_ids $ do { - -- Default declarations - traceTc "Tc4a" empty ; - default_tys <- tcDefaults default_decls ; - updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { - -- Value declarations next. -- It is important that we check the top-level value bindings -- before the GHC-generated derived bindings, since the latter @@ -1686,13 +1681,14 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, addUsedGREs NoDeprecationWarnings (bagToList fo_gres) ; return (tcg_env', tcl_env) - }}}}}} + }}}}} tcTopSrcDecls _ = panic "tcTopSrcDecls: ValBindsIn" --------------------------- tcTyClsInstDecls :: [TyClGroup GhcRn] -> [LDerivDecl GhcRn] + -> [LDefaultDecl GhcRn] -> [(RecFlag, LHsBinds GhcRn)] -> TcM (TcGblEnv, -- The full inst env [InstInfo GhcRn], -- Source-code instance decls to @@ -1702,16 +1698,24 @@ tcTyClsInstDecls :: [TyClGroup GhcRn] HsValBinds GhcRn) -- Supporting bindings for derived -- instances -tcTyClsInstDecls tycl_decls deriv_decls binds +tcTyClsInstDecls tycl_decls deriv_decls default_decls binds = tcAddDataFamConPlaceholders (tycl_decls >>= group_instds) $ tcAddPatSynPlaceholders (getPatSynBinds binds) $ do { (tcg_env, inst_info, deriv_info, th_bndrs) <- tcTyAndClassDecls tycl_decls ; + ; setGblEnv tcg_env $ do { + -- With the @TyClDecl at s and @InstDecl at s checked we're ready to -- process the deriving clauses, including data family deriving -- clauses discovered in @tcTyAndClassDecls at . -- + -- But only after we've typechecked 'default' declarations. + -- See Note [Typechecking default declarations] + default_tys <- tcDefaults default_decls ; + updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { + + -- Careful to quit now in case there were instance errors, so that -- the deriving errors don't pile up as well. ; failIfErrsM @@ -1720,7 +1724,7 @@ tcTyClsInstDecls tycl_decls deriv_decls binds ; setGblEnv tcg_env' $ do { failIfErrsM ; pure ( tcg_env', inst_info' ++ inst_info, th_bndrs, val_binds ) - }}} + }}}} {- ********************************************************************* * * @@ -3141,3 +3145,43 @@ mark_plugin_unsafe dflags = unless (gopt Opt_PluginTrustworthy dflags) $ pluginUnsafe = singleMessage $ mkPlainMsgEnvelope diag_opts noSrcSpan TcRnUnsafeDueToPlugin + + +-- Note [Typechecking default declarations] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Typechecking default declarations requires careful placement: +-- +-- 1. We must check them after types (tcTyAndClassDecls) because they can refer +-- to them. E.g. +-- +-- data T = MkT ... +-- default(Int, T, Integer) +-- +-- -- or even (tested by T11974b and T2245) +-- default(Int, T, Integer) +-- data T = MkT ... +-- +-- 2. We must check them before typechecking deriving clauses (tcInstDeclsDeriv) +-- otherwise we may lookup default default types (Integer, Double) while checking +-- deriving clauses, ignoring the default declaration. +-- +-- Before this careful placement (#24566), compiling the following example +-- (T24566) with "-ddump-if-trace -ddump-tc-trace" showed a call to +-- `applyDefaultingRules` with default types set to "(Integer,Double)": +-- +-- module M where +-- +-- import GHC.Classes +-- default () +-- +-- data Foo a = Nothing | Just a +-- deriving (Eq, Ord) +-- +-- This was an issue while building modules like M in the ghc-internal package +-- because they would spuriously fail to build if the module defining Integer +-- (ghc-bignum:GHC.Num.Integer) wasn't compiled yet and its interface not to be +-- found. The implicit dependency between M and GHC.Num.Integer isn't known to +-- the build system. +-- In addition, trying to explicitly avoid the implicit dependency with `default +-- ()` didn't work, except if *standalone* deriving was used, which was an +-- inconsistent behavior. ===================================== libraries/base/src/Data/Complex.hs ===================================== @@ -62,7 +62,7 @@ infix 6 :+ -- it holds that @z == 'abs' z * 'signum' z at . -- -- Note that `Complex`'s instances inherit the deficiencies from the type --- parameter's. For example, @Complex Float@'s 'Ord' instance has similar +-- parameter's. For example, @Complex Float@'s 'Eq' instance has similar -- problems to `Float`'s. -- -- As can be seen in the examples, the 'Foldable' ===================================== libraries/ghc-internal/src/GHC/Internal/Maybe.hs ===================================== @@ -28,14 +28,5 @@ default () -- data Maybe a = Nothing | Just a deriving ( Eq -- ^ @since base-2.01 - - --, Ord -- ^ @since base-2.01 + , Ord -- ^ @since base-2.01 ) - --- ??? --- A non-standalone instance will slurp the interface file for GHC.Num.Integer. - -- During simplifyInstanceContexts, a call to GHC.Tc.Utils.Env.tcGetDefaultTys - -- apparently sees mb_defaults = Nothing and thus tries to bring in the - -- default "default" types, including Integer. This seems wrong. -deriving instance Ord a => Ord (Maybe a) -- ^ @since base-2.01 - ===================================== testsuite/tests/th/T24571.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell, RequiredTypeArguments #-} +module T24571 where + +g :: forall a -> () +g $([p| a |]) = () ===================================== testsuite/tests/th/all.T ===================================== @@ -605,3 +605,4 @@ test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) test('T24559', normal, compile, ['']) +test('T24571', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/Makefile ===================================== @@ -122,3 +122,7 @@ InlinePatSyn_ExplicitBidiBuilder: InlinePatSyn_ExplicitBidiMatcher: $(RM) -f InlinePatSyn_ExplicitBidiMatcher.o InlinePatSyn_ExplicitBidiMatcher.hi '$(TEST_HC)' $(TEST_HC_OPTS) -c InlinePatSyn_ExplicitBidiMatcher.hs -O -dsuppress-all -ddump-simpl | sed -n '/^test/,/^$$/p' | grep -vq 'Pattern' + +T24566: + '$(TEST_HC)' $(TEST_HC_OPTS) -c T24566.hs -fno-code -dno-typeable-binds -ddump-if-trace 2>&1 | grep Integer || true + # Not expecting any mention of Integer in the interface loading trace ===================================== testsuite/tests/typecheck/should_compile/T24566.hs ===================================== @@ -0,0 +1,7 @@ +module M where + +import GHC.Classes +default () + +data Foo a = Nothing | Just a + deriving (Eq, Ord) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -913,3 +913,4 @@ test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) test('T24470b', normal, compile, ['']) +test('T24566', [], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1028b0bcbce3995ab257a7f3fcbed5386ae78f9...c7543596dfba03a733aedee6683621721088b9b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1028b0bcbce3995ab257a7f3fcbed5386ae78f9...c7543596dfba03a733aedee6683621721088b9b1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 15:48:50 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 21 Mar 2024 11:48:50 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/drop-rel-notes Message-ID: <65fc56e24a65c_1068ad4cf4d341340af@gitlab.mail> Ben Gamari pushed new branch wip/drop-rel-notes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/drop-rel-notes You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 15:49:37 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 21 Mar 2024 11:49:37 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 5 commits: docs: Drop old release notes Message-ID: <65fc5711e783f_1068ad4df339814071d@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 47272633 by Ben Gamari at 2024-03-13T18:21:37-04:00 docs: Drop old release notes - - - - - db8a17a0 by Ben Gamari at 2024-03-13T18:33:12-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - b55e0ef9 by Ben Gamari at 2024-03-13T18:33:17-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - 548da279 by Ben Gamari at 2024-03-14T09:13:15-04:00 rel_env/recompress_all: Decompress xz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - cf814fe9 by Teo Camarasu at 2024-03-21T11:44:15-04:00 Add preamble to 9.10 release notes Resolves #24567 - - - - - 5 changed files: - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - docs/users_guide/9.10.1-notes.rst - − docs/users_guide/9.6.1-notes.rst - − docs/users_guide/9.8.1-notes.rst Changes: ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -9,21 +9,22 @@ usage : %.gz : %.xz echo "[xz->gz] $< to $@..." - xz -c $< | gzip -c > $@ + xz -cd $< | gzip -c > $@ %.bz2 : %.xz echo "[xz->bz2] $< to $@..." - xz -c $< | bzip2 -c > $@ + xz -cd $< | bzip2 -c > $@ %.lz : %.xz echo "[xz->lz] $< to $@..." - xz -c $< | lzip -c > $@ + xz -cd $< | lzip -c > $@ %.zip : %.tar.xz echo "[tarxz->zip] $< to $@..." - tmp="$(mktemp tmp.XXX)" && \ + tmp="$$(mktemp tmp.XXX)" && \ tar -C "$$tmp" -xf $< && \ cd "$$tmp" && \ zip -9 -r $@ * && \ + cd .. && \ rm -R "$$tmp" ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -145,7 +145,7 @@ function purge_all() { curl -X PURGE http://downloads.haskell.org/~ghc/$dir curl -X PURGE http://downloads.haskell.org/~ghc/$dir/ for i in *; do - purge_file $i + purge_file "$i" done } @@ -158,43 +158,14 @@ function purge_file() { ) for dir in ${dirs[@]}; do - curl -X PURGE http://downloads.haskell.org/$dir/$i - curl -X PURGE http://downloads.haskell.org/$dir/$i/ - curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/ + curl -X PURGE http://downloads.haskell.org/$dir/$1 + curl -X PURGE http://downloads.haskell.org/$dir/$1/ + curl -X PURGE http://downloads.haskell.org/$dir/$1/docs/ done } function prepare_docs() { echo "THIS COMMAND IS DEPRECATED, THE DOCS FOLDER SHOULD BE PREPARED BY THE FETCH SCRIPT" - local tmp - rm -Rf docs - if [ -z "$GHC_TREE" ]; then - tmp="$(mktemp -d)" - tar -xf "ghc-$ver-src.tar.xz" -C "$tmp" - GHC_TREE="$tmp/ghc-$ver" - fi - mkdocs="$GHC_TREE/distrib/mkDocs/mkDocs" - if [ ! -e "$mkdocs" ]; then - echo "Couldn't find GHC mkDocs at $mkdocs." - echo "Perhaps you need to override GHC_TREE?" - rm -Rf "$tmp" - exit 1 - fi - windows_bindist="$(ls ghc-$ver-x86_64-unknown-mingw32.tar.xz | head -n1)" - linux_bindist="$(ls ghc-$ver-x86_64-deb9-linux.tar.xz | head -n1)" - echo "Windows bindist: $windows_bindist" - echo "Linux bindist: $linux_bindist" - $ENTER_FHS_ENV $mkdocs $linux_bindist $windows_bindist - if [ -d "$tmp" ]; then rm -Rf "$tmp"; fi - - mkdir -p docs/html - tar -Jxf "$linux_bindist" - cp -R "ghc-$ver/docs/users_guide/build-html/users_guide docs/html/users_guide" - #cp -R ghc-$ver/utils/haddock/doc/haddock docs/html/haddock - rm -R "ghc-$ver" - - tar -Jxf docs/libraries.html.tar.xz -C docs/html - mv docs/index.html docs/html } function recompress() { @@ -213,7 +184,7 @@ function recompress() { needed+=( "$(basename $i .tar.xz).zip" ) done - recompress-all -l ${needed[@]} + recompress-all -j10 ${needed[@]} } function upload_docs() { ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -2,6 +2,10 @@ Version 9.10.1 ============== +The significant changes to the various parts of the compiler are listed in the +following sections. See the `migration guide +`_ on the GHC Wiki +for specific guidance on migrating programs to this release. Language ~~~~~~~~ ===================================== docs/users_guide/9.6.1-notes.rst deleted ===================================== @@ -1,267 +0,0 @@ -.. _release-9-6-1: - -Version 9.6.1 -============== - -Language -~~~~~~~~ - -- GHC is now more conservative when solving constraints that arise from - superclass expansion in terms of other constraints that also arise from - superclass expansion. - - For example: :: - - class C a - class C a => D a b - instance D a a => D a b - - When typechecking the instance, we need to also solve the constraints arising - from the superclasses of ``D``; in this case, we need ``C a``. We could obtain - evidence for this constraint by expanding the superclasses of the context, - as ``D a a`` also has a superclass context of ``C a``. - However, is it unsound to do so in general, as we might be assuming precisely - the predicate we want to prove! This can lead to programs that loop at runtime. - - When such potentially-loopy situations arise, GHC now emits a warning. - In future releases, this behaviour will no longer be supported, and the - typechecker will outright refuse to solve these constraints, emitting a - ``Could not deduce`` error. - - In practice, you should be able to fix these issues by adding the necessary - constraint to the context, e.g. for the above example: :: - - instance (C a, D a a) => D a b - -- Record updates for GADTs and other existential datatypes are now - fully supported. - - For example: :: - - data D b where - MkD :: { fld1 :: a -> a, fld2 :: a -> (), fld3 :: b } -> D b - - foo :: D b -> D b - foo d = d { fld1 = id, fld2 = const () } - - In this example, we have an existential variable ``a``, and we update - all fields whose type involves ``a`` at once, so the update is valid. - - A side-effect of this change is that GHC now rejects some record updates - involving fields whose types contain type families (these record updates - were previously erroneously accepted). - - Example: :: - - type family F a where - F Int = Char - F Float = Char - - data T b = MkT { x :: [Int], y :: [F b] } - - emptyT :: forall b. T b - emptyT = MkT [] [] - - bar :: T Int - bar = emptyT { x = [3] } - - In this example, we can't infer the type of ``emptyT`` in ``bar``: it could be - ``T Int``, but it could also be ``T Float`` because the type family ``F`` - is not injective and ``T Float ~ T Int``. Indeed, the following typechecks :: - - baz :: T Int - baz = case ( emptyT :: T Float ) of { MkT _ y -> MkT [3] y } - - This means that the type of ``emptyT`` is ambiguous in the definition - of ``bar`` above, and thus GHC rejects the record update: :: - - Couldn't match type `F b0' with `Char' - Expected: [F Int] - Actual: [F b0] - NB: ‘F’ is a non-injective type family - The type variable ‘b0’ is ambiguous - - To fix these issues, add a type signature to the expression that the - record update is applied to (``emptyT`` in the example above), or - add an injectivity annotation to the type family in the case that - the type family is in fact injective. - -- Error messages are now assigned unique error codes, of the form ``[GHC-12345]``. - -- GHC Proposal `#106 - `_ - has been implemented, introducing a new language extension - :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. - -- GHC proposal `#170 Unrestricted OverloadedLabels - `_ - has been implemented. - This extends the variety syntax for constructing labels under :extension:`OverloadedLabels`. - Examples of newly allowed syntax: - - Leading capital letters: `#Foo` equivalant to `getLabel @"Foo"` - - Numeric characters: `#1728` equivalent to `getLabel @"1728"` - - Arbitrary strings: `#"Hello, World!"` equivalent to `getLabel @"Hello, World!"` - -Compiler -~~~~~~~~ - -- The `WebAssembly backend - `_ - has been merged. This allows GHC to be built as a cross-compiler - that targets ``wasm32-wasi`` and compiles Haskell code to - self-contained WebAssembly modules that can be executed on a variety - of different runtimes. There are a few caveats to be aware of: - - - To use the WebAssembly backend, one would need to follow the - instructions on `ghc-wasm-meta - `_. The WebAssembly - backend is not included in the GHC release bindists for the time - being, nor is it supported by ``ghcup`` or ``stack`` yet. - - The WebAssembly backend is still under active development. It's - presented in this GHC version as a technology preview, bugs and - missing features are expected. - -- The JavaScript backend has been merged. GHC is now able to be built as a - cross-compiler targeting the JavaScript platform. The backend should be - considered a technology preview. As such it is not ready for use in - production, is not distributed in the GHC release bindists and requires the - user to manually build GHC as a cross-compiler. See the JavaScript backend - `wiki `_ page - on the GHC wiki for the current status, project roadmap, build instructions - and demos. - -- 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 ``:``). - -- The :ghc-flag:`-Wstar-is-type` warning is now enabled by default. - -- The 32bit x86 NCG backend will now generate inline assembly for most common 64bit - operations. This improves Int64/Word64 performance substantially on this platform. - -GHCi -~~~~ - -- GHCi will now accept any file-header pragmas it finds, such as - ``{-# OPTIONS_GHC ... #-}`` and ``{-# LANGUAGE ... #-}`` (see :ref:`pragmas`). For example, - instead of using :ghci-cmd:`:set` to enable :ghc-flag:`-Wmissing-signatures`, - you could instead write: - - .. code-block:: none - - ghci> {-# OPTIONS_GHC -Wmissing-signatures #-} - -This can be convenient when pasting large multi-line blocks of code into GHCi. - -Runtime system -~~~~~~~~~~~~~~ - -- The `Delimited continuation primops `_ - proposal has been implemented, adding native support for first-class, - delimited continuations to the RTS. For the reasons given in the proposal, - 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.Prim`` for more details. - -- The behaviour of the ``-M`` flag has been made more strict. It will now trigger - a heap overflow if the total amount of memory used by the Haskell heap exceeds the limit. - Previously only live blocks were taken into account. - This makes it more likely to trigger promptly when the heap is highly fragmented. - -- Fixed a bug that sometimes caused live sparks to be GC'ed too early either during - minor GC or major GC with workstealing disabled. See #22528. - - -``base`` library -~~~~~~~~~~~~~~~~ - -- Exceptions thrown by weak pointer finalizers can now be reported by setting - a global exception handler, using ``GHC.Weak.Finalize.setFinalizerExceptionHandler``. - The default behaviour is unchanged (exceptions are ignored and not reported). - -- GHC now provides a set of operations for introspecting on the threads of a - program, ``GHC.Conc.listThreads``, as well as operations for querying a thread's - label (:base-ref:`GHC.Conc.Sync.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 - -- Updated to `Unicode 15.0.0 `_. - -- Add standard Unicode case predicates :base-ref:`Data.Char.isUpperCase` and - :base-ref:`Data.Char.isLowerCase`. These predicates use the standard Unicode - case properties and are more intuitive than :base-ref:`Data.Char.isUpper` and - :base-ref:`Data.Char.isLower`. - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -``ghc`` library -~~~~~~~~~~~~~~~ - -- Add `Foreign.C.Types.ConstPtr` was added to encode ``const``-qualified pointer return - types in foreign declarations when using ``CApiFFI`` extension. - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - - -Included libraries ------------------- - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/9.8.1-notes.rst deleted ===================================== @@ -1,334 +0,0 @@ -.. _release-9-8-1: - -Version 9.8.1 -============= - -Language -~~~~~~~~ - -- There is a new extension :extension:`ExtendedLiterals`, which enables - sized primitive literals, e.g. ``123#Int8`` is a literal of type ``Int8#``. - See the GHC proposal `#451 `_. - Derived ``Show`` instances for datatypes containing sized literals (``Int8#``, ``Word8#``, ``Int16#`` etc.) - now use the extended literal syntax, per GHC proposal `#596 `_. - Furthermore, it is now possible to derive ``Show`` for datatypes containing - fields of types ``Int64#`` and ``Word64#``. - -- GHC Proposal `#425 - `_ - has been partially implemented. Namely, the ``@k``-binders in type declarations are now permitted:: - - type T :: forall k. k -> forall j. j -> Type - data T @k (a :: k) @(j :: Type) (b :: j) - - This feature is guarded behind :extension:`TypeAbstractions`. - -- In accordance with GHC proposal `#425 - `_ - GHC no longer implicitly quantifies over type variables that appear only in the RHS of type and - data family instances. This code will no longer work: :: - - type family F1 a :: k - type instance F1 Int = Any :: j -> j - - Instead you should write:: - - type instance F1 @(j -> j) Int = Any :: j -> j - - Or:: - - type instance forall j . F1 Int = Any :: j -> j - -- GHC proposal `#475 `_ - has been partially implemented. Namely, tuple data types, which were previously represented using a brackets-with-commas - syntax form ((), (,), (,,), and so on) have been renamed to common names of the form ``Unit``, ``Tuple2``, ``Tuple3``, - and so on, where the number after ``Tuple`` indicates its arity: :: - - data Unit = () - - data Tuple2 a b = (a,b) - data Tuple3 a b c = (a, b, c) - -- and so on, up to Tuple64 - - For consistency, we also introduce type aliases: :: - - type Tuple0 = Unit - type Tuple1 = Solo - - The renamed tuple data types and the new type aliases can be found in the ``GHC.Tuple`` module. This renaming - does not break existing code that directly uses tuple data types, but it does affect tools and libraries - that have access to the data type names, such as ``Generic`` and Template Haskell. - -Compiler -~~~~~~~~ - -- Added a new warning :ghc-flag:`-Wterm-variable-capture` that helps to make code compatible with - the future extension ``RequiredTypeArguments``. - -- Rewrite rules now support a limited form of higher order matching when a - pattern variable is applied to distinct locally bound variables. For example: :: - - forall f. foo (\x -> f x) - - Now matches: :: - - foo (\x -> x*2 + x) - -- GHC Proposal `#496 - `_ - has been implemented, allowing ``{..}`` syntax for constructors without fields, for consistency. - This is convenient for TH code generation, as you can now uniformly use record wildcards - regardless of number of fields. - -- Incoherent instance applications are no longer specialised. The previous implementation of - specialisation resulted in nondeterministic instance resolution in certain cases, breaking - the specification described in the documentation of the `INCOHERENT` pragma. See :ghc-ticket:`22448` for further details. - -- Fix a bug in TH causing excessive calls to ``setNumCapabilities`` when ``-j`` is greater than ``-N``. - See :ghc-ticket:`23049`. - -- The ``-Wno-⟨wflag⟩``, ``-Werror=⟨wflag⟩`` and ``-Wwarn=⟨wflag⟩`` options are - now defined systematically for all warning groups (for example, - ``-Wno-default``, ``-Werror=unused-binds`` and ``-Wwarn=all`` are now - accepted). See :ref:`options-sanity`. - -- ``WARNING`` pragmas may now be annotated with a category, following - `GHC proposal #541 `_, in which case they are controlled with new - ``-Wx-⟨category⟩`` flags rather than :ghc-flag:`-Wdeprecations`. - A new warning group :ghc-flag:`-Wextended-warnings` includes all such warnings - regardless of category. See :ref:`warning-deprecated-pragma`. - -- GHC is now better at disambiguating record updates in the presence of duplicate - record fields. The following program is now accepted :: - - {-# LANGUAGE DuplicateRecordFields #-} - - data R = MkR1 { foo :: Int } - | MkR2 { bar :: Int } - - data S = MkS { foo :: Int, bar :: Int } - - blah x = x { foo = 5, bar = 6 } - - The point is that only the type S has a constructor with both fields "foo" - and "bar", so this record update is unambiguous. - -- Data types with ``deriving`` clauses now reject inferred instance contexts - that mention ``TypeError`` constraints (see :ref:`custom-errors`), such as - this one: :: - - newtype Foo = Foo Int - - class Bar a where - bar :: a - - instance (TypeError (Text "Boo")) => Bar Foo where - bar = undefined - - newtype Baz = Baz Foo - deriving Bar - - Here, the derived ``Bar`` instance for ``Baz`` would look like this: :: - - instance TypeError (Text "Boo") => Bar Baz - - While GHC would accept this before, GHC 9.8 now rejects it, emitting "``Boo``" - in the resulting error message. If you really want to derive this instance and - defer the error to sites where the instance is used, you must do so manually - with :extension:`StandaloneDeriving`, e.g. :: - - deriving instance TypeError (Text "Boo") => Bar Baz - -- GHC Proposal `#540 `_ has been implemented. - This adds the `-jsem`:ghc-flag: flag, which instructs GHC to act as a jobserver client. - This enables multiple GHC processes running at once to share system resources - with each other, communicating via the system semaphore specified by - the flag argument. - -- GHC Proposal `#433 - `_ - has been implemented. This adds the class ``Unsatisfiable :: ErrorMessage -> Constraint`` - to the ``GHC.TypeError`` module. Constraints of the form ``Unsatisfiable msg`` - provide a mechanism for custom type errors that reports the errors in a more - predictable behaviour than ``TypeError``, as these constraints are - handled purely during constraint solving. - - For example: :: - - instance Unsatisfiable (Text "There is no Eq instance for functions") => Eq (a -> b) where - (==) = unsatisfiable - - This allows errors to be reported when users use the instance, even when - type errors are being deferred. - -- GHC is now deals "insoluble Givens" in a consistent way. For example: :: - - k :: (Int ~ Bool) => Int -> Bool - k x = x - - GHC used to accept the contradictory ``Int~Bool`` in the type signature, but reject the ``Int~Bool`` constraint that arises from typechecking the definition itself. Now it accepts both. More details in `GHC ticket #23413 `_, which gives examples of the previous inconsistency. GHC now implements the "PermissivePlan" described in that ticket. - -- The `-ddump-spec` flag has been split into `-ddump-spec` and - `-ddump-spec-constr`, allowing only output from the typeclass specialiser or - `SpecConstr` to be seen if desired. - -- The compiler may now be configured to compress the debugging information - included in :ghc-flag:`-finfo-table-map` enabled binaries. To do so, one must - build GHC from source (see - `here` for directions) - and supply the ``--enable-ipe-data-compression`` flag to the ``configure`` - script. **Note**: This feature requires that the machine building GHC has - `libzstd `_ version 1.4.0 or greater - installed. The compression library `libzstd` may optionally be statically - linked in the resulting compiler (on non-darwin machines) using the - ``--enable-static-libzstd`` configure flag. - - In a test compiling GHC itself, the size of the :ghc-flag:`-finfo-table-map` - enabled build results was reduced by over 20% when compression was enabled. - -- GHC Proposal `#134 - `_ - has been implemented. This makes it possible to deprecate certain names exported from a module, without deprecating - the name itself. You can check the full specification of the feature at :ref:`warning-deprecated-pragma`. - - For example :: - - module X ( - {-# WARNING "do not use that constructor" D(D1), - D(D2) - ) - data D = D1 | D2 - - This allows for changing the structure of a library without immediately breaking user code, - but instead being able to warn the user that a change in the library interface - will occur in the future. - -- Guard polymorphic specialisation behind the flag :ghc-flag:`-fpolymorphic-specialisation`. - This optimisation has led to a number of incorrect runtime result bugs, so we are disabling it - by default for now whilst we consider more carefully an appropriate fix. - (See :ghc-ticket:`23469`, :ghc-ticket:`23109`, :ghc-ticket:`21229`, :ghc-ticket:`23445`) - -- The warning about incompatible command line flags can now be controlled with the - :ghc-flag:`-Winconsistent-flags`. In particular this allows you to silence a warning - when using optimisation flags with :ghc-flag:`--interactive` mode. - -GHCi -~~~~ - -- The deprecated `:ctags` and `:etags` GHCi commands have been removed. See this `wiki page `_ if you want to add a macro to recover similar functionality. - -Runtime system -~~~~~~~~~~~~~~ - -- On POSIX systems that support timerfd, RTS shutdown no longer has to wait for - the next RTS 'tick' to occur before continuing the shutdown process. See :ghc-ticket:`22692`. - -``base`` library -~~~~~~~~~~~~~~~~ - -- ``Data.Tuple`` now exports ``getSolo :: Solo a -> a``. - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -- Primitive pointer comparison functions are now levity-polymorphic, e.g. :: - - sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# - - This change affects the following functions: - - - ``sameArray#``, ``sameMutableArray#``, - - ``sameSmallArray#``, ``sameSmallMutableArray#``, - - ``sameMutVar#``, ``sameTVar#``, ``sameMVar#`` - - ``sameIOPort#``, ``eqStableName#``. - -- New primops for fused multiply-add operations. These primops combine a - multiplication and an addition, compiling to a single instruction when - the ``-mfma`` flag is enabled and the architecture supports it. - - The new primops are ``fmaddFloat#, fmsubFloat#, fnmaddFloat#, fnmsubFloat# :: Float# -> Float# -> Float# -> Float#`` - and ``fmaddDouble#, fmsubDouble#, fnmaddDouble#, fnmsubDouble# :: Double# -> Double# -> Double# -> Double#``. - - These implement the following operations, while performing one single - rounding at the end, leading to a more accurate result: - - - ``fmaddFloat# x y z``, ``fmaddDouble# x y z`` compute ``x * y + z``. - - ``fmsubFloat# x y z``, ``fmsubDouble# x y z`` compute ``x * y - z``. - - ``fnmaddFloat# x y z``, ``fnmaddDouble# x y z`` compute ``- x * y + z``. - - ``fnmsubFloat# x y z``, ``fnmsubDouble# x y z`` compute ``- x * y - z``. - - Warning: on unsupported architectures, the software emulation provided by - the fallback to the C standard library is not guaranteed to be IEEE-compliant. - -``ghc`` library -~~~~~~~~~~~~~~~ - -- The ``RecordUpd`` constructor of ``HsExpr`` now takes an ``HsRecUpdFields`` - instead of ``Either [LHsRecUpdField p] [LHsRecUpdProj p]``. - Instead of ``Left ..``, use the constructor ``RegularRecUpdFields``, and instead - of ``Right ..``, use the constructor ``OverloadedRecUpdFields``. - -- The ``loadWithCache`` function now takes an extra argument which allows API users - to embed GHC diagnostics in their own diagnostic type before they are printed. - This allows how messages are rendered and explained to users to be modified. - We use this functionality in GHCi to modify how some messages are displayed. - -- The extensions fields of constructors of ``IE`` now take ``Maybe (WarningTxt p)`` - in ``GhcPs`` and ``GhcRn`` variants of the Syntax Tree. - This represents the warning assigned to a certain export item, - which is used for deprecated exports (see :ref:`warning-deprecated-pragma`). - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - -``template-haskell`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Record fields now belong to separate ``NameSpace``s, keyed by the parent of - the record field. This is the name of the first constructor of the parent type, - even if this constructor does not have the field in question. - This change enables TemplateHaskell support for ``DuplicateRecordFields``. - -Included libraries ------------------- - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9f85900d1d851adaa91215b21d362eed95387b5d...cf814fe982f42483c672802ce905350d99a85a35 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9f85900d1d851adaa91215b21d362eed95387b5d...cf814fe982f42483c672802ce905350d99a85a35 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 15:49:47 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 21 Mar 2024 11:49:47 -0400 Subject: [Git][ghc/ghc][ghc-9.10] 2 commits: rel_env/recompress_all: Decompress xz before recompressing Message-ID: <65fc571b87886_1068ad4e893d414096@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 548da279 by Ben Gamari at 2024-03-14T09:13:15-04:00 rel_env/recompress_all: Decompress xz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - cf814fe9 by Teo Camarasu at 2024-03-21T11:44:15-04:00 Add preamble to 9.10 release notes Resolves #24567 - - - - - 2 changed files: - .gitlab/rel_eng/recompress-all - docs/users_guide/9.10.1-notes.rst Changes: ===================================== .gitlab/rel_eng/recompress-all ===================================== @@ -9,15 +9,15 @@ usage : %.gz : %.xz echo "[xz->gz] $< to $@..." - xz -c $< | gzip -c > $@ + xz -cd $< | gzip -c > $@ %.bz2 : %.xz echo "[xz->bz2] $< to $@..." - xz -c $< | bzip2 -c > $@ + xz -cd $< | bzip2 -c > $@ %.lz : %.xz echo "[xz->lz] $< to $@..." - xz -c $< | lzip -c > $@ + xz -cd $< | lzip -c > $@ %.zip : %.tar.xz echo "[tarxz->zip] $< to $@..." ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -2,6 +2,10 @@ Version 9.10.1 ============== +The significant changes to the various parts of the compiler are listed in the +following sections. See the `migration guide +`_ on the GHC Wiki +for specific guidance on migrating programs to this release. Language ~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b55e0ef930f93c13e0f23ed7e129247fb06af9d2...cf814fe982f42483c672802ce905350d99a85a35 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b55e0ef930f93c13e0f23ed7e129247fb06af9d2...cf814fe982f42483c672802ce905350d99a85a35 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 16:20:42 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 21 Mar 2024 12:20:42 -0400 Subject: [Git][ghc/ghc][wip/T24553] 3 commits: docs: Remove mention of non-existent Ord instance for Complex Message-ID: <65fc5e5a61400_1068ad5eb36381478e9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - f072fdcb by Simon Peyton Jones at 2024-03-21T16:20:22+00:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 17 changed files: - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - libraries/base/src/Data/Complex.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -228,7 +228,7 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = andEq TEQX e = hasCast e andEq TEQ e = e - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare go (D _ (TyConApp tc1 [])) (D _ (TyConApp tc2 [])) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -12,8 +12,9 @@ module GHC.Core.TyCo.Compare ( nonDetCmpTypesX, nonDetCmpTc, eqVarBndrs, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTyConApps, + mayLookIdentical, -- * Visiblity comparision eqForAllVis, cmpForAllVis @@ -22,7 +23,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -129,52 +131,114 @@ Cabal. See #19226. -} +mayLookIdentical :: Type -> Type -> Bool +-- | Returns True if the /visible/ part of the types +-- might look equal, even if they are really unequal (in the invisible bits) +-- Always safe to return True -- this affects error messages only +mayLookIdentical orig_ty1 orig_ty2 + = go orig_env orig_ty1 orig_ty2 + where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + + go :: RnEnv2 -> Type -> Type -> Bool + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True + + go env t1 t2 | Just t1' <- coreView t1 = go env t1' t2 + go env t1 t2 | Just t2' <- coreView t2 = go env t1 t2' + + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True + + go env (ForAllTy (Bndr tv1 vis1) ty1) + (ForAllTy (Bndr tv2 vis2) ty2) + = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] + && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- Visible stuff only: ignore kinds of binders + + -- If we have (forall (r::RunTimeRep). ty1 ~ blah) then respond + -- with True. Reason: the type pretty-printer defaults RuntimeRep + -- foralls (see Ghc.Iface.Type.hideNonStandardTypes). That can make, + -- say (forall r. TYPE r -> Type) into (Type -> Type), so it looks the + -- same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of mayLookIdentical) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | isDefaultableBndr b = True + go _ _ (ForAllTy b _) | isDefaultableBndr b = True + + go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) + = go env arg1 arg2 && go env res1 res2 && go env w1 w2 + -- Visible stuff only: ignore agg kinds + + -- See Note [Equality on AppTys] in GHC.Core.Type + go env (AppTy s1 t1) ty2 + | Just (s2, t2) <- tcSplitAppTyNoView_maybe ty2 + = go env s1 s2 && go env t1 t2 + go env ty1 (AppTy s2 t2) + | Just (s1, t1) <- tcSplitAppTyNoView_maybe ty1 + = go env s1 s2 && go env t1 t2 + + go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) + = tc1 == tc2 && gos env (tyConBinders tc1) ts1 ts2 + + go _ _ _ = False + + gos :: RnEnv2 -> [TyConBinder] -> [Type] -> [Type] -> Bool + gos _ _ [] [] = True + gos env bs (t1:ts1) (t2:ts2) + | (invisible, bs') <- case bs of + [] -> (False, []) + (b:bs) -> (isInvisibleTyConBinder b, bs) + = (invisible || go env t1 t2) && gos env bs' ts1 ts2 + + gos _ _ _ _ = False + + -- | Type equality comparing both visible and invisible arguments and expanding -- type synonyms. tcEqTypeNoSyns :: Type -> Type -> Bool -tcEqTypeNoSyns ta tb = tc_eq_type False False ta tb - --- | Like 'tcEqType', but returns True if the /visible/ part of the types --- are equal, even if they are really unequal (in the invisible bits) -tcEqTypeVis :: Type -> Type -> Bool -tcEqTypeVis ty1 ty2 = tc_eq_type False True ty1 ty2 +tcEqTypeNoSyns ta tb = tc_eq_type False ta tb -- | Like 'pickyEqTypeVis', but returns a Bool for convenience pickyEqType :: Type -> Type -> Bool -- Check when two types _look_ the same, _including_ synonyms. -- So (pickyEqType String [Char]) returns False -- This ignores kinds and coercions, because this is used only for printing. -pickyEqType ty1 ty2 = tc_eq_type True False ty1 ty2 +pickyEqType ty1 ty2 = tc_eq_type True ty1 ty2 -- | Real worker for 'tcEqType'. No kind check! tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms - -> Bool -- ^ True <=> compare visible args only -> Type -> Type -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type -tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +tc_eq_type keep_syns orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + go :: RnEnv2 -> Type -> Type -> Bool - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. - go _ (TyConApp tc1 []) (TyConApp tc2 []) - | tc1 == tc2 - = True + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True go env t1 t2 | not keep_syns, Just t1' <- coreView t1 = go env t1' t2 go env t1 t2 | not keep_syns, Just t2' <- coreView t2 = go env t1 t2' - go env (TyVarTy tv1) (TyVarTy tv2) - = rnOccL env tv1 == rnOccR env tv2 - - go _ (LitTy lit1) (LitTy lit2) - = lit1 == lit2 + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] - && (vis_only || go env (varType tv1) (varType tv2)) + && go env (varType tv1) (varType tv2) && go (rnBndr2 env tv1 tv2) ty1 ty2 -- Make sure we handle all FunTy cases since falling through to the @@ -183,11 +247,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- See Note [Equality on FunTys] in GHC.Core.TyCo.Rep: we must check -- kinds here go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) - = kinds_eq && go env arg1 arg2 && go env res1 res2 && go env w1 w2 - where - kinds_eq | vis_only = True - | otherwise = go env (typeKind arg1) (typeKind arg2) && - go env (typeKind res1) (typeKind res2) + = go env (typeKind arg1) (typeKind arg2) && + go env (typeKind res1) (typeKind res2) && + go env arg1 arg2 && go env res1 res2 && go env w1 w2 -- See Note [Equality on AppTys] in GHC.Core.Type go env (AppTy s1 t1) ty2 @@ -198,32 +260,24 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go env s1 s2 && go env t1 t2 go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) - = tc1 == tc2 && gos env (tc_vis tc1) ts1 ts2 - - go env (CastTy t1 _) t2 = go env t1 t2 - go env t1 (CastTy t2 _) = go env t1 t2 - go _ (CoercionTy {}) (CoercionTy {}) = True + = tc1 == tc2 && gos env ts1 ts2 go _ _ _ = False - gos _ _ [] [] = True - gos env (ig:igs) (t1:ts1) (t2:ts2) = (ig || go env t1 t2) - && gos env igs ts1 ts2 - gos _ _ _ _ = False + gos _ [] [] = True + gos env (t1:ts1) (t2:ts2) = go env t1 t2 && gos env ts1 ts2 + gos _ _ _ = False - tc_vis :: TyCon -> [Bool] -- True for the fields we should ignore - tc_vis tc | vis_only = inviss ++ repeat False -- Ignore invisibles - | otherwise = repeat False -- Ignore nothing - -- The repeat False is necessary because tycons - -- can legitimately be oversaturated - where - bndrs = tyConBinders tc - inviss = map isInvisibleTyConBinder bndrs - - orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] - -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function @@ -543,7 +597,7 @@ nonDetCmpTypeX env orig_t1 orig_t2 = -- Returns both the resulting ordering relation between -- the two types and whether either contains a cast. go :: RnEnv2 -> Type -> Type -> TypeOrdering - -- See Note [Comparing nullary type synonyms]. + -- See Note [Comparing nullary type synonyms] go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1066,7 +1066,7 @@ unify_ty :: UMEnv -- Respects newtypes, PredTypes -- See Note [Computing equality on types] in GHC.Core.Type unify_ty _env (TyConApp tc1 []) (TyConApp tc2 []) _kco - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare | tc1 == tc2 = return () ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,60 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = mayLookIdentical act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = mayLookIdentical ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when we find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by + `GHC.Core.TyCo.Compare.mayLookIdentical` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6089,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6172,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6434,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6458,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -534,6 +534,9 @@ pat_to_type_pat (SigPat _ pat sig_ty) pat_to_type_pat (ParPat _ pat) = do { HsTP x t <- pat_to_type_pat (unLoc pat) ; return (HsTP x (noLocA (HsParTy noAnn t))) } +pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { HsTP x t <- pat_to_type_pat pat + ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } pat_to_type_pat pat = -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -311,7 +311,7 @@ can_eq_nc -> Type -> Type -- RHS, after and before type-synonym expansion, resp -> TcS (StopOrContinue (Either IrredCt EqCt)) --- See Note [Comparing nullary type synonyms] in GHC.Core.Type. +-- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare can_eq_nc _flat _rdr_env _envs ev eq_rel ty1@(TyConApp tc1 []) _ps_ty1 (TyConApp tc2 []) _ps_ty2 | tc1 == tc2 = canEqReflexive ev eq_rel ty1 ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -95,7 +95,7 @@ module GHC.Tc.Utils.TcType ( -- Re-exported from GHC.Core.TyCo.Compare -- mainly just for back-compat reasons eqType, eqTypes, nonDetCmpType, nonDetCmpTypes, eqTypeX, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, mayLookIdentical, tcEqTyConApps, eqForAllVis, eqVarBndrs, --------------------------------- @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== libraries/base/src/Data/Complex.hs ===================================== @@ -62,7 +62,7 @@ infix 6 :+ -- it holds that @z == 'abs' z * 'signum' z at . -- -- Note that `Complex`'s instances inherit the deficiencies from the type --- parameter's. For example, @Complex Float@'s 'Ord' instance has similar +-- parameter's. For example, @Complex Float@'s 'Eq' instance has similar -- problems to `Float`'s. -- -- As can be seen in the examples, the 'Foldable' ===================================== testsuite/tests/th/T24571.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell, RequiredTypeArguments #-} +module T24571 where + +g :: forall a -> () +g $([p| a |]) = () ===================================== testsuite/tests/th/all.T ===================================== @@ -605,3 +605,4 @@ test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) test('T24559', normal, compile, ['']) +test('T24571', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c4740b22cd166bbede9683c1d7be01c096cb311...f072fdcb4d6aa128bf4fd262b4523854ec075e25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c4740b22cd166bbede9683c1d7be01c096cb311...f072fdcb4d6aa128bf4fd262b4523854ec075e25 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 16:28:36 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Thu, 21 Mar 2024 12:28:36 -0400 Subject: [Git][ghc/ghc][wip/T22859] 3 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65fc60348095_1068ad6190c9814881d@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - b76643e0 by Teo Camarasu at 2024-03-21T16:28:06+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 29 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/PrimOps.cmm - rts/RtsSymbols.c - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h - rts/include/rts/storage/TSO.h - rts/include/stg/MiscClosures.h - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Test24533.hs - testsuite/tests/printer/Test24533.stdout - + testsuite/tests/rts/T22859.hs - + testsuite/tests/rts/T22859.stderr - testsuite/tests/rts/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3952,6 +3952,15 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp effect = ReadWriteEffect out_of_line = True +primop SetOtherThreadAllocationCounter "setOtherThreadAllocationCounter#" GenPrimOp + Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld + { Sets the allocation counter for the another thread to the given value. + This doesn't take allocations into the current nursery chunk into account. + Therefore it is only accurate if the other thread is not currently running. } + with + effect = ReadWriteEffect + out_of_line = True + primtype StackSnapshot# { Haskell representation of a @StgStack*@ that was created (cloned) with a function in "GHC.Stack.CloneStack". Please check the ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -361,12 +361,51 @@ data IfaceTyConInfo -- Used only to guide pretty-printing , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) --- This smart constructor allows sharing of the two most common --- cases. See #19194 +-- | This smart constructor allows sharing of the two most common +-- cases. See Note [Sharing IfaceTyConInfo] mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo -mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = IfaceTyConInfo IsPromoted IfaceNormalTyCon -mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = IfaceTyConInfo NotPromoted IfaceNormalTyCon -mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort +mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo +mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo +mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +{-# NOINLINE promotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +promotedNormalTyConInfo :: IfaceTyConInfo +promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + +{-# NOINLINE notPromotedNormalTyConInfo #-} +-- | See Note [Sharing IfaceTyConInfo] +notPromotedNormalTyConInfo :: IfaceTyConInfo +notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + +{- +Note [Sharing IfaceTyConInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +'IfaceTyConInfo' occurs an awful lot in 'ModIface', see #19194 for an example. +But almost all of them are + + IfaceTyConInfo IsPromoted IfaceNormalTyCon + IfaceTyConInfo NotPromoted IfaceNormalTyCon. + +The smart constructor `mkIfaceTyConInfo` arranges to share these instances, +thus: + + promotedNormalTyConInfo = IfaceTyConInfo IsPromoted IfaceNormalTyCon + notPromotedNormalTyConInfo = IfaceTyConInfo NotPromoted IfaceNormalTyCon + + mkIfaceTyConInfo IsPromoted IfaceNormalTyCon = promotedNormalTyConInfo + mkIfaceTyConInfo NotPromoted IfaceNormalTyCon = notPromotedNormalTyConInfo + mkIfaceTyConInfo prom sort = IfaceTyConInfo prom sort + +But ALAS, the (nested) CPR transform can lose this sharing, completely +negating the effect of `mkIfaceTyConInfo`: see #24530 and #19326. + +Sticking-plaster solution: add a NOINLINE pragma to those top-level constants. +When we fix the CPR bug we can remove the NOINLINE pragmas. + +This one change leads to an 15% reduction in residency for GHC when embedding +'mi_extra_decls': see !12222. +-} data IfaceMCoercion = IfaceMRefl ===================================== compiler/GHC/Parser.y ===================================== @@ -1237,12 +1237,12 @@ topdecl_cs : topdecl {% commentsPA $1 } ----------------------------------------------------------------------------- topdecl :: { LHsDecl GhcPs } - : cl_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | ty_decl { sL1a $1 (TyClD noExtField (unLoc $1)) } - | standalone_kind_sig { sL1a $1 (KindSigD noExtField (unLoc $1)) } - | inst_decl { sL1a $1 (InstD noExtField (unLoc $1)) } - | stand_alone_deriving { sL1a $1 (DerivD noExtField (unLoc $1)) } - | role_annot { sL1a $1 (RoleAnnotD noExtField (unLoc $1)) } + : cl_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | ty_decl { L (getLoc $1) (TyClD noExtField (unLoc $1)) } + | standalone_kind_sig { L (getLoc $1) (KindSigD noExtField (unLoc $1)) } + | inst_decl { L (getLoc $1) (InstD noExtField (unLoc $1)) } + | stand_alone_deriving { L (getLoc $1) (DerivD noExtField (unLoc $1)) } + | role_annot { L (getLoc $1) (RoleAnnotD noExtField (unLoc $1)) } | 'default' '(' comma_types0 ')' {% amsA' (sLL $1 $> (DefD noExtField (DefaultDecl [mj AnnDefault $1,mop $2,mcp $4] $3))) } | 'foreign' fdecl {% amsA' (sLL $1 $> ((snd $ unLoc $2) (mj AnnForeign $1:(fst $ unLoc $2)))) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -943,11 +943,13 @@ checkTyVars pp_what equals_or_where tc tparms -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) - chkParens ops cps bvis (L l (HsParTy _ ty)) + chkParens ops cps bvis (L l (HsParTy _ (L lt ty))) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + lcs = epAnnComments l + lt' = setCommentsEpAnn lt lcs in - chkParens (o:ops) (c:cps) bvis ty + chkParens (o:ops) (c:cps) bvis (L lt' ty) chkParens ops cps bvis ty = chk ops cps bvis ty -- Check that the name space is correct! ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1746,6 +1746,7 @@ emitPrimOp cfg primop = TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + SetOtherThreadAllocationCounter -> alwaysExternal KeepAliveOp -> alwaysExternal CastWord32ToFloatOp -> alwaysExternal CastWord64ToDoubleOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1167,6 +1167,7 @@ genPrim prof bound ty op = case op of WhereFromOp -> unhandledPrimop op -- should be easily implementable with o.f.n SetThreadAllocationCounter -> unhandledPrimop op + SetOtherThreadAllocationCounter -> unhandledPrimop op ------------------------------- Vector ----------------------------------------- -- For now, vectors are unsupported on the JS backend. Simply put, they do not ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,10 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.Base +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.Foreign.C.Types +import GHC.Internal.IO (unsafePerformIO) +import GHC.Internal.Int (Int64(..)) + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler + +-- | Retrieves the allocation counter for the another thread. +foreign import prim "stg_getOtherThreadAllocationCounterzh" getOtherThreadAllocationCounter# + :: ThreadId# + -> State# RealWorld + -> (# State# RealWorld, Int64# #) + +getAllocationCounterFor :: ThreadId -> IO Int64 +getAllocationCounterFor (ThreadId t#) = IO $ \s -> + case getOtherThreadAllocationCounter# t# s of (# s', i# #) -> (# s', I64# i# #) + +setAllocationCounterFor :: Int64 -> ThreadId -> IO () +setAllocationCounterFor (I64# i#) (ThreadId t#) = IO $ \s -> + case setOtherThreadAllocationCounter# i# t# s of s' -> (# s', () #) + + +-- | Enable allocation limit processing the thread @t at . +enableAllocationLimitFor :: ThreadId -> IO () +enableAllocationLimitFor (ThreadId t) = do + rts_enableThreadAllocationLimit t + +-- | Disable allocation limit processing the thread @t at . +disableAllocationLimitFor :: ThreadId -> IO () +disableAllocationLimitFor (ThreadId t) = do + rts_disableThreadAllocationLimit t + +foreign import ccall unsafe "rts_enableThreadAllocationLimit" + rts_enableThreadAllocationLimit :: ThreadId# -> IO () + +foreign import ccall unsafe "rts_disableThreadAllocationLimit" + rts_disableThreadAllocationLimit :: ThreadId# -> IO () ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/PrimOps.cmm ===================================== @@ -2923,6 +2923,11 @@ stg_getThreadAllocationCounterzh () return (StgTSO_alloc_limit(CurrentTSO) - TO_I64(offset)); } +stg_getOtherThreadAllocationCounterzh ( gcptr t ) +{ + return (StgTSO_alloc_limit(t)); +} + stg_setThreadAllocationCounterzh ( I64 counter ) { // Allocation in the current block will be subtracted by @@ -2935,6 +2940,12 @@ stg_setThreadAllocationCounterzh ( I64 counter ) return (); } +stg_setOtherThreadAllocationCounterzh ( I64 counter, gcptr t ) +{ + StgTSO_alloc_limit(t) = counter; + return (); +} + #define KEEP_ALIVE_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,c) \ w_ info_ptr, \ ===================================== rts/RtsSymbols.c ===================================== @@ -914,7 +914,9 @@ extern char **environ; SymI_HasDataProto(stg_traceMarkerzh) \ SymI_HasDataProto(stg_traceBinaryEventzh) \ SymI_HasDataProto(stg_getThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_getOtherThreadAllocationCounterzh) \ SymI_HasDataProto(stg_setThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_setOtherThreadAllocationCounterzh) \ SymI_HasProto(getMonotonicNSec) \ SymI_HasProto(lockFile) \ SymI_HasProto(unlockFile) \ ===================================== rts/Schedule.c ===================================== @@ -41,6 +41,7 @@ #include "Threads.h" #include "Timer.h" #include "ThreadPaused.h" +#include "ThreadLabels.h" #include "Messages.h" #include "StablePtr.h" #include "StableName.h" @@ -94,6 +95,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1113,19 +1118,36 @@ schedulePostRunThread (Capability *cap, StgTSO *t) } } - // - // If the current thread's allocation limit has run out, send it - // the AllocationLimitExceeded exception. + // Handle the current thread's allocation limit running out, if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Throw the AllocationLimitExceeded exception. + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + setThreadLabel(cap, hookThread, "allocation limit handler thread"); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3349,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ ===================================== rts/include/rts/storage/TSO.h ===================================== @@ -157,9 +157,10 @@ typedef struct StgTSO_ { /* * The allocation limit for this thread, which is updated as the * thread allocates. If the value drops below zero, and - * TSO_ALLOC_LIMIT is set in flags, we raise an exception in the - * thread, and give the thread a little more space to handle the - * exception before we raise the exception again. + * TSO_ALLOC_LIMIT is set in flags, then a handler is triggerd. + * Either we raise an exception in the thread, and give the thread + * a little more space to handle the exception before we raise the + * exception again; or we run a user defined handler. * * This is an integer, because we might update it in a place where * it isn't convenient to raise the exception, so we want it to ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -588,7 +588,9 @@ RTS_FUN_DECL(stg_traceEventzh); RTS_FUN_DECL(stg_traceBinaryEventzh); RTS_FUN_DECL(stg_traceMarkerzh); RTS_FUN_DECL(stg_getThreadAllocationCounterzh); +RTS_FUN_DECL(stg_getOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_setThreadAllocationCounterzh); +RTS_FUN_DECL(stg_setOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_castWord64ToDoublezh); RTS_FUN_DECL(stg_castDoubleToWord64zh); ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6689,6 +6690,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6658,6 +6659,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4588,6 +4588,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6838,6 +6839,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6689,6 +6690,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -8638,6 +8638,16 @@ module Prelude.Experimental where data Unit# = ... getSolo :: forall a. Solo a -> a +module System.Mem.Experimental where + -- Safety: None + type AllocationLimitKillBehaviour :: * + data AllocationLimitKillBehaviour = KillOnAllocationLimit | DontKillOnAllocationLimit + disableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + enableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + getAllocationCounterFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO GHC.Internal.Int.Int64 + setAllocationCounterFor :: GHC.Internal.Int.Int64 -> GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> GHC.Internal.Maybe.Maybe (GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO ()) -> GHC.Types.IO () + -- Instances: instance GHC.Classes.Eq GHC.Types.Bool -- Defined in ‘GHC.Classes’ ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -212,7 +212,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:9:11 }) (EpaSpan { DumpSemis.hs:9:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -498,7 +501,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:14:11 }) (EpaSpan { DumpSemis.hs:14:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L @@ -747,7 +753,10 @@ (EpaComments [])) (HsTupleTy - (AnnParen AnnParens (EpaSpan { DumpSemis.hs:21:11 }) (EpaSpan { DumpSemis.hs:21:12 })) + (AnnParen + AnnParens + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) (HsBoxedOrConstraintTuple) [])))))))))) ,(L ===================================== testsuite/tests/printer/Test24533.hs ===================================== @@ -6,3 +6,9 @@ instance Read b ) => Read (a, b) + +class Foo (a :: Type {- Weird -}) + +instance Eq Foo where + -- Weird + Foo == Foo = True ===================================== testsuite/tests/printer/Test24533.stdout ===================================== @@ -13,8 +13,8 @@ [] (Just ((,) - { Test24533.hs:9:1 } - { Test24533.hs:8:13 }))) + { Test24533.hs:15:1 } + { Test24533.hs:14:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -273,6 +273,323 @@ [] [] [] + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:10:1-33 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.hs:10:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.hs:10:11-33 }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:10:22-32 }) + (EpaComment + (EpaBlockComment + "{- Weird -}") + { Test24533.hs:10:17-20 }))])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.hs:10:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.hs:10:33 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.hs:10:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:10:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:(12,1)-(14,19) }) + (AnnListItem + []) + (EpaComments + [(L + (EpaSpan + { Test24533.hs:13:3-10 }) + (EpaComment + (EpaLineComment + "-- Weird") + { Test24533.hs:12:17-21 }))])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.hs:12:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.hs:12:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.hs:12:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.hs:14:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.hs:14:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.hs:14:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.hs:14:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] (Nothing)))))])) @@ -291,8 +608,8 @@ [] (Just ((,) - { Test24533.ppr.hs:3:41 } - { Test24533.ppr.hs:3:40 }))) + { Test24533.ppr.hs:6:20 } + { Test24533.ppr.hs:6:16-19 }))) (EpaCommentsBalanced [(L (EpaSpan @@ -545,4 +862,311 @@ [] [] [] - (Nothing)))))])) \ No newline at end of file + (Nothing))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:1-21 }) + (AnnListItem + []) + (EpaComments + [])) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + [(AddEpAnn AnnClass (EpaSpan { Test24533.ppr.hs:4:1-5 }))] + (EpNoLayout) + (NoAnnSortKey)) + (Nothing) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:7-9 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (HsQTvs + (NoExtField) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:11-21 }) + (AnnListItem + []) + (EpaComments + [])) + (KindedTyVar + [(AddEpAnn AnnOpenP (EpaSpan { Test24533.ppr.hs:4:11 })) + ,(AddEpAnn AnnCloseP (EpaSpan { Test24533.ppr.hs:4:21 })) + ,(AddEpAnn AnnDcolon (EpaSpan { Test24533.ppr.hs:4:14-15 }))] + (HsBndrRequired + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: a})) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:4:17-20 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:(5,1)-(6,19) }) + (AnnListItem + []) + (EpaComments + [])) + (InstD + (NoExtField) + (ClsInstD + (NoExtField) + (ClsInstDecl + ((,,) + (Nothing) + [(AddEpAnn AnnInstance (EpaSpan { Test24533.ppr.hs:5:1-8 })) + ,(AddEpAnn AnnWhere (EpaSpan { Test24533.ppr.hs:5:17-21 }))] + (NoAnnSortKey)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsAppTy + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:10-11 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Eq})))) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (AnnListItem + []) + (EpaComments + [])) + (HsTyVar + [] + (NotPromoted) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:5:13-15 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})))))))) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (FunBind + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (MG + (FromSource) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-19 }) + (AnnListItem + []) + (EpaComments + [])) + (Match + [] + (FunRhs + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:7-8 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: ==})) + (Infix) + (NoSrcStrict)) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:3-5 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + []))))) + ,(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (VisPat + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (AnnListItem + []) + (EpaComments + [])) + (ConPat + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:10-12 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: Foo})) + (PrefixCon + [] + [])))))] + (GRHSs + (EpaComments + []) + [(L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (NoEpAnns) + (EpaComments + [])) + (GRHS + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:14-19 }) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { Test24533.ppr.hs:6:14 }))) + (EpaComments + [])) + [] + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (AnnListItem + []) + (EpaComments + [])) + (HsVar + (NoExtField) + (L + (EpAnn + (EpaSpan { Test24533.ppr.hs:6:16-19 }) + (NameAnnTrailing + []) + (EpaComments + [])) + (Unqual + {OccName: True}))))))] + (EmptyLocalBinds + (NoExtField)))))]))))]} + [] + [] + [] + (Nothing)))))])) + + ===================================== testsuite/tests/rts/T22859.hs ===================================== @@ -0,0 +1,71 @@ +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +import Control.Exception +import Control.Exception.Backtrace +import Control.Concurrent +import Control.Concurrent.MVar +import System.Mem +import System.Mem.Experimental +import GHC.IO (IO (..)) +import GHC.Exts +import System.IO + +-- | Just do some work and hPutStrLn stderr to stdout to indicate that we are making progress +worker :: IO () +worker = loop [] 2 + where + loop !m !n + | n > 30 = hPutStrLn stderr . show $ length m + | otherwise = do + let x = show n + hPutStrLn stderr x + -- just to bulk out the allocations + IO (\s -> case newByteArray# 900000# s of (# s', arr# #) -> (# s', () #)) + yield + loop (x:m) (n + 1) + +main :: IO () +main = do + done <- newMVar () -- we use this lock to wait for the worker to finish + started <- newEmptyMVar + let runWorker = do + forkIO . withMVar done $ \_ -> flip onException (hPutStrLn stderr "worker died") $ do + hPutStrLn stderr "worker starting" + putMVar started () + setAllocationCounter 1_000_000 + enableAllocationLimit + worker + hPutStrLn stderr "worker done" + takeMVar started + readMVar done + hFlush stderr + threadDelay 1000 + -- default behaviour: + -- kill it after the limit is exceeded + hPutStrLn stderr "default behaviour" + runWorker + hPutStrLn stderr "just log once on the hook being triggered" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit (Just $ \_ -> hPutStrLn stderr "allocation limit triggered 1") + runWorker + hPutStrLn stderr "just log on the hook being triggered" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit . Just $ \tid -> do + hPutStrLn stderr "allocation limit triggered 2" + -- re-enable the hook + setAllocationCounterFor 1_000_000 tid + enableAllocationLimitFor tid + runWorker + hPutStrLn stderr "kill from the hook" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit . Just $ \tId -> throwTo tId AllocationLimitExceeded + runWorker + -- not super helpful, but let's test it anyway + hPutStrLn stderr "do nothing" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit Nothing + runWorker + -- this is possible to handle using an exception handler instead. + hPutStrLn stderr "kill and log" + setGlobalAllocationLimitHandler KillOnAllocationLimit (Just $ \_ -> hPutStrLn stderr "allocation limit triggered 3") + runWorker + threadDelay 1000 + hPutStrLn stderr "done" ===================================== testsuite/tests/rts/T22859.stderr ===================================== @@ -0,0 +1,152 @@ +default behaviour +worker starting +2 +3 +worker died +T22859: allocation limit exceeded +HasCallStack backtrace: + collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception + toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO + throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base + + +just log once on the hook being triggered +worker starting +2 +3 +allocation limit triggered 1 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +29 +worker done +just log on the hook being triggered +worker starting +2 +3 +allocation limit triggered 2 +4 +5 +allocation limit triggered 2 +6 +7 +allocation limit triggered 2 +8 +9 +allocation limit triggered 2 +10 +11 +allocation limit triggered 2 +12 +13 +allocation limit triggered 2 +14 +15 +allocation limit triggered 2 +16 +17 +allocation limit triggered 2 +18 +19 +allocation limit triggered 2 +20 +21 +allocation limit triggered 2 +22 +23 +allocation limit triggered 2 +24 +25 +allocation limit triggered 2 +26 +27 +allocation limit triggered 2 +28 +29 +allocation limit triggered 2 +30 +29 +worker done +kill from the hook +worker starting +2 +3 +worker died +T22859: allocation limit exceeded +HasCallStack backtrace: + collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception + toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO + throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base + + +do nothing +worker starting +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +29 +worker done +kill and log +worker starting +2 +3 +allocation limit triggered 3 +worker died +T22859: allocation limit exceeded +HasCallStack backtrace: + collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception + toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO + throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base + + +done ===================================== testsuite/tests/rts/all.T ===================================== @@ -609,3 +609,5 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], compile_and_run, ['']) + +test('T22859', [js_skip], compile_and_run, ['-with-rtsopts -A8K']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64ee01494af677371fbc33e13c2d830ea9d5eacd...b76643e056e7e09e48e040c1e1bb86020561b6a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64ee01494af677371fbc33e13c2d830ea9d5eacd...b76643e056e7e09e48e040c1e1bb86020561b6a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 16:37:02 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Thu, 21 Mar 2024 12:37:02 -0400 Subject: [Git][ghc/ghc][wip/T22859] Implement user-defined allocation limit handlers Message-ID: <65fc622ee2d36_1068ad68b7cb0153010@gitlab.mail> Teo Camarasu pushed to branch wip/T22859 at Glasgow Haskell Compiler / GHC Commits: a0e8978b by Teo Camarasu at 2024-03-21T16:36:34+00:00 Implement user-defined allocation limit handlers Resolves #22859 - - - - - 23 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - libraries/ghc-experimental/ghc-experimental.cabal - + libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/ghc-internal.cabal - + libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - rts/Prelude.h - rts/PrimOps.cmm - rts/RtsSymbols.c - rts/Schedule.c - rts/external-symbols.list.in - rts/include/rts/storage/GC.h - rts/include/rts/storage/TSO.h - rts/include/stg/MiscClosures.h - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - + testsuite/tests/rts/T22859.hs - + testsuite/tests/rts/T22859.stderr - testsuite/tests/rts/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3952,6 +3952,15 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp effect = ReadWriteEffect out_of_line = True +primop SetOtherThreadAllocationCounter "setOtherThreadAllocationCounter#" GenPrimOp + Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld + { Sets the allocation counter for the another thread to the given value. + This doesn't take allocations into the current nursery chunk into account. + Therefore it is only accurate if the other thread is not currently running. } + with + effect = ReadWriteEffect + out_of_line = True + primtype StackSnapshot# { Haskell representation of a @StgStack*@ that was created (cloned) with a function in "GHC.Stack.CloneStack". Please check the ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1746,6 +1746,7 @@ emitPrimOp cfg primop = TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + SetOtherThreadAllocationCounter -> alwaysExternal KeepAliveOp -> alwaysExternal CastWord32ToFloatOp -> alwaysExternal CastWord64ToDoubleOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1167,6 +1167,7 @@ genPrim prof bound ty op = case op of WhereFromOp -> unhandledPrimop op -- should be easily implementable with o.f.n SetThreadAllocationCounter -> unhandledPrimop op + SetOtherThreadAllocationCounter -> unhandledPrimop op ------------------------------- Vector ----------------------------------------- -- For now, vectors are unsupported on the JS backend. Simply put, they do not ===================================== libraries/ghc-experimental/ghc-experimental.cabal ===================================== @@ -27,6 +27,7 @@ library Data.Tuple.Experimental Data.Sum.Experimental Prelude.Experimental + System.Mem.Experimental if arch(wasm32) exposed-modules: GHC.Wasm.Prim other-extensions: ===================================== libraries/ghc-experimental/src/System/Mem/Experimental.hs ===================================== @@ -0,0 +1,10 @@ +module System.Mem.Experimental + ( setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.AllocationLimitHandler ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -91,6 +91,7 @@ Library ghc-bignum >= 1.0 && < 2.0 exposed-modules: + GHC.Internal.AllocationLimitHandler GHC.Internal.ClosureTypes GHC.Internal.Control.Arrow GHC.Internal.Control.Category ===================================== libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs ===================================== @@ -0,0 +1,114 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# OPTIONS_HADDOCK not-home #-} +module GHC.Internal.AllocationLimitHandler + ( runAllocationLimitHandler + , setGlobalAllocationLimitHandler + , AllocationLimitKillBehaviour(..) + , getAllocationCounterFor + , setAllocationCounterFor + , enableAllocationLimitFor + , disableAllocationLimitFor + ) + where +import GHC.Internal.Base +import GHC.Internal.Conc.Sync (ThreadId(..)) +import GHC.Internal.Data.IORef (IORef, readIORef, writeIORef, newIORef) +import GHC.Internal.Foreign.C.Types +import GHC.Internal.IO (unsafePerformIO) +import GHC.Internal.Int (Int64(..)) + + +{-# NOINLINE allocationLimitHandler #-} +allocationLimitHandler :: IORef (ThreadId -> IO ()) +allocationLimitHandler = unsafePerformIO (newIORef defaultHandler) + +defaultHandler :: ThreadId -> IO () +defaultHandler _ = pure () + +foreign import ccall "setAllocLimitKill" setAllocLimitKill :: CBool -> CBool -> IO () + +runAllocationLimitHandler :: ThreadId# -> IO () +runAllocationLimitHandler tid = do + hook <- getAllocationLimitHandler + hook $ ThreadId tid + +getAllocationLimitHandler :: IO (ThreadId -> IO ()) +getAllocationLimitHandler = readIORef allocationLimitHandler + +data AllocationLimitKillBehaviour = + KillOnAllocationLimit + -- ^ Throw a @AllocationLimitExceeded@ async exception to the thread when the + -- allocation limit is exceeded. + | DontKillOnAllocationLimit + -- ^ Do not throw an exception when the allocation limit is exceeded. + +-- | Define the behaviour for handling allocation limits. +-- By default we throw a @AllocationLimitExceeded@ async exception to the thread. +-- This can be controlled using @AllocationLimitKillBehaviour at . +-- +-- We can also run a user-specified handler, which can be done in addition to +-- or in place of the exception. +-- This allows for instance logging on the allocation limit being exceeded, +-- or dynamically determining whether to terminate the thread. +-- The handler is not guaranteed to run before the thread is terminated or restarted. +-- +-- Note: that if you don't terminate the thread, then the allocation limit gets +-- removed. +-- If you wish to keep the allocation limit you will have to reset it using +-- @setAllocationCounter@ and @enableAllocationLimit at . +setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () +setGlobalAllocationLimitHandler killBehaviour mHandler = do + shouldRunHandler <- case mHandler of + Just hook -> do + writeIORef allocationLimitHandler hook + pure 1 + Nothing -> do + writeIORef allocationLimitHandler defaultHandler + pure 0 + let shouldKill = + case killBehaviour of + KillOnAllocationLimit -> 1 + DontKillOnAllocationLimit -> 0 + setAllocLimitKill shouldKill shouldRunHandler + +-- | Retrieves the allocation counter for the another thread. +foreign import prim "stg_getOtherThreadAllocationCounterzh" getOtherThreadAllocationCounter# + :: ThreadId# + -> State# RealWorld + -> (# State# RealWorld, Int64# #) + +-- | Get the allocation counter for a different thread. +-- Note this doesn't take the current nursery chunk into account. +-- If the thread is running then it may underestimate allocations by the size of a nursery thread. +getAllocationCounterFor :: ThreadId -> IO Int64 +getAllocationCounterFor (ThreadId t#) = IO $ \s -> + case getOtherThreadAllocationCounter# t# s of (# s', i# #) -> (# s', I64# i# #) + +-- | Set the allocation counter for a different thread. +-- This can be combined with 'enableAllocationLimitFor' to enable allocation limits for another thread. +-- Note this doesn't take the current nursery chunk into account. +-- If the thread is running then it may overestimate allocations by the size of a nursery thread, +-- and trigger the limit sooner than expected. +setAllocationCounterFor :: Int64 -> ThreadId -> IO () +setAllocationCounterFor (I64# i#) (ThreadId t#) = IO $ \s -> + case setOtherThreadAllocationCounter# i# t# s of s' -> (# s', () #) + + +-- | Enable allocation limit processing the thread @t at . +enableAllocationLimitFor :: ThreadId -> IO () +enableAllocationLimitFor (ThreadId t) = do + rts_enableThreadAllocationLimit t + +-- | Disable allocation limit processing the thread @t at . +disableAllocationLimitFor :: ThreadId -> IO () +disableAllocationLimitFor (ThreadId t) = do + rts_disableThreadAllocationLimit t + +foreign import ccall unsafe "rts_enableThreadAllocationLimit" + rts_enableThreadAllocationLimit :: ThreadId# -> IO () + +foreign import ccall unsafe "rts_disableThreadAllocationLimit" + rts_disableThreadAllocationLimit :: ThreadId# -> IO () ===================================== rts/Prelude.h ===================================== @@ -67,6 +67,7 @@ PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteComplet PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure); PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure); +PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure); PRELUDE_INFO(ghczmprim_GHCziCString_unpackCStringzh_info); PRELUDE_INFO(ghczmprim_GHCziTypes_Czh_con_info); @@ -102,6 +103,7 @@ PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info); #if defined(mingw32_HOST_OS) #define processRemoteCompletion_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure) #endif +#define runAllocationLimitHandler_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure) #define flushStdHandles_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure) #define runMainIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure) ===================================== rts/PrimOps.cmm ===================================== @@ -2923,6 +2923,11 @@ stg_getThreadAllocationCounterzh () return (StgTSO_alloc_limit(CurrentTSO) - TO_I64(offset)); } +stg_getOtherThreadAllocationCounterzh ( gcptr t ) +{ + return (StgTSO_alloc_limit(t)); +} + stg_setThreadAllocationCounterzh ( I64 counter ) { // Allocation in the current block will be subtracted by @@ -2935,6 +2940,12 @@ stg_setThreadAllocationCounterzh ( I64 counter ) return (); } +stg_setOtherThreadAllocationCounterzh ( I64 counter, gcptr t ) +{ + StgTSO_alloc_limit(t) = counter; + return (); +} + #define KEEP_ALIVE_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,c) \ w_ info_ptr, \ ===================================== rts/RtsSymbols.c ===================================== @@ -914,7 +914,9 @@ extern char **environ; SymI_HasDataProto(stg_traceMarkerzh) \ SymI_HasDataProto(stg_traceBinaryEventzh) \ SymI_HasDataProto(stg_getThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_getOtherThreadAllocationCounterzh) \ SymI_HasDataProto(stg_setThreadAllocationCounterzh) \ + SymI_HasDataProto(stg_setOtherThreadAllocationCounterzh) \ SymI_HasProto(getMonotonicNSec) \ SymI_HasProto(lockFile) \ SymI_HasProto(unlockFile) \ ===================================== rts/Schedule.c ===================================== @@ -41,6 +41,7 @@ #include "Threads.h" #include "Timer.h" #include "ThreadPaused.h" +#include "ThreadLabels.h" #include "Messages.h" #include "StablePtr.h" #include "StableName.h" @@ -94,6 +95,10 @@ StgWord recent_activity = ACTIVITY_YES; */ StgWord sched_state = SCHED_RUNNING; + +bool allocLimitKill = true; +bool allocLimitRunHook = false; + /* * This mutex protects most of the global scheduler data in * the THREADED_RTS runtime. @@ -1113,19 +1118,36 @@ schedulePostRunThread (Capability *cap, StgTSO *t) } } - // - // If the current thread's allocation limit has run out, send it - // the AllocationLimitExceeded exception. + // Handle the current thread's allocation limit running out, if (PK_Int64((W_*)&(t->alloc_limit)) < 0 && (t->flags & TSO_ALLOC_LIMIT)) { - // Use a throwToSelf rather than a throwToSingleThreaded, because - // it correctly handles the case where the thread is currently - // inside mask. Also the thread might be blocked (e.g. on an - // MVar), and throwToSingleThreaded doesn't unblock it - // correctly in that case. - throwToSelf(cap, t, allocationLimitExceeded_closure); - ASSIGN_Int64((W_*)&(t->alloc_limit), - (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + if(allocLimitKill) { + // Throw the AllocationLimitExceeded exception. + // Use a throwToSelf rather than a throwToSingleThreaded, because + // it correctly handles the case where the thread is currently + // inside mask. Also the thread might be blocked (e.g. on an + // MVar), and throwToSingleThreaded doesn't unblock it + // correctly in that case. + throwToSelf(cap, t, allocationLimitExceeded_closure); + ASSIGN_Int64((W_*)&(t->alloc_limit), + (StgInt64)RtsFlags.GcFlags.allocLimitGrace * BLOCK_SIZE); + } else { + // If we aren't killing the thread, we must disable the limit + // otherwise we will immediatelly retrigger it. + // User defined handlers should re-enable it if wanted. + t->flags = t->flags & ~TSO_ALLOC_LIMIT; + } + + if(allocLimitRunHook) + { + // Create a thread to run the allocation limit handler. + StgClosure* c = rts_apply(cap, runAllocationLimitHandler_closure, (StgClosure*)t); + StgTSO* hookThread = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, c); + setThreadLabel(cap, hookThread, "allocation limit handler thread"); + // Schedule the handler to be run immediatelly. + pushOnRunQueue(cap, hookThread); + } + } /* some statistics gathering in the parallel case */ @@ -3327,3 +3349,9 @@ resurrectThreads (StgTSO *threads) } } } + +void setAllocLimitKill(bool shouldKill, bool shouldHook) +{ + allocLimitKill = shouldKill; + allocLimitRunHook = shouldHook; +} ===================================== rts/external-symbols.list.in ===================================== @@ -38,6 +38,7 @@ ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure ghczminternal_GHCziInternalziTopHandler_runMainIO_closure +ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure ghczmprim_GHCziTypes_Czh_con_info ghczmprim_GHCziTypes_Izh_con_info ghczmprim_GHCziTypes_Fzh_con_info ===================================== rts/include/rts/storage/GC.h ===================================== @@ -209,6 +209,10 @@ void flushExec(W_ len, AdjustorExecutable exec_addr); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; +// Should triggering an allocation limit kill the thread +// and should we run a user-defined hook when it is triggered. +void setAllocLimitKill(bool, bool); + /* ----------------------------------------------------------------------------- Performing Garbage Collection -------------------------------------------------------------------------- */ ===================================== rts/include/rts/storage/TSO.h ===================================== @@ -157,9 +157,10 @@ typedef struct StgTSO_ { /* * The allocation limit for this thread, which is updated as the * thread allocates. If the value drops below zero, and - * TSO_ALLOC_LIMIT is set in flags, we raise an exception in the - * thread, and give the thread a little more space to handle the - * exception before we raise the exception again. + * TSO_ALLOC_LIMIT is set in flags, then a handler is triggerd. + * Either we raise an exception in the thread, and give the thread + * a little more space to handle the exception before we raise the + * exception again; or we run a user defined handler. * * This is an integer, because we might update it in a place where * it isn't convenient to raise the exception, so we want it to ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -588,7 +588,9 @@ RTS_FUN_DECL(stg_traceEventzh); RTS_FUN_DECL(stg_traceBinaryEventzh); RTS_FUN_DECL(stg_traceMarkerzh); RTS_FUN_DECL(stg_getThreadAllocationCounterzh); +RTS_FUN_DECL(stg_getOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_setThreadAllocationCounterzh); +RTS_FUN_DECL(stg_setOtherThreadAllocationCounterzh); RTS_FUN_DECL(stg_castWord64ToDoublezh); RTS_FUN_DECL(stg_castDoubleToWord64zh); ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6689,6 +6690,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6658,6 +6659,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4588,6 +4588,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6838,6 +6839,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4585,6 +4585,7 @@ module GHC.Base where sequence :: forall (m :: * -> *) a. Monad m => [m a] -> m [a] setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# @@ -6689,6 +6690,7 @@ module GHC.Exts where seq# :: forall a d. a -> State# d -> (# State# d, a #) setAddrRange# :: Addr# -> Int# -> Int# -> State# RealWorld -> State# RealWorld setByteArray# :: forall d. MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d + setOtherThreadAllocationCounter# :: Int64# -> ThreadId# -> State# RealWorld -> State# RealWorld setThreadAllocationCounter# :: Int64# -> State# RealWorld -> State# RealWorld shiftL# :: Word# -> Int# -> Word# shiftRL# :: Word# -> Int# -> Word# ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -8638,6 +8638,16 @@ module Prelude.Experimental where data Unit# = ... getSolo :: forall a. Solo a -> a +module System.Mem.Experimental where + -- Safety: None + type AllocationLimitKillBehaviour :: * + data AllocationLimitKillBehaviour = KillOnAllocationLimit | DontKillOnAllocationLimit + disableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + enableAllocationLimitFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + getAllocationCounterFor :: GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO GHC.Internal.Int.Int64 + setAllocationCounterFor :: GHC.Internal.Int.Int64 -> GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO () + setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> GHC.Internal.Maybe.Maybe (GHC.Internal.Conc.Sync.ThreadId -> GHC.Types.IO ()) -> GHC.Types.IO () + -- Instances: instance GHC.Classes.Eq GHC.Types.Bool -- Defined in ‘GHC.Classes’ ===================================== testsuite/tests/rts/T22859.hs ===================================== @@ -0,0 +1,71 @@ +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +import Control.Exception +import Control.Exception.Backtrace +import Control.Concurrent +import Control.Concurrent.MVar +import System.Mem +import System.Mem.Experimental +import GHC.IO (IO (..)) +import GHC.Exts +import System.IO + +-- | Just do some work and hPutStrLn stderr to stdout to indicate that we are making progress +worker :: IO () +worker = loop [] 2 + where + loop !m !n + | n > 30 = hPutStrLn stderr . show $ length m + | otherwise = do + let x = show n + hPutStrLn stderr x + -- just to bulk out the allocations + IO (\s -> case newByteArray# 900000# s of (# s', arr# #) -> (# s', () #)) + yield + loop (x:m) (n + 1) + +main :: IO () +main = do + done <- newMVar () -- we use this lock to wait for the worker to finish + started <- newEmptyMVar + let runWorker = do + forkIO . withMVar done $ \_ -> flip onException (hPutStrLn stderr "worker died") $ do + hPutStrLn stderr "worker starting" + putMVar started () + setAllocationCounter 1_000_000 + enableAllocationLimit + worker + hPutStrLn stderr "worker done" + takeMVar started + readMVar done + hFlush stderr + threadDelay 1000 + -- default behaviour: + -- kill it after the limit is exceeded + hPutStrLn stderr "default behaviour" + runWorker + hPutStrLn stderr "just log once on the hook being triggered" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit (Just $ \_ -> hPutStrLn stderr "allocation limit triggered 1") + runWorker + hPutStrLn stderr "just log on the hook being triggered" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit . Just $ \tid -> do + hPutStrLn stderr "allocation limit triggered 2" + -- re-enable the hook + setAllocationCounterFor 1_000_000 tid + enableAllocationLimitFor tid + runWorker + hPutStrLn stderr "kill from the hook" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit . Just $ \tId -> throwTo tId AllocationLimitExceeded + runWorker + -- not super helpful, but let's test it anyway + hPutStrLn stderr "do nothing" + setGlobalAllocationLimitHandler DontKillOnAllocationLimit Nothing + runWorker + -- this is possible to handle using an exception handler instead. + hPutStrLn stderr "kill and log" + setGlobalAllocationLimitHandler KillOnAllocationLimit (Just $ \_ -> hPutStrLn stderr "allocation limit triggered 3") + runWorker + threadDelay 1000 + hPutStrLn stderr "done" ===================================== testsuite/tests/rts/T22859.stderr ===================================== @@ -0,0 +1,152 @@ +default behaviour +worker starting +2 +3 +worker died +T22859: allocation limit exceeded +HasCallStack backtrace: + collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception + toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO + throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base + + +just log once on the hook being triggered +worker starting +2 +3 +allocation limit triggered 1 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +29 +worker done +just log on the hook being triggered +worker starting +2 +3 +allocation limit triggered 2 +4 +5 +allocation limit triggered 2 +6 +7 +allocation limit triggered 2 +8 +9 +allocation limit triggered 2 +10 +11 +allocation limit triggered 2 +12 +13 +allocation limit triggered 2 +14 +15 +allocation limit triggered 2 +16 +17 +allocation limit triggered 2 +18 +19 +allocation limit triggered 2 +20 +21 +allocation limit triggered 2 +22 +23 +allocation limit triggered 2 +24 +25 +allocation limit triggered 2 +26 +27 +allocation limit triggered 2 +28 +29 +allocation limit triggered 2 +30 +29 +worker done +kill from the hook +worker starting +2 +3 +worker died +T22859: allocation limit exceeded +HasCallStack backtrace: + collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception + toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO + throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base + + +do nothing +worker starting +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +29 +worker done +kill and log +worker starting +2 +3 +allocation limit triggered 3 +worker died +T22859: allocation limit exceeded +HasCallStack backtrace: + collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception + toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO + throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base + + +done ===================================== testsuite/tests/rts/all.T ===================================== @@ -609,3 +609,5 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], compile_and_run, ['']) + +test('T22859', [js_skip], compile_and_run, ['-with-rtsopts -A8K']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a0e8978be1d6047806704de0a7fb50dc2e9dd1d7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a0e8978be1d6047806704de0a7fb50dc2e9dd1d7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 19:18:08 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 21 Mar 2024 15:18:08 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24554 Message-ID: <65fc87f039460_1258fb1980354825e9@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24554 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24554 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 19:25:03 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 21 Mar 2024 15:25:03 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65fc898f27995_1258fb1d17e2c87120@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: 12d28860 by Apoorv Ingle at 2024-03-21T14:24:53-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -797,6 +788,8 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' , text "matchPmChecked" <+> ppr (isMatchContextPmChecked dflags origin ctxt)]) ; matches_nablas <- if isMatchContextPmChecked dflags origin ctxt + -- See Note [Expanding HsDo with XXExprGhcRn] Part 1. Wrinkle 1 for + -- pmc for pattern synonyms -- See Note [Long-distance information] in GHC.HsToCore.Pmc then addHsScrutTmCs (concat scrs) new_vars $ @@ -843,16 +836,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -212,7 +212,7 @@ mk_failable_expr doFlav pat@(L loc _) expr fail_op = mk_fail_block :: HsDoFlavour -> LPat GhcRn -> LHsExpr GhcRn -> FailOperator GhcRn -> TcM (HsExpr GhcRn) mk_fail_block doFlav pat@(L ploc _) e (Just (SyntaxExprRn fail_op)) = do dflags <- getDynFlags - return $ HsLam noAnn LamSingle $ mkMatchGroup (doExpansionOrigin doFlav) -- \ + return $ HsLam noAnn LamCases $ mkMatchGroup (doExpansionOrigin doFlav) -- \ (wrapGenSpan [ genHsCaseAltDoExp doFlav (mkVisPat pat) e -- pat -> expr , fail_alt_case dflags pat fail_op -- _ -> fail "fail pattern" ]) @@ -356,25 +356,42 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash at runtime. -* That call of `fail` will (rightly) automatically generate a `MonadFail` constraint. So if the - pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate - a `MonadFail` constraint that isn't needed. +* According to the language specification, when the pattern is irrefutable, + we should not add the `fail` alternative. This is important because + the occurrence of `fail` means that the typechecker will generate a `MonadFail` constraint, + and irrefutable patterns shouldn't need a fail alternative. -* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. - When the pattern is irrefutable, we do not add the fail block. - This is important because the occurrence of `fail` means that the typechecker - will generate a `MonadFail` constraint, and the language spec says that - we should not do that for irrefutable patterns. +* _Wrinkel 1_: Note that pattern synonyms count as refutable during type checking, + see `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`. they will hence generate a + `MonadFail` constraint and we will always be wrapped in a `fail`able-block. - Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate - a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + Consider a patten synonym declaration (testcase T24552): + + pattern MyJust :: a -> Maybe a + pattern MyJust x <- Just x where MyJust = Just + + and a `do`-block with the following bind and return statement + + do { MyJust x <- [MyNothing, MyJust ()] + ; return x + } + + The `do`-expansion will generate the expansion + + (>>=) ([MyNothing, MyJust ()]) + (\case MyJust x -> return x -- (1) + _ -> fail "failable pattern .. " -- (2) + ) + + This code is compiler generated, so the associated `Origin` will be `Generated`. + It will be ignored by the pattern match check (c.f. `isMatchContextPmChecked`). + This ensures we do not generate spurious redundant-pattern-match warnings from line (2) above + See Note [Generated code and pattern-match checking] + See Note [Long-distance information in matchWrapper] * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we - attach to that constraint? It should be a good one, because it'll show up in error - messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the + attach to that constraint? When the `MonadFail` constraint can't be solved, it'll show up in error + messages and it needs to be a good location. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs) ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,14 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude +import qualified Prelude as P + +pattern MyNothing :: Maybe a +pattern MyNothing <- Nothing where MyNothing = Nothing + +pattern MyJust :: a -> Maybe a +pattern MyJust x <- Just x where MyJust = Just + +main = print $ do MyJust x <- [MyNothing, MyJust ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/12d288600ec1e821e099d497bfb8d3187db2e507 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/12d288600ec1e821e099d497bfb8d3187db2e507 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 19:26:35 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 21 Mar 2024 15:26:35 -0400 Subject: [Git][ghc/ghc][wip/T24552] 24 commits: Escape multiple arguments in the settings file Message-ID: <65fc89eb49d2c_1258fb1e0c7d88742a@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - bdbfca35 by Apoorv Ingle at 2024-03-21T14:26:15-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Stg/Unarise.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/12d288600ec1e821e099d497bfb8d3187db2e507...bdbfca356ca88a8c98eac99d4eeb0f24bb13c4c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/12d288600ec1e821e099d497bfb8d3187db2e507...bdbfca356ca88a8c98eac99d4eeb0f24bb13c4c4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 20:12:01 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 16:12:01 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Type-check default declarations before deriving clauses (#24566) Message-ID: <65fc94911e32f_1258fb318b73c9243@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3de938eb by Sylvain Henry at 2024-03-21T16:11:43-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 81eb4628 by Sylvain Henry at 2024-03-21T16:11:46-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - ae52eca6 by Sylvain Henry at 2024-03-21T16:11:46-04:00 JS: fix some comments - - - - - fbad35ab by Sebastian Graf at 2024-03-21T16:11:47-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 10 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/Tc/Module.hs - libraries/ghc-internal/src/GHC/Internal/Maybe.hs - + testsuite/tests/simplCore/should_compile/T24551.hs - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/typecheck/should_compile/Makefile - + testsuite/tests/typecheck/should_compile/T24566.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -85,6 +85,8 @@ import GHC.Utils.Panic import Control.Monad ( when ) import Data.List ( sortBy ) +import GHC.Types.Name.Env +import Data.Graph {- ********************************************************************* * * @@ -2108,6 +2110,27 @@ new binding is abstracted. Several points worth noting which showed that it's harder to do polymorphic specialisation well if there are dictionaries abstracted over unnecessary type variables. See Note [Weird special case for SpecDict] in GHC.Core.Opt.Specialise + +(AB5) We do dependency analysis on recursive groups prior to determining + which variables to abstract over. + This is useful, because ANFisation in prepareBinding may float out + values out of a complex recursive binding, e.g., + letrec { xs = g @a "blah"# ((:) 1 []) xs } in ... + ==> { prepareBinding } + letrec { foo = "blah"# + bar = [42] + xs = g @a foo bar xs } in + ... + and we don't want to abstract foo and bar over @a. + + (Why is it OK to float the unlifted `foo` there? + See Note [Core top-level string literals] in GHC.Core; + it is controlled by GHC.Core.Opt.Simplify.Env.unitLetFloat.) + + It is also necessary to do dependency analysis, because + otherwise (in #24551) we might get `foo = \@_ -> "missing"#` at the + top-level, and that triggers a CoreLint error because `foo` is *not* + manifestly a literal string. -} abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats @@ -2115,15 +2138,27 @@ abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats abstractFloats uf_opts top_lvl main_tvs floats body = assert (notNull body_floats) $ assert (isNilOL (sfJoinFloats floats)) $ - do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats + do { let sccs = concatMap to_sccs body_floats + ; (subst, float_binds) <- mapAccumLM abstract empty_subst sccs ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl body_floats = letFloatBinds (sfLetFloats floats) empty_subst = GHC.Core.Subst.mkEmptySubst (sfInScope floats) - abstract :: GHC.Core.Subst.Subst -> OutBind -> SimplM (GHC.Core.Subst.Subst, OutBind) - abstract subst (NonRec id rhs) + -- See wrinkle (AB5) in Note [Which type variables to abstract over] + -- for why we need to re-do dependency analysis + to_sccs :: OutBind -> [SCC (Id, CoreExpr, VarSet)] + to_sccs (NonRec id e) = [AcyclicSCC (id, e, emptyVarSet)] -- emptyVarSet: abstract doesn't need it + to_sccs (Rec prs) = sccs + where + (ids,rhss) = unzip prs + sccs = depAnal (\(id,_rhs,_fvs) -> [getName id]) + (\(_id,_rhs,fvs) -> nonDetStrictFoldVarSet ((:) . getName) [] fvs) -- Wrinkle (AB3) + (zip3 ids rhss (map exprFreeVars rhss)) + + abstract :: GHC.Core.Subst.Subst -> SCC (Id, CoreExpr, VarSet) -> SimplM (GHC.Core.Subst.Subst, OutBind) + abstract subst (AcyclicSCC (id, rhs, _empty_var_set)) = do { (poly_id1, poly_app) <- mk_poly1 tvs_here id ; let (poly_id2, poly_rhs) = mk_poly2 poly_id1 tvs_here rhs' !subst' = GHC.Core.Subst.extendIdSubst subst id poly_app @@ -2134,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body -- tvs_here: see Note [Which type variables to abstract over] tvs_here = choose_tvs (exprSomeFreeVars isTyVar rhs') - abstract subst (Rec prs) + abstract subst (CyclicSCC trpls) = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' @@ -2142,15 +2177,15 @@ abstractFloats uf_opts top_lvl main_tvs floats body , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where - (ids,rhss) = unzip prs - + (ids,rhss,_fvss) = unzip3 trpls -- tvs_here: see Note [Which type variables to abstract over] - tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs prs) + tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs trpls) -- See wrinkle (AB4) in Note [Which type variables to abstract over] - get_bind_fvs (id,rhs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs - get_rec_rhs_tvs rhs = nonDetStrictFoldVarSet get_tvs emptyVarSet (exprFreeVars rhs) + get_bind_fvs (id,_rhs,rhs_fvs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs_fvs + get_rec_rhs_tvs rhs_fvs = nonDetStrictFoldVarSet get_tvs emptyVarSet rhs_fvs + -- nonDet is safe because of wrinkle (AB3) get_tvs :: Var -> VarSet -> VarSet get_tvs var free_tvs ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2814,19 +2814,19 @@ characters into single bytes. {-# INLINE adjustChar #-} adjustChar :: Char -> Word8 -adjustChar c = fromIntegral $ ord adj_c - where non_graphic = '\x00' - upper = '\x01' - lower = '\x02' - digit = '\x03' - symbol = '\x04' - space = '\x05' - other_graphic = '\x06' - uniidchar = '\x07' +adjustChar c = adj_c + where non_graphic = 0x00 + upper = 0x01 + lower = 0x02 + digit = 0x03 + symbol = 0x04 + space = 0x05 + other_graphic = 0x06 + uniidchar = 0x07 adj_c | c <= '\x07' = non_graphic - | c <= '\x7f' = c + | c <= '\x7f' = fromIntegral (ord c) -- Alex doesn't handle Unicode, so when Unicode -- character is encountered we output these values -- with the actual character value hidden in the state. @@ -2866,15 +2866,18 @@ adjustChar c = fromIntegral $ ord adj_c -- -- See Note [Unicode in Alex] and #13986. alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (AI _ buf) = chr (fromIntegral (adjustChar pc)) +alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' +unsafeChr :: Int -> Char +unsafeChr (I# c) = C# (chr# c) + -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) alexGetChar inp = case alexGetByte inp of Nothing -> Nothing Just (b,i) -> c `seq` Just (c,i) - where c = chr $ fromIntegral b + where c = unsafeChr $ fromIntegral b -- See Note [Unicode in Alex] alexGetByte :: AlexInput -> Maybe (Word8,AlexInput) ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -738,7 +738,7 @@ writeExterns out = writeFile (out "all.js.externs") -- | Get all block dependencies for a given set of roots -- --- Returns the update block info map and the blocks. +-- Returns the updated block info map and the blocks. getDeps :: Map Module LocatedBlockInfo -- ^ Block info per module -> (Module -> IO LocatedBlockInfo) -- ^ Used to load block info if missing -> Set ExportedFun -- ^ start here @@ -754,7 +754,7 @@ getDeps init_infos load_info root_funs root_blocks = traverse_funs init_infos S. -- 1. We use the BlockInfos to find the block corresponding to every -- exported root functions. -- - -- 2. We had these blocks to the set of root_blocks if they aren't already + -- 2. We add these blocks to the set of root_blocks if they aren't already -- added to the result. -- -- 3. Then we traverse the root_blocks to find their dependencies and we ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -709,7 +709,7 @@ tcRnHsBootDecls boot_or_sig decls -- Typecheck type/class/instance decls ; traceTc "Tc2 (boot)" empty ; (tcg_env, inst_infos, _deriv_binds, _th_bndrs) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds + <- tcTyClsInstDecls tycl_decls deriv_decls def_decls val_binds ; setGblEnv tcg_env $ do { -- Emit Typeable bindings @@ -1612,7 +1612,7 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, traceTc "Tc3" empty ; (tcg_env, inst_infos, th_bndrs, XValBindsLR (NValBinds deriv_binds deriv_sigs)) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds ; + <- tcTyClsInstDecls tycl_decls deriv_decls default_decls val_binds ; updLclCtxt (\tcl_env -> tcl_env { tcl_th_bndrs = th_bndrs `plusNameEnv` tcl_th_bndrs tcl_env }) $ setGblEnv tcg_env $ do { @@ -1622,11 +1622,6 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, (fi_ids, fi_decls, fi_gres) <- tcForeignImports foreign_decls ; tcExtendGlobalValEnv fi_ids $ do { - -- Default declarations - traceTc "Tc4a" empty ; - default_tys <- tcDefaults default_decls ; - updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { - -- Value declarations next. -- It is important that we check the top-level value bindings -- before the GHC-generated derived bindings, since the latter @@ -1686,13 +1681,14 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, addUsedGREs NoDeprecationWarnings (bagToList fo_gres) ; return (tcg_env', tcl_env) - }}}}}} + }}}}} tcTopSrcDecls _ = panic "tcTopSrcDecls: ValBindsIn" --------------------------- tcTyClsInstDecls :: [TyClGroup GhcRn] -> [LDerivDecl GhcRn] + -> [LDefaultDecl GhcRn] -> [(RecFlag, LHsBinds GhcRn)] -> TcM (TcGblEnv, -- The full inst env [InstInfo GhcRn], -- Source-code instance decls to @@ -1702,16 +1698,24 @@ tcTyClsInstDecls :: [TyClGroup GhcRn] HsValBinds GhcRn) -- Supporting bindings for derived -- instances -tcTyClsInstDecls tycl_decls deriv_decls binds +tcTyClsInstDecls tycl_decls deriv_decls default_decls binds = tcAddDataFamConPlaceholders (tycl_decls >>= group_instds) $ tcAddPatSynPlaceholders (getPatSynBinds binds) $ do { (tcg_env, inst_info, deriv_info, th_bndrs) <- tcTyAndClassDecls tycl_decls ; + ; setGblEnv tcg_env $ do { + -- With the @TyClDecl at s and @InstDecl at s checked we're ready to -- process the deriving clauses, including data family deriving -- clauses discovered in @tcTyAndClassDecls at . -- + -- But only after we've typechecked 'default' declarations. + -- See Note [Typechecking default declarations] + default_tys <- tcDefaults default_decls ; + updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { + + -- Careful to quit now in case there were instance errors, so that -- the deriving errors don't pile up as well. ; failIfErrsM @@ -1720,7 +1724,7 @@ tcTyClsInstDecls tycl_decls deriv_decls binds ; setGblEnv tcg_env' $ do { failIfErrsM ; pure ( tcg_env', inst_info' ++ inst_info, th_bndrs, val_binds ) - }}} + }}}} {- ********************************************************************* * * @@ -3141,3 +3145,43 @@ mark_plugin_unsafe dflags = unless (gopt Opt_PluginTrustworthy dflags) $ pluginUnsafe = singleMessage $ mkPlainMsgEnvelope diag_opts noSrcSpan TcRnUnsafeDueToPlugin + + +-- Note [Typechecking default declarations] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Typechecking default declarations requires careful placement: +-- +-- 1. We must check them after types (tcTyAndClassDecls) because they can refer +-- to them. E.g. +-- +-- data T = MkT ... +-- default(Int, T, Integer) +-- +-- -- or even (tested by T11974b and T2245) +-- default(Int, T, Integer) +-- data T = MkT ... +-- +-- 2. We must check them before typechecking deriving clauses (tcInstDeclsDeriv) +-- otherwise we may lookup default default types (Integer, Double) while checking +-- deriving clauses, ignoring the default declaration. +-- +-- Before this careful placement (#24566), compiling the following example +-- (T24566) with "-ddump-if-trace -ddump-tc-trace" showed a call to +-- `applyDefaultingRules` with default types set to "(Integer,Double)": +-- +-- module M where +-- +-- import GHC.Classes +-- default () +-- +-- data Foo a = Nothing | Just a +-- deriving (Eq, Ord) +-- +-- This was an issue while building modules like M in the ghc-internal package +-- because they would spuriously fail to build if the module defining Integer +-- (ghc-bignum:GHC.Num.Integer) wasn't compiled yet and its interface not to be +-- found. The implicit dependency between M and GHC.Num.Integer isn't known to +-- the build system. +-- In addition, trying to explicitly avoid the implicit dependency with `default +-- ()` didn't work, except if *standalone* deriving was used, which was an +-- inconsistent behavior. ===================================== libraries/ghc-internal/src/GHC/Internal/Maybe.hs ===================================== @@ -28,14 +28,5 @@ default () -- data Maybe a = Nothing | Just a deriving ( Eq -- ^ @since base-2.01 - - --, Ord -- ^ @since base-2.01 + , Ord -- ^ @since base-2.01 ) - --- ??? --- A non-standalone instance will slurp the interface file for GHC.Num.Integer. - -- During simplifyInstanceContexts, a call to GHC.Tc.Utils.Env.tcGetDefaultTys - -- apparently sees mb_defaults = Nothing and thus tries to bring in the - -- default "default" types, including Integer. This seems wrong. -deriving instance Ord a => Ord (Maybe a) -- ^ @since base-2.01 - ===================================== testsuite/tests/simplCore/should_compile/T24551.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module T24551 (f) where + +import GHC.Exts + +f :: a -> a +f = repeatFB g + +repeatFB :: (Addr# -> (a -> a) -> a -> a) -> a -> a +repeatFB c = let xs = c "missing"# xs in xs +{-# INLINE [0] repeatFB #-} + +g :: Addr# -> (a -> a) -> a -> a +g _ _ x = x +{-# NOINLINE g #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T23209', [extra_files(['T23209_Aux.hs'])], multimod_compile, ['T23209', '- test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) +test('T24551', normal, compile, ['-O -dcore-lint']) ===================================== testsuite/tests/typecheck/should_compile/Makefile ===================================== @@ -122,3 +122,7 @@ InlinePatSyn_ExplicitBidiBuilder: InlinePatSyn_ExplicitBidiMatcher: $(RM) -f InlinePatSyn_ExplicitBidiMatcher.o InlinePatSyn_ExplicitBidiMatcher.hi '$(TEST_HC)' $(TEST_HC_OPTS) -c InlinePatSyn_ExplicitBidiMatcher.hs -O -dsuppress-all -ddump-simpl | sed -n '/^test/,/^$$/p' | grep -vq 'Pattern' + +T24566: + '$(TEST_HC)' $(TEST_HC_OPTS) -c T24566.hs -fno-code -dno-typeable-binds -ddump-if-trace 2>&1 | grep Integer || true + # Not expecting any mention of Integer in the interface loading trace ===================================== testsuite/tests/typecheck/should_compile/T24566.hs ===================================== @@ -0,0 +1,7 @@ +module M where + +import GHC.Classes +default () + +data Foo a = Nothing | Just a + deriving (Eq, Ord) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -913,3 +913,4 @@ test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) test('T24470b', normal, compile, ['']) +test('T24566', [], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7543596dfba03a733aedee6683621721088b9b1...fbad35abf2a06c8890d932e03782de507e169ec8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7543596dfba03a733aedee6683621721088b9b1...fbad35abf2a06c8890d932e03782de507e169ec8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 21 20:15:49 2024 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Thu, 21 Mar 2024 16:15:49 -0400 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] More instruction cache flushing Message-ID: <65fc957575069_1258fb363538c98254@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: f3921041 by Sven Tennie at 2024-03-21T21:14:36+01:00 More instruction cache flushing Flush in the Linker, which creates code in the PLT. And, cleanup the link code by using built-ins instead of inline assembly. - - - - - 8 changed files: - rts/adjustor/LibffiAdjustor.c - rts/linker/Elf.c - rts/linker/elf_reloc.c - rts/linker/elf_reloc.h - rts/linker/elf_reloc_aarch64.c - rts/linker/elf_reloc_aarch64.h - rts/linker/elf_reloc_riscv64.c - rts/linker/elf_reloc_riscv64.h Changes: ===================================== rts/adjustor/LibffiAdjustor.c ===================================== @@ -12,6 +12,7 @@ #include "Adjustor.h" #include "rts/ghc_ffi.h" +#include #include // Note that ffi_alloc_prep_closure is a non-standard libffi closure @@ -189,14 +190,18 @@ createAdjustor (int cconv, #if defined(riscv64_HOST_ARCH) // Synchronize the memory and instruction cache to prevent illegal - // instruction exceptions. fence.i works per hart. I'm not sure what happens - // when the generated code is called on another hart. Probably, the fence on - // read/write is good enough for that. However, if there are illegal - // instruction exceptions, this is the place to look at (maybe, that the - // fence.i needs to be moved closely before the call.) - asm volatile ("fence rw, rw" : : : "memory"); - asm volatile ("fence.i" ::: "memory"); + // instruction exceptions. + + // We expect two instructions for address loading, one for the jump. + int instrCount = 3; + // On Linux the parameters of __builtin___clear_cache are currently unused. + // Add them anyways for future compatibility. (I.e. the parameters couldn't + // be checked during development.) + __builtin___clear_cache((void *)code, + (void *)code + instrCount * sizeof(uint64_t)); + // Memory barrier to ensure nothing circumvents the fence.i / cache flush. + SEQ_CST_FENCE(); #endif - return (void*)code; + return (void *)code; } ===================================== rts/linker/Elf.c ===================================== @@ -2015,6 +2015,8 @@ ocResolve_ELF ( ObjectCode* oc ) #if defined(powerpc_HOST_ARCH) ocFlushInstructionCache( oc ); +#elseif defined(riscv64_HOST_ARCH) + flushInstructionCache(); #endif return ocMprotect_Elf(oc); ===================================== rts/linker/elf_reloc.c ===================================== @@ -11,6 +11,11 @@ bool relocateObjectCode(ObjectCode * oc) { return ADD_SUFFIX(relocateObjectCode)(oc); } + + +void flushInstructionCache(){ + return ADD_SUFFIX(flushInstructionCache)(); +} #endif #endif ===================================== rts/linker/elf_reloc.h ===================================== @@ -10,5 +10,5 @@ bool relocateObjectCode(ObjectCode * oc); - +void flushInstructionCache(); #endif /* OBJETFORMAT_ELF */ ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -339,5 +339,10 @@ relocateObjectCodeAarch64(ObjectCode * oc) { return EXIT_SUCCESS; } +void flushInstructionCacheAarch64() { + // Looks like we don't need this on Aarch64. + /* no-op */ +} + #endif /* OBJECTFORMAT_ELF */ #endif /* aarch64_HOST_ARCH */ ===================================== rts/linker/elf_reloc_aarch64.h ===================================== @@ -7,4 +7,5 @@ bool relocateObjectCodeAarch64(ObjectCode * oc); +void flushInstructionCacheAarch64(); #endif /* OBJETFORMAT_ELF */ ===================================== rts/linker/elf_reloc_riscv64.c ===================================== @@ -588,5 +588,25 @@ bool relocateObjectCodeRISCV64(ObjectCode *oc) { return EXIT_SUCCESS; } +void flushInstructionCacheRISCV64(ObjectCode *oc) { + // Synchronize the memory and instruction cache to prevent illegal + // instruction exceptions. On Linux the parameters of + // __builtin___clear_cache are currently unused. Add them anyways for future + // compatibility. (I.e. the parameters couldn't be checked during + // development.) + + /* The main object code */ + void *codeBegin = oc->image + oc->misalignment; + __builtin___clear_cache(codeBegin, codeBegin + oc->fileSize); + + /* Jump Islands */ + __builtin___clear_cache((void *)oc->symbol_extras, + (void *)oc->symbol_extras + + sizeof(SymbolExtra) * oc->n_symbol_extras); + + // Memory barrier to ensure nothing circumvents the fence.i / cache flushes. + SEQ_CST_FENCE(); +} + #endif /* OBJECTFORMAT_ELF */ #endif /* riscv64_HOST_ARCH */ ===================================== rts/linker/elf_reloc_riscv64.h ===================================== @@ -7,4 +7,5 @@ bool relocateObjectCodeRISCV64(ObjectCode * oc); +void flushInstructionCacheRISCV64(); #endif /* OBJETFORMAT_ELF */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f39210417bc758abf4b013c5becaa66545184cbc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f39210417bc758abf4b013c5becaa66545184cbc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 01:02:28 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 21:02:28 -0400 Subject: [Git][ghc/ghc][master] Type-check default declarations before deriving clauses (#24566) Message-ID: <65fcd8a451d35_1258fbb2d9be0113995@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 5 changed files: - compiler/GHC/Tc/Module.hs - libraries/ghc-internal/src/GHC/Internal/Maybe.hs - testsuite/tests/typecheck/should_compile/Makefile - + testsuite/tests/typecheck/should_compile/T24566.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -709,7 +709,7 @@ tcRnHsBootDecls boot_or_sig decls -- Typecheck type/class/instance decls ; traceTc "Tc2 (boot)" empty ; (tcg_env, inst_infos, _deriv_binds, _th_bndrs) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds + <- tcTyClsInstDecls tycl_decls deriv_decls def_decls val_binds ; setGblEnv tcg_env $ do { -- Emit Typeable bindings @@ -1612,7 +1612,7 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, traceTc "Tc3" empty ; (tcg_env, inst_infos, th_bndrs, XValBindsLR (NValBinds deriv_binds deriv_sigs)) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds ; + <- tcTyClsInstDecls tycl_decls deriv_decls default_decls val_binds ; updLclCtxt (\tcl_env -> tcl_env { tcl_th_bndrs = th_bndrs `plusNameEnv` tcl_th_bndrs tcl_env }) $ setGblEnv tcg_env $ do { @@ -1622,11 +1622,6 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, (fi_ids, fi_decls, fi_gres) <- tcForeignImports foreign_decls ; tcExtendGlobalValEnv fi_ids $ do { - -- Default declarations - traceTc "Tc4a" empty ; - default_tys <- tcDefaults default_decls ; - updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { - -- Value declarations next. -- It is important that we check the top-level value bindings -- before the GHC-generated derived bindings, since the latter @@ -1686,13 +1681,14 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, addUsedGREs NoDeprecationWarnings (bagToList fo_gres) ; return (tcg_env', tcl_env) - }}}}}} + }}}}} tcTopSrcDecls _ = panic "tcTopSrcDecls: ValBindsIn" --------------------------- tcTyClsInstDecls :: [TyClGroup GhcRn] -> [LDerivDecl GhcRn] + -> [LDefaultDecl GhcRn] -> [(RecFlag, LHsBinds GhcRn)] -> TcM (TcGblEnv, -- The full inst env [InstInfo GhcRn], -- Source-code instance decls to @@ -1702,16 +1698,24 @@ tcTyClsInstDecls :: [TyClGroup GhcRn] HsValBinds GhcRn) -- Supporting bindings for derived -- instances -tcTyClsInstDecls tycl_decls deriv_decls binds +tcTyClsInstDecls tycl_decls deriv_decls default_decls binds = tcAddDataFamConPlaceholders (tycl_decls >>= group_instds) $ tcAddPatSynPlaceholders (getPatSynBinds binds) $ do { (tcg_env, inst_info, deriv_info, th_bndrs) <- tcTyAndClassDecls tycl_decls ; + ; setGblEnv tcg_env $ do { + -- With the @TyClDecl at s and @InstDecl at s checked we're ready to -- process the deriving clauses, including data family deriving -- clauses discovered in @tcTyAndClassDecls at . -- + -- But only after we've typechecked 'default' declarations. + -- See Note [Typechecking default declarations] + default_tys <- tcDefaults default_decls ; + updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { + + -- Careful to quit now in case there were instance errors, so that -- the deriving errors don't pile up as well. ; failIfErrsM @@ -1720,7 +1724,7 @@ tcTyClsInstDecls tycl_decls deriv_decls binds ; setGblEnv tcg_env' $ do { failIfErrsM ; pure ( tcg_env', inst_info' ++ inst_info, th_bndrs, val_binds ) - }}} + }}}} {- ********************************************************************* * * @@ -3141,3 +3145,43 @@ mark_plugin_unsafe dflags = unless (gopt Opt_PluginTrustworthy dflags) $ pluginUnsafe = singleMessage $ mkPlainMsgEnvelope diag_opts noSrcSpan TcRnUnsafeDueToPlugin + + +-- Note [Typechecking default declarations] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Typechecking default declarations requires careful placement: +-- +-- 1. We must check them after types (tcTyAndClassDecls) because they can refer +-- to them. E.g. +-- +-- data T = MkT ... +-- default(Int, T, Integer) +-- +-- -- or even (tested by T11974b and T2245) +-- default(Int, T, Integer) +-- data T = MkT ... +-- +-- 2. We must check them before typechecking deriving clauses (tcInstDeclsDeriv) +-- otherwise we may lookup default default types (Integer, Double) while checking +-- deriving clauses, ignoring the default declaration. +-- +-- Before this careful placement (#24566), compiling the following example +-- (T24566) with "-ddump-if-trace -ddump-tc-trace" showed a call to +-- `applyDefaultingRules` with default types set to "(Integer,Double)": +-- +-- module M where +-- +-- import GHC.Classes +-- default () +-- +-- data Foo a = Nothing | Just a +-- deriving (Eq, Ord) +-- +-- This was an issue while building modules like M in the ghc-internal package +-- because they would spuriously fail to build if the module defining Integer +-- (ghc-bignum:GHC.Num.Integer) wasn't compiled yet and its interface not to be +-- found. The implicit dependency between M and GHC.Num.Integer isn't known to +-- the build system. +-- In addition, trying to explicitly avoid the implicit dependency with `default +-- ()` didn't work, except if *standalone* deriving was used, which was an +-- inconsistent behavior. ===================================== libraries/ghc-internal/src/GHC/Internal/Maybe.hs ===================================== @@ -28,14 +28,5 @@ default () -- data Maybe a = Nothing | Just a deriving ( Eq -- ^ @since base-2.01 - - --, Ord -- ^ @since base-2.01 + , Ord -- ^ @since base-2.01 ) - --- ??? --- A non-standalone instance will slurp the interface file for GHC.Num.Integer. - -- During simplifyInstanceContexts, a call to GHC.Tc.Utils.Env.tcGetDefaultTys - -- apparently sees mb_defaults = Nothing and thus tries to bring in the - -- default "default" types, including Integer. This seems wrong. -deriving instance Ord a => Ord (Maybe a) -- ^ @since base-2.01 - ===================================== testsuite/tests/typecheck/should_compile/Makefile ===================================== @@ -122,3 +122,7 @@ InlinePatSyn_ExplicitBidiBuilder: InlinePatSyn_ExplicitBidiMatcher: $(RM) -f InlinePatSyn_ExplicitBidiMatcher.o InlinePatSyn_ExplicitBidiMatcher.hi '$(TEST_HC)' $(TEST_HC_OPTS) -c InlinePatSyn_ExplicitBidiMatcher.hs -O -dsuppress-all -ddump-simpl | sed -n '/^test/,/^$$/p' | grep -vq 'Pattern' + +T24566: + '$(TEST_HC)' $(TEST_HC_OPTS) -c T24566.hs -fno-code -dno-typeable-binds -ddump-if-trace 2>&1 | grep Integer || true + # Not expecting any mention of Integer in the interface loading trace ===================================== testsuite/tests/typecheck/should_compile/T24566.hs ===================================== @@ -0,0 +1,7 @@ +module M where + +import GHC.Classes +default () + +data Foo a = Nothing | Just a + deriving (Eq, Ord) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -913,3 +913,4 @@ test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) test('T24470b', normal, compile, ['']) +test('T24566', [], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52072f8e2121fe49a8367027efa3d8db32325f84 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52072f8e2121fe49a8367027efa3d8db32325f84 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 01:03:03 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 21:03:03 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Lexer: small perf changes Message-ID: <65fcd8c72cdb9_1258fbb4803681168e2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 2 changed files: - compiler/GHC/Parser/Lexer.x - compiler/GHC/StgToJS/Linker/Linker.hs Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2814,19 +2814,19 @@ characters into single bytes. {-# INLINE adjustChar #-} adjustChar :: Char -> Word8 -adjustChar c = fromIntegral $ ord adj_c - where non_graphic = '\x00' - upper = '\x01' - lower = '\x02' - digit = '\x03' - symbol = '\x04' - space = '\x05' - other_graphic = '\x06' - uniidchar = '\x07' +adjustChar c = adj_c + where non_graphic = 0x00 + upper = 0x01 + lower = 0x02 + digit = 0x03 + symbol = 0x04 + space = 0x05 + other_graphic = 0x06 + uniidchar = 0x07 adj_c | c <= '\x07' = non_graphic - | c <= '\x7f' = c + | c <= '\x7f' = fromIntegral (ord c) -- Alex doesn't handle Unicode, so when Unicode -- character is encountered we output these values -- with the actual character value hidden in the state. @@ -2866,15 +2866,18 @@ adjustChar c = fromIntegral $ ord adj_c -- -- See Note [Unicode in Alex] and #13986. alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (AI _ buf) = chr (fromIntegral (adjustChar pc)) +alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' +unsafeChr :: Int -> Char +unsafeChr (I# c) = C# (chr# c) + -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) alexGetChar inp = case alexGetByte inp of Nothing -> Nothing Just (b,i) -> c `seq` Just (c,i) - where c = chr $ fromIntegral b + where c = unsafeChr $ fromIntegral b -- See Note [Unicode in Alex] alexGetByte :: AlexInput -> Maybe (Word8,AlexInput) ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -738,7 +738,7 @@ writeExterns out = writeFile (out "all.js.externs") -- | Get all block dependencies for a given set of roots -- --- Returns the update block info map and the blocks. +-- Returns the updated block info map and the blocks. getDeps :: Map Module LocatedBlockInfo -- ^ Block info per module -> (Module -> IO LocatedBlockInfo) -- ^ Used to load block info if missing -> Set ExportedFun -- ^ start here @@ -754,7 +754,7 @@ getDeps init_infos load_info root_funs root_blocks = traverse_funs init_infos S. -- 1. We use the BlockInfos to find the block corresponding to every -- exported root functions. -- - -- 2. We had these blocks to the set of root_blocks if they aren't already + -- 2. We add these blocks to the set of root_blocks if they aren't already -- added to the result. -- -- 3. Then we traverse the root_blocks to find their dependencies and we View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52072f8e2121fe49a8367027efa3d8db32325f84...864922ef8ab97ea6dfe970be69f0c2fa78315b08 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52072f8e2121fe49a8367027efa3d8db32325f84...864922ef8ab97ea6dfe970be69f0c2fa78315b08 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 01:03:46 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 21 Mar 2024 21:03:46 -0400 Subject: [Git][ghc/ghc][master] Simplifier: Re-do dependency analysis in abstractFloats (#24551) Message-ID: <65fcd8f2141ce_1258fbb64a9781214c0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/simplCore/should_compile/T24551.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -85,6 +85,8 @@ import GHC.Utils.Panic import Control.Monad ( when ) import Data.List ( sortBy ) +import GHC.Types.Name.Env +import Data.Graph {- ********************************************************************* * * @@ -2108,6 +2110,27 @@ new binding is abstracted. Several points worth noting which showed that it's harder to do polymorphic specialisation well if there are dictionaries abstracted over unnecessary type variables. See Note [Weird special case for SpecDict] in GHC.Core.Opt.Specialise + +(AB5) We do dependency analysis on recursive groups prior to determining + which variables to abstract over. + This is useful, because ANFisation in prepareBinding may float out + values out of a complex recursive binding, e.g., + letrec { xs = g @a "blah"# ((:) 1 []) xs } in ... + ==> { prepareBinding } + letrec { foo = "blah"# + bar = [42] + xs = g @a foo bar xs } in + ... + and we don't want to abstract foo and bar over @a. + + (Why is it OK to float the unlifted `foo` there? + See Note [Core top-level string literals] in GHC.Core; + it is controlled by GHC.Core.Opt.Simplify.Env.unitLetFloat.) + + It is also necessary to do dependency analysis, because + otherwise (in #24551) we might get `foo = \@_ -> "missing"#` at the + top-level, and that triggers a CoreLint error because `foo` is *not* + manifestly a literal string. -} abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats @@ -2115,15 +2138,27 @@ abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats abstractFloats uf_opts top_lvl main_tvs floats body = assert (notNull body_floats) $ assert (isNilOL (sfJoinFloats floats)) $ - do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats + do { let sccs = concatMap to_sccs body_floats + ; (subst, float_binds) <- mapAccumLM abstract empty_subst sccs ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl body_floats = letFloatBinds (sfLetFloats floats) empty_subst = GHC.Core.Subst.mkEmptySubst (sfInScope floats) - abstract :: GHC.Core.Subst.Subst -> OutBind -> SimplM (GHC.Core.Subst.Subst, OutBind) - abstract subst (NonRec id rhs) + -- See wrinkle (AB5) in Note [Which type variables to abstract over] + -- for why we need to re-do dependency analysis + to_sccs :: OutBind -> [SCC (Id, CoreExpr, VarSet)] + to_sccs (NonRec id e) = [AcyclicSCC (id, e, emptyVarSet)] -- emptyVarSet: abstract doesn't need it + to_sccs (Rec prs) = sccs + where + (ids,rhss) = unzip prs + sccs = depAnal (\(id,_rhs,_fvs) -> [getName id]) + (\(_id,_rhs,fvs) -> nonDetStrictFoldVarSet ((:) . getName) [] fvs) -- Wrinkle (AB3) + (zip3 ids rhss (map exprFreeVars rhss)) + + abstract :: GHC.Core.Subst.Subst -> SCC (Id, CoreExpr, VarSet) -> SimplM (GHC.Core.Subst.Subst, OutBind) + abstract subst (AcyclicSCC (id, rhs, _empty_var_set)) = do { (poly_id1, poly_app) <- mk_poly1 tvs_here id ; let (poly_id2, poly_rhs) = mk_poly2 poly_id1 tvs_here rhs' !subst' = GHC.Core.Subst.extendIdSubst subst id poly_app @@ -2134,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body -- tvs_here: see Note [Which type variables to abstract over] tvs_here = choose_tvs (exprSomeFreeVars isTyVar rhs') - abstract subst (Rec prs) + abstract subst (CyclicSCC trpls) = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' @@ -2142,15 +2177,15 @@ abstractFloats uf_opts top_lvl main_tvs floats body , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where - (ids,rhss) = unzip prs - + (ids,rhss,_fvss) = unzip3 trpls -- tvs_here: see Note [Which type variables to abstract over] - tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs prs) + tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs trpls) -- See wrinkle (AB4) in Note [Which type variables to abstract over] - get_bind_fvs (id,rhs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs - get_rec_rhs_tvs rhs = nonDetStrictFoldVarSet get_tvs emptyVarSet (exprFreeVars rhs) + get_bind_fvs (id,_rhs,rhs_fvs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs_fvs + get_rec_rhs_tvs rhs_fvs = nonDetStrictFoldVarSet get_tvs emptyVarSet rhs_fvs + -- nonDet is safe because of wrinkle (AB3) get_tvs :: Var -> VarSet -> VarSet get_tvs var free_tvs ===================================== testsuite/tests/simplCore/should_compile/T24551.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module T24551 (f) where + +import GHC.Exts + +f :: a -> a +f = repeatFB g + +repeatFB :: (Addr# -> (a -> a) -> a -> a) -> a -> a +repeatFB c = let xs = c "missing"# xs in xs +{-# INLINE [0] repeatFB #-} + +g :: Addr# -> (a -> a) -> a -> a +g _ _ x = x +{-# NOINLINE g #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T23209', [extra_files(['T23209_Aux.hs'])], multimod_compile, ['T23209', '- test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) +test('T24551', normal, compile, ['-O -dcore-lint']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e0b2b1f14e5e82eaa1dc6fbf8dceb5f539f5aa3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e0b2b1f14e5e82eaa1dc6fbf8dceb5f539f5aa3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 09:13:56 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 22 Mar 2024 05:13:56 -0400 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] Apply 1 suggestion(s) to 1 file(s) Message-ID: <65fd4bd4c331a_173821bf392b41136fa@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: fd1c7f9e by Hannes Siebenhandl at 2024-03-22T09:13:54+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1734,8 +1734,10 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. +-- +-- See Note [Multiple Home Units], section 'Closure Property'. checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [DriverMessages] checkHomeUnitsClosed ue home_id_set | Set.null bad_unit_ids = [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd1c7f9e61f823647d96a0e7d148090a08ab46a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd1c7f9e61f823647d96a0e7d148090a08ab46a2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 09:17:23 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 22 Mar 2024 05:17:23 -0400 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <65fd4ca3ed56c_173821c01f1b01159d5@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: ae757416 by Zubin Duggal at 2024-03-22T14:47:15+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 6 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,69 +1714,77 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +-- +-- See Note [Multiple Home Units], section 'Closure Property'. +checkHomeUnitsClosed :: UnitEnv -> [DriverMessages] +checkHomeUnitsClosed ue + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + home_id_set = unitEnv_keys $ ue_home_unit_graph ue + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae757416b07afc55e0515cac80084c2e0e346800 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae757416b07afc55e0515cac80084c2e0e346800 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 11:34:35 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 22 Mar 2024 07:34:35 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] Use symbol cache in internal interpreter too Message-ID: <65fd6ccbe104a_173821fc8495c13982b@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: b3d85333 by Rodrigo Mesquita at 2024-03-22T11:32:09+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. - - - - - 5 changed files: - compiler/GHC.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -394,6 +394,7 @@ import GHC.Types.Name.Ppr import GHC.Types.TypeEnv import GHC.Types.BreakInfo import GHC.Types.PkgQual +import GHC.Types.Unique.FM import GHC.Unit import GHC.Unit.Env @@ -673,6 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger + lookup_cache <- liftIO $ newMVar emptyUFM -- Interpreter interp <- if @@ -702,7 +704,7 @@ setTopSessionDynFlags dflags = do } s <- liftIO $ newMVar InterpPending loader <- liftIO Loader.uninitializedLoader - return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader)) + return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) -- JavaScript interpreter | ArchJavaScript <- platformArch (targetPlatform dflags) @@ -720,7 +722,7 @@ setTopSessionDynFlags dflags = do , jsInterpFinderOpts = initFinderOpts dflags , jsInterpFinderCache = hsc_FC hsc_env } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader)) + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) -- Internal interpreter | otherwise @@ -728,7 +730,7 @@ setTopSessionDynFlags dflags = do #if defined(HAVE_INTERNAL_INTERPRETER) do loader <- liftIO Loader.uninitializedLoader - return (Just (Interp InternalInterp loader)) + return (Just (Interp InternalInterp loader lookup_cache)) #else return Nothing #endif ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -2665,7 +2665,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do case interp of -- always generate JS code for the JS interpreter (no bytecode!) - Interp (ExternalInterp (ExtJS i)) _ -> + Interp (ExternalInterp (ExtJS i)) _ _ -> jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id _ -> do ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -152,22 +152,22 @@ The main pieces are: - implementation of Template Haskell (GHCi.TH) - a few other things needed to run interpreted code -- top-level iserv directory, containing the codefor the external - server. This is a fairly simple wrapper, most of the functionality +- top-level iserv directory, containing the code for the external + server. This is a fairly simple wrapper, most of the functionality is provided by modules in libraries/ghci. - This module which provides the interface to the server used by the rest of GHC. -GHC works with and without -fexternal-interpreter. With the flag, all -interpreted code is run by the iserv binary. Without the flag, +GHC works with and without -fexternal-interpreter. With the flag, all +interpreted code is run by the iserv binary. Without the flag, interpreted code is run in the same process as GHC. Things that do not work with -fexternal-interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dynCompileExpr cannot work, because we have no way to run code of an -unknown type in the remote process. This API fails with an error +unknown type in the remote process. This API fails with an error message if it is used with -fexternal-interpreter. Other Notes on Remote GHCi @@ -441,32 +441,36 @@ initObjLinker :: Interp -> IO () initObjLinker interp = interpCmd interp InitLinker lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) -lookupSymbol interp str = case interpInstance interp of +lookupSymbol interp str = do + + -- Profiling of GHCi showed a lot of time and allocation spent + -- making cross-process LookupSymbol calls, so I added a GHC-side + -- cache which sped things up quite a lot. We have to be careful + -- to purge this cache when unloading code though. + -- + -- The analysis in #23415 further showed this cache should also benefit the + -- internal interpreter's loading times, and needn't be used by the external + -- interpreter only. + cache <- readMVar (interpLookupSymbolCache interp) + case lookupUFM cache str of + Just p -> return (Just p) + Nothing -> do + rm <- case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) + InternalInterp -> run (LookupSymbol (unpackFS str)) #endif - - ExternalInterp ext -> case ext of - ExtIServ i -> withIServ i $ \inst -> do - -- Profiling of GHCi showed a lot of time and allocation spent - -- making cross-process LookupSymbol calls, so I added a GHC-side - -- cache which sped things up quite a lot. We have to be careful - -- to purge this cache when unloading code though. - cache <- readMVar (instLookupSymbolCache inst) - case lookupUFM cache str of - Just p -> return (Just p) - Nothing -> do - m <- uninterruptibleMask_ $ - sendMessage inst (LookupSymbol (unpackFS str)) - case m of - Nothing -> return Nothing - Just r -> do - let p = fromRemotePtr r - cache' = addToUFM cache str p - modifyMVar_ (instLookupSymbolCache inst) (const (pure cache')) - return (Just p) - - ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbol (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + case rm of + Nothing -> return Nothing + Just r -> do + let p = fromRemotePtr r + cache' = addToUFM cache str p + modifyMVar_ (interpLookupSymbolCache interp) (const (pure cache')) + return (Just p) lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) lookupSymbolInDLL interp dll str = case interpInstance interp of @@ -480,13 +484,7 @@ lookupClosure interp str = interpCmd interp (LookupClosure str) purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = case interpInstance interp of -#if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> pure () -#endif - ExternalInterp ext -> withExtInterpMaybe ext $ \case - Nothing -> pure () -- interpreter stopped, nothing to do - Just inst -> modifyMVar_ (instLookupSymbolCache inst) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = modifyMVar_ (interpLookupSymbolCache interp) (const (pure emptyUFM)) -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either @@ -552,11 +550,9 @@ spawnIServ conf = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = process , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = () } pure inst ===================================== compiler/GHC/Runtime/Interpreter/JS.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Utils.Panic import GHC.Utils.Error (logInfo) import GHC.Utils.Outputable (text) import GHC.Data.FastString -import GHC.Types.Unique.FM import Control.Concurrent import Control.Monad @@ -178,11 +177,9 @@ spawnJSInterp cfg = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = proc , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = extra } ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -51,6 +51,9 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader + + , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + -- ^ LookupSymbol cache } data InterpInstance @@ -108,9 +111,6 @@ data ExtInterpInstance c = ExtInterpInstance -- Finalizers for ForeignRefs can append values to this list -- asynchronously. - , instLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) - -- ^ LookupSymbol cache - , instExtra :: !c -- ^ Instance specific extra fields } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3d853334003f5b63a10293b8c7b631ddcf9b69f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3d853334003f5b63a10293b8c7b631ddcf9b69f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 12:06:21 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 22 Mar 2024 08:06:21 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] Use symbol cache in internal interpreter too Message-ID: <65fd743d419d3_17382110b0907c1469e7@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 868226bc by Rodrigo Mesquita at 2024-03-22T12:04:25+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - 5 changed files: - compiler/GHC.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -394,6 +394,7 @@ import GHC.Types.Name.Ppr import GHC.Types.TypeEnv import GHC.Types.BreakInfo import GHC.Types.PkgQual +import GHC.Types.Unique.FM import GHC.Unit import GHC.Unit.Env @@ -673,6 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger + lookup_cache <- liftIO $ newMVar emptyUFM -- Interpreter interp <- if @@ -702,7 +704,7 @@ setTopSessionDynFlags dflags = do } s <- liftIO $ newMVar InterpPending loader <- liftIO Loader.uninitializedLoader - return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader)) + return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) -- JavaScript interpreter | ArchJavaScript <- platformArch (targetPlatform dflags) @@ -720,7 +722,7 @@ setTopSessionDynFlags dflags = do , jsInterpFinderOpts = initFinderOpts dflags , jsInterpFinderCache = hsc_FC hsc_env } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader)) + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) -- Internal interpreter | otherwise @@ -728,7 +730,7 @@ setTopSessionDynFlags dflags = do #if defined(HAVE_INTERNAL_INTERPRETER) do loader <- liftIO Loader.uninitializedLoader - return (Just (Interp InternalInterp loader)) + return (Just (Interp InternalInterp loader lookup_cache)) #else return Nothing #endif ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -2665,7 +2665,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do case interp of -- always generate JS code for the JS interpreter (no bytecode!) - Interp (ExternalInterp (ExtJS i)) _ -> + Interp (ExternalInterp (ExtJS i)) _ _ -> jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id _ -> do ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -152,22 +152,22 @@ The main pieces are: - implementation of Template Haskell (GHCi.TH) - a few other things needed to run interpreted code -- top-level iserv directory, containing the codefor the external - server. This is a fairly simple wrapper, most of the functionality +- top-level iserv directory, containing the code for the external + server. This is a fairly simple wrapper, most of the functionality is provided by modules in libraries/ghci. - This module which provides the interface to the server used by the rest of GHC. -GHC works with and without -fexternal-interpreter. With the flag, all -interpreted code is run by the iserv binary. Without the flag, +GHC works with and without -fexternal-interpreter. With the flag, all +interpreted code is run by the iserv binary. Without the flag, interpreted code is run in the same process as GHC. Things that do not work with -fexternal-interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dynCompileExpr cannot work, because we have no way to run code of an -unknown type in the remote process. This API fails with an error +unknown type in the remote process. This API fails with an error message if it is used with -fexternal-interpreter. Other Notes on Remote GHCi @@ -441,52 +441,67 @@ initObjLinker :: Interp -> IO () initObjLinker interp = interpCmd interp InitLinker lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) -lookupSymbol interp str = case interpInstance interp of +lookupSymbol interp str = withSymbolCache interp str $ + case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) #endif - - ExternalInterp ext -> case ext of - ExtIServ i -> withIServ i $ \inst -> do - -- Profiling of GHCi showed a lot of time and allocation spent - -- making cross-process LookupSymbol calls, so I added a GHC-side - -- cache which sped things up quite a lot. We have to be careful - -- to purge this cache when unloading code though. - cache <- readMVar (instLookupSymbolCache inst) - case lookupUFM cache str of - Just p -> return (Just p) - Nothing -> do - m <- uninterruptibleMask_ $ - sendMessage inst (LookupSymbol (unpackFS str)) - case m of - Nothing -> return Nothing - Just r -> do - let p = fromRemotePtr r - cache' = addToUFM cache str p - modifyMVar_ (instLookupSymbolCache inst) (const (pure cache')) - return (Just p) - - ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbol (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) -lookupSymbolInDLL interp dll str = case interpInstance interp of +lookupSymbolInDLL interp dll str = withSymbolCache interp str $ + case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) #endif - ExternalInterp _ -> panic "lookupSymbolInDLL: not implemented for external interpreter" -- FIXME + ExternalInterp _ -> panic "lookupSymbolInDLL: not implemented for external interpreter" -- FIXME lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = interpCmd interp (LookupClosure str) +-- | 'withSymbolCache' tries to find a symbol in the 'interpLookupSymbolCache' +-- which maps symbols to the address where they are loaded. +-- When there's a cache hit we simply return the cached address, when there is +-- a miss we run the action which determines the symbol's address and populate +-- the cache with the answer. +withSymbolCache :: Interp + -> FastString + -- ^ The symbol we are looking up in the cache + -> IO (Maybe (Ptr ())) + -- ^ An action which determines the address of the symbol we + -- are looking up in the cache, which is run if there is a + -- cache miss. The result will be cached. + -> IO (Maybe (Ptr ())) +withSymbolCache interp str determine_addr = do + + -- Profiling of GHCi showed a lot of time and allocation spent + -- making cross-process LookupSymbol calls, so I added a GHC-side + -- cache which sped things up quite a lot. We have to be careful + -- to purge this cache when unloading code though. + -- + -- The analysis in #23415 further showed this cache should also benefit the + -- internal interpreter's loading times, and needn't be used by the external + -- interpreter only. + cache <- readMVar (interpLookupSymbolCache interp) + case lookupUFM cache str of + Just p -> return (Just p) + Nothing -> do + + maddr <- determine_addr + case maddr of + Nothing -> return Nothing + Just p -> do + let cache' = addToUFM cache str p + modifyMVar_ (interpLookupSymbolCache interp) (const (pure cache')) + return (Just p) + purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = case interpInstance interp of -#if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> pure () -#endif - ExternalInterp ext -> withExtInterpMaybe ext $ \case - Nothing -> pure () -- interpreter stopped, nothing to do - Just inst -> modifyMVar_ (instLookupSymbolCache inst) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = modifyMVar_ (interpLookupSymbolCache interp) (const (pure emptyUFM)) -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either @@ -552,11 +567,9 @@ spawnIServ conf = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = process , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = () } pure inst ===================================== compiler/GHC/Runtime/Interpreter/JS.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Utils.Panic import GHC.Utils.Error (logInfo) import GHC.Utils.Outputable (text) import GHC.Data.FastString -import GHC.Types.Unique.FM import Control.Concurrent import Control.Monad @@ -178,11 +177,9 @@ spawnJSInterp cfg = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = proc , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = extra } ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -51,6 +51,9 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader + + , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + -- ^ LookupSymbol cache } data InterpInstance @@ -108,9 +111,6 @@ data ExtInterpInstance c = ExtInterpInstance -- Finalizers for ForeignRefs can append values to this list -- asynchronously. - , instLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) - -- ^ LookupSymbol cache - , instExtra :: !c -- ^ Instance specific extra fields } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/868226bcfb15e512e36ceb3651d17e5fd2fb5b8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/868226bcfb15e512e36ceb3651d17e5fd2fb5b8f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 12:12:56 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 08:12:56 -0400 Subject: [Git][ghc/ghc][wip/T24553] 5 commits: Type-check default declarations before deriving clauses (#24566) Message-ID: <65fd75c88a785_17382110c1ae5c149763@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - e42aa904 by Simon Peyton Jones at 2024-03-22T12:12:29+00:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 23 changed files: - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - libraries/ghc-internal/src/GHC/Internal/Maybe.hs - + testsuite/tests/simplCore/should_compile/T24551.hs - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/typecheck/should_compile/Makefile - + testsuite/tests/typecheck/should_compile/T24566.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -228,7 +228,7 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = andEq TEQX e = hasCast e andEq TEQ e = e - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare go (D _ (TyConApp tc1 [])) (D _ (TyConApp tc2 [])) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -85,6 +85,8 @@ import GHC.Utils.Panic import Control.Monad ( when ) import Data.List ( sortBy ) +import GHC.Types.Name.Env +import Data.Graph {- ********************************************************************* * * @@ -2108,6 +2110,27 @@ new binding is abstracted. Several points worth noting which showed that it's harder to do polymorphic specialisation well if there are dictionaries abstracted over unnecessary type variables. See Note [Weird special case for SpecDict] in GHC.Core.Opt.Specialise + +(AB5) We do dependency analysis on recursive groups prior to determining + which variables to abstract over. + This is useful, because ANFisation in prepareBinding may float out + values out of a complex recursive binding, e.g., + letrec { xs = g @a "blah"# ((:) 1 []) xs } in ... + ==> { prepareBinding } + letrec { foo = "blah"# + bar = [42] + xs = g @a foo bar xs } in + ... + and we don't want to abstract foo and bar over @a. + + (Why is it OK to float the unlifted `foo` there? + See Note [Core top-level string literals] in GHC.Core; + it is controlled by GHC.Core.Opt.Simplify.Env.unitLetFloat.) + + It is also necessary to do dependency analysis, because + otherwise (in #24551) we might get `foo = \@_ -> "missing"#` at the + top-level, and that triggers a CoreLint error because `foo` is *not* + manifestly a literal string. -} abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats @@ -2115,15 +2138,27 @@ abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats abstractFloats uf_opts top_lvl main_tvs floats body = assert (notNull body_floats) $ assert (isNilOL (sfJoinFloats floats)) $ - do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats + do { let sccs = concatMap to_sccs body_floats + ; (subst, float_binds) <- mapAccumLM abstract empty_subst sccs ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl body_floats = letFloatBinds (sfLetFloats floats) empty_subst = GHC.Core.Subst.mkEmptySubst (sfInScope floats) - abstract :: GHC.Core.Subst.Subst -> OutBind -> SimplM (GHC.Core.Subst.Subst, OutBind) - abstract subst (NonRec id rhs) + -- See wrinkle (AB5) in Note [Which type variables to abstract over] + -- for why we need to re-do dependency analysis + to_sccs :: OutBind -> [SCC (Id, CoreExpr, VarSet)] + to_sccs (NonRec id e) = [AcyclicSCC (id, e, emptyVarSet)] -- emptyVarSet: abstract doesn't need it + to_sccs (Rec prs) = sccs + where + (ids,rhss) = unzip prs + sccs = depAnal (\(id,_rhs,_fvs) -> [getName id]) + (\(_id,_rhs,fvs) -> nonDetStrictFoldVarSet ((:) . getName) [] fvs) -- Wrinkle (AB3) + (zip3 ids rhss (map exprFreeVars rhss)) + + abstract :: GHC.Core.Subst.Subst -> SCC (Id, CoreExpr, VarSet) -> SimplM (GHC.Core.Subst.Subst, OutBind) + abstract subst (AcyclicSCC (id, rhs, _empty_var_set)) = do { (poly_id1, poly_app) <- mk_poly1 tvs_here id ; let (poly_id2, poly_rhs) = mk_poly2 poly_id1 tvs_here rhs' !subst' = GHC.Core.Subst.extendIdSubst subst id poly_app @@ -2134,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body -- tvs_here: see Note [Which type variables to abstract over] tvs_here = choose_tvs (exprSomeFreeVars isTyVar rhs') - abstract subst (Rec prs) + abstract subst (CyclicSCC trpls) = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' @@ -2142,15 +2177,15 @@ abstractFloats uf_opts top_lvl main_tvs floats body , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where - (ids,rhss) = unzip prs - + (ids,rhss,_fvss) = unzip3 trpls -- tvs_here: see Note [Which type variables to abstract over] - tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs prs) + tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs trpls) -- See wrinkle (AB4) in Note [Which type variables to abstract over] - get_bind_fvs (id,rhs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs - get_rec_rhs_tvs rhs = nonDetStrictFoldVarSet get_tvs emptyVarSet (exprFreeVars rhs) + get_bind_fvs (id,_rhs,rhs_fvs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs_fvs + get_rec_rhs_tvs rhs_fvs = nonDetStrictFoldVarSet get_tvs emptyVarSet rhs_fvs + -- nonDet is safe because of wrinkle (AB3) get_tvs :: Var -> VarSet -> VarSet get_tvs var free_tvs ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -12,8 +12,9 @@ module GHC.Core.TyCo.Compare ( nonDetCmpTypesX, nonDetCmpTc, eqVarBndrs, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTyConApps, + mayLookIdentical, -- * Visiblity comparision eqForAllVis, cmpForAllVis @@ -22,7 +23,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -129,52 +131,114 @@ Cabal. See #19226. -} +mayLookIdentical :: Type -> Type -> Bool +-- | Returns True if the /visible/ part of the types +-- might look equal, even if they are really unequal (in the invisible bits) +-- Always safe to return True -- this affects error messages only +mayLookIdentical orig_ty1 orig_ty2 + = go orig_env orig_ty1 orig_ty2 + where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + + go :: RnEnv2 -> Type -> Type -> Bool + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True + + go env t1 t2 | Just t1' <- coreView t1 = go env t1' t2 + go env t1 t2 | Just t2' <- coreView t2 = go env t1 t2' + + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True + + go env (ForAllTy (Bndr tv1 vis1) ty1) + (ForAllTy (Bndr tv2 vis2) ty2) + = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] + && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- Visible stuff only: ignore kinds of binders + + -- If we have (forall (r::RunTimeRep). ty1 ~ blah) then respond + -- with True. Reason: the type pretty-printer defaults RuntimeRep + -- foralls (see Ghc.Iface.Type.hideNonStandardTypes). That can make, + -- say (forall r. TYPE r -> Type) into (Type -> Type), so it looks the + -- same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of mayLookIdentical) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | isDefaultableBndr b = True + go _ _ (ForAllTy b _) | isDefaultableBndr b = True + + go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) + = go env arg1 arg2 && go env res1 res2 && go env w1 w2 + -- Visible stuff only: ignore agg kinds + + -- See Note [Equality on AppTys] in GHC.Core.Type + go env (AppTy s1 t1) ty2 + | Just (s2, t2) <- tcSplitAppTyNoView_maybe ty2 + = go env s1 s2 && go env t1 t2 + go env ty1 (AppTy s2 t2) + | Just (s1, t1) <- tcSplitAppTyNoView_maybe ty1 + = go env s1 s2 && go env t1 t2 + + go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) + = tc1 == tc2 && gos env (tyConBinders tc1) ts1 ts2 + + go _ _ _ = False + + gos :: RnEnv2 -> [TyConBinder] -> [Type] -> [Type] -> Bool + gos _ _ [] [] = True + gos env bs (t1:ts1) (t2:ts2) + | (invisible, bs') <- case bs of + [] -> (True,[]) + (b:bs) -> (isInvisibleTyConBinder b, bs) + = (invisible || go env t1 t2) && gos env bs' ts1 ts2 + + gos _ _ _ _ = False + + -- | Type equality comparing both visible and invisible arguments and expanding -- type synonyms. tcEqTypeNoSyns :: Type -> Type -> Bool -tcEqTypeNoSyns ta tb = tc_eq_type False False ta tb - --- | Like 'tcEqType', but returns True if the /visible/ part of the types --- are equal, even if they are really unequal (in the invisible bits) -tcEqTypeVis :: Type -> Type -> Bool -tcEqTypeVis ty1 ty2 = tc_eq_type False True ty1 ty2 +tcEqTypeNoSyns ta tb = tc_eq_type False ta tb -- | Like 'pickyEqTypeVis', but returns a Bool for convenience pickyEqType :: Type -> Type -> Bool -- Check when two types _look_ the same, _including_ synonyms. -- So (pickyEqType String [Char]) returns False -- This ignores kinds and coercions, because this is used only for printing. -pickyEqType ty1 ty2 = tc_eq_type True False ty1 ty2 +pickyEqType ty1 ty2 = tc_eq_type True ty1 ty2 -- | Real worker for 'tcEqType'. No kind check! tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms - -> Bool -- ^ True <=> compare visible args only -> Type -> Type -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type -tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +tc_eq_type keep_syns orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + go :: RnEnv2 -> Type -> Type -> Bool - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. - go _ (TyConApp tc1 []) (TyConApp tc2 []) - | tc1 == tc2 - = True + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True go env t1 t2 | not keep_syns, Just t1' <- coreView t1 = go env t1' t2 go env t1 t2 | not keep_syns, Just t2' <- coreView t2 = go env t1 t2' - go env (TyVarTy tv1) (TyVarTy tv2) - = rnOccL env tv1 == rnOccR env tv2 - - go _ (LitTy lit1) (LitTy lit2) - = lit1 == lit2 + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] - && (vis_only || go env (varType tv1) (varType tv2)) + && go env (varType tv1) (varType tv2) && go (rnBndr2 env tv1 tv2) ty1 ty2 -- Make sure we handle all FunTy cases since falling through to the @@ -183,11 +247,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- See Note [Equality on FunTys] in GHC.Core.TyCo.Rep: we must check -- kinds here go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) - = kinds_eq && go env arg1 arg2 && go env res1 res2 && go env w1 w2 - where - kinds_eq | vis_only = True - | otherwise = go env (typeKind arg1) (typeKind arg2) && - go env (typeKind res1) (typeKind res2) + = go env (typeKind arg1) (typeKind arg2) && + go env (typeKind res1) (typeKind res2) && + go env arg1 arg2 && go env res1 res2 && go env w1 w2 -- See Note [Equality on AppTys] in GHC.Core.Type go env (AppTy s1 t1) ty2 @@ -198,32 +260,24 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go env s1 s2 && go env t1 t2 go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) - = tc1 == tc2 && gos env (tc_vis tc1) ts1 ts2 - - go env (CastTy t1 _) t2 = go env t1 t2 - go env t1 (CastTy t2 _) = go env t1 t2 - go _ (CoercionTy {}) (CoercionTy {}) = True + = tc1 == tc2 && gos env ts1 ts2 go _ _ _ = False - gos _ _ [] [] = True - gos env (ig:igs) (t1:ts1) (t2:ts2) = (ig || go env t1 t2) - && gos env igs ts1 ts2 - gos _ _ _ _ = False + gos _ [] [] = True + gos env (t1:ts1) (t2:ts2) = go env t1 t2 && gos env ts1 ts2 + gos _ _ _ = False - tc_vis :: TyCon -> [Bool] -- True for the fields we should ignore - tc_vis tc | vis_only = inviss ++ repeat False -- Ignore invisibles - | otherwise = repeat False -- Ignore nothing - -- The repeat False is necessary because tycons - -- can legitimately be oversaturated - where - bndrs = tyConBinders tc - inviss = map isInvisibleTyConBinder bndrs - - orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] - -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function @@ -543,7 +597,7 @@ nonDetCmpTypeX env orig_t1 orig_t2 = -- Returns both the resulting ordering relation between -- the two types and whether either contains a cast. go :: RnEnv2 -> Type -> Type -> TypeOrdering - -- See Note [Comparing nullary type synonyms]. + -- See Note [Comparing nullary type synonyms] go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1066,7 +1066,7 @@ unify_ty :: UMEnv -- Respects newtypes, PredTypes -- See Note [Computing equality on types] in GHC.Core.Type unify_ty _env (TyConApp tc1 []) (TyConApp tc2 []) _kco - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare | tc1 == tc2 = return () ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2814,19 +2814,19 @@ characters into single bytes. {-# INLINE adjustChar #-} adjustChar :: Char -> Word8 -adjustChar c = fromIntegral $ ord adj_c - where non_graphic = '\x00' - upper = '\x01' - lower = '\x02' - digit = '\x03' - symbol = '\x04' - space = '\x05' - other_graphic = '\x06' - uniidchar = '\x07' +adjustChar c = adj_c + where non_graphic = 0x00 + upper = 0x01 + lower = 0x02 + digit = 0x03 + symbol = 0x04 + space = 0x05 + other_graphic = 0x06 + uniidchar = 0x07 adj_c | c <= '\x07' = non_graphic - | c <= '\x7f' = c + | c <= '\x7f' = fromIntegral (ord c) -- Alex doesn't handle Unicode, so when Unicode -- character is encountered we output these values -- with the actual character value hidden in the state. @@ -2866,15 +2866,18 @@ adjustChar c = fromIntegral $ ord adj_c -- -- See Note [Unicode in Alex] and #13986. alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (AI _ buf) = chr (fromIntegral (adjustChar pc)) +alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' +unsafeChr :: Int -> Char +unsafeChr (I# c) = C# (chr# c) + -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) alexGetChar inp = case alexGetByte inp of Nothing -> Nothing Just (b,i) -> c `seq` Just (c,i) - where c = chr $ fromIntegral b + where c = unsafeChr $ fromIntegral b -- See Note [Unicode in Alex] alexGetByte :: AlexInput -> Maybe (Word8,AlexInput) ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -738,7 +738,7 @@ writeExterns out = writeFile (out "all.js.externs") -- | Get all block dependencies for a given set of roots -- --- Returns the update block info map and the blocks. +-- Returns the updated block info map and the blocks. getDeps :: Map Module LocatedBlockInfo -- ^ Block info per module -> (Module -> IO LocatedBlockInfo) -- ^ Used to load block info if missing -> Set ExportedFun -- ^ start here @@ -754,7 +754,7 @@ getDeps init_infos load_info root_funs root_blocks = traverse_funs init_infos S. -- 1. We use the BlockInfos to find the block corresponding to every -- exported root functions. -- - -- 2. We had these blocks to the set of root_blocks if they aren't already + -- 2. We add these blocks to the set of root_blocks if they aren't already -- added to the result. -- -- 3. Then we traverse the root_blocks to find their dependencies and we ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,60 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = mayLookIdentical act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = mayLookIdentical ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when we find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by + `GHC.Core.TyCo.Compare.mayLookIdentical` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6089,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6172,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6434,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6458,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -709,7 +709,7 @@ tcRnHsBootDecls boot_or_sig decls -- Typecheck type/class/instance decls ; traceTc "Tc2 (boot)" empty ; (tcg_env, inst_infos, _deriv_binds, _th_bndrs) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds + <- tcTyClsInstDecls tycl_decls deriv_decls def_decls val_binds ; setGblEnv tcg_env $ do { -- Emit Typeable bindings @@ -1612,7 +1612,7 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, traceTc "Tc3" empty ; (tcg_env, inst_infos, th_bndrs, XValBindsLR (NValBinds deriv_binds deriv_sigs)) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds ; + <- tcTyClsInstDecls tycl_decls deriv_decls default_decls val_binds ; updLclCtxt (\tcl_env -> tcl_env { tcl_th_bndrs = th_bndrs `plusNameEnv` tcl_th_bndrs tcl_env }) $ setGblEnv tcg_env $ do { @@ -1622,11 +1622,6 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, (fi_ids, fi_decls, fi_gres) <- tcForeignImports foreign_decls ; tcExtendGlobalValEnv fi_ids $ do { - -- Default declarations - traceTc "Tc4a" empty ; - default_tys <- tcDefaults default_decls ; - updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { - -- Value declarations next. -- It is important that we check the top-level value bindings -- before the GHC-generated derived bindings, since the latter @@ -1686,13 +1681,14 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, addUsedGREs NoDeprecationWarnings (bagToList fo_gres) ; return (tcg_env', tcl_env) - }}}}}} + }}}}} tcTopSrcDecls _ = panic "tcTopSrcDecls: ValBindsIn" --------------------------- tcTyClsInstDecls :: [TyClGroup GhcRn] -> [LDerivDecl GhcRn] + -> [LDefaultDecl GhcRn] -> [(RecFlag, LHsBinds GhcRn)] -> TcM (TcGblEnv, -- The full inst env [InstInfo GhcRn], -- Source-code instance decls to @@ -1702,16 +1698,24 @@ tcTyClsInstDecls :: [TyClGroup GhcRn] HsValBinds GhcRn) -- Supporting bindings for derived -- instances -tcTyClsInstDecls tycl_decls deriv_decls binds +tcTyClsInstDecls tycl_decls deriv_decls default_decls binds = tcAddDataFamConPlaceholders (tycl_decls >>= group_instds) $ tcAddPatSynPlaceholders (getPatSynBinds binds) $ do { (tcg_env, inst_info, deriv_info, th_bndrs) <- tcTyAndClassDecls tycl_decls ; + ; setGblEnv tcg_env $ do { + -- With the @TyClDecl at s and @InstDecl at s checked we're ready to -- process the deriving clauses, including data family deriving -- clauses discovered in @tcTyAndClassDecls at . -- + -- But only after we've typechecked 'default' declarations. + -- See Note [Typechecking default declarations] + default_tys <- tcDefaults default_decls ; + updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { + + -- Careful to quit now in case there were instance errors, so that -- the deriving errors don't pile up as well. ; failIfErrsM @@ -1720,7 +1724,7 @@ tcTyClsInstDecls tycl_decls deriv_decls binds ; setGblEnv tcg_env' $ do { failIfErrsM ; pure ( tcg_env', inst_info' ++ inst_info, th_bndrs, val_binds ) - }}} + }}}} {- ********************************************************************* * * @@ -3141,3 +3145,43 @@ mark_plugin_unsafe dflags = unless (gopt Opt_PluginTrustworthy dflags) $ pluginUnsafe = singleMessage $ mkPlainMsgEnvelope diag_opts noSrcSpan TcRnUnsafeDueToPlugin + + +-- Note [Typechecking default declarations] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Typechecking default declarations requires careful placement: +-- +-- 1. We must check them after types (tcTyAndClassDecls) because they can refer +-- to them. E.g. +-- +-- data T = MkT ... +-- default(Int, T, Integer) +-- +-- -- or even (tested by T11974b and T2245) +-- default(Int, T, Integer) +-- data T = MkT ... +-- +-- 2. We must check them before typechecking deriving clauses (tcInstDeclsDeriv) +-- otherwise we may lookup default default types (Integer, Double) while checking +-- deriving clauses, ignoring the default declaration. +-- +-- Before this careful placement (#24566), compiling the following example +-- (T24566) with "-ddump-if-trace -ddump-tc-trace" showed a call to +-- `applyDefaultingRules` with default types set to "(Integer,Double)": +-- +-- module M where +-- +-- import GHC.Classes +-- default () +-- +-- data Foo a = Nothing | Just a +-- deriving (Eq, Ord) +-- +-- This was an issue while building modules like M in the ghc-internal package +-- because they would spuriously fail to build if the module defining Integer +-- (ghc-bignum:GHC.Num.Integer) wasn't compiled yet and its interface not to be +-- found. The implicit dependency between M and GHC.Num.Integer isn't known to +-- the build system. +-- In addition, trying to explicitly avoid the implicit dependency with `default +-- ()` didn't work, except if *standalone* deriving was used, which was an +-- inconsistent behavior. ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -311,7 +311,7 @@ can_eq_nc -> Type -> Type -- RHS, after and before type-synonym expansion, resp -> TcS (StopOrContinue (Either IrredCt EqCt)) --- See Note [Comparing nullary type synonyms] in GHC.Core.Type. +-- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare can_eq_nc _flat _rdr_env _envs ev eq_rel ty1@(TyConApp tc1 []) _ps_ty1 (TyConApp tc2 []) _ps_ty2 | tc1 == tc2 = canEqReflexive ev eq_rel ty1 ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -95,7 +95,7 @@ module GHC.Tc.Utils.TcType ( -- Re-exported from GHC.Core.TyCo.Compare -- mainly just for back-compat reasons eqType, eqTypes, nonDetCmpType, nonDetCmpTypes, eqTypeX, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, mayLookIdentical, tcEqTyConApps, eqForAllVis, eqVarBndrs, --------------------------------- @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== libraries/ghc-internal/src/GHC/Internal/Maybe.hs ===================================== @@ -28,14 +28,5 @@ default () -- data Maybe a = Nothing | Just a deriving ( Eq -- ^ @since base-2.01 - - --, Ord -- ^ @since base-2.01 + , Ord -- ^ @since base-2.01 ) - --- ??? --- A non-standalone instance will slurp the interface file for GHC.Num.Integer. - -- During simplifyInstanceContexts, a call to GHC.Tc.Utils.Env.tcGetDefaultTys - -- apparently sees mb_defaults = Nothing and thus tries to bring in the - -- default "default" types, including Integer. This seems wrong. -deriving instance Ord a => Ord (Maybe a) -- ^ @since base-2.01 - ===================================== testsuite/tests/simplCore/should_compile/T24551.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module T24551 (f) where + +import GHC.Exts + +f :: a -> a +f = repeatFB g + +repeatFB :: (Addr# -> (a -> a) -> a -> a) -> a -> a +repeatFB c = let xs = c "missing"# xs in xs +{-# INLINE [0] repeatFB #-} + +g :: Addr# -> (a -> a) -> a -> a +g _ _ x = x +{-# NOINLINE g #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T23209', [extra_files(['T23209_Aux.hs'])], multimod_compile, ['T23209', '- test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) +test('T24551', normal, compile, ['-O -dcore-lint']) ===================================== testsuite/tests/typecheck/should_compile/Makefile ===================================== @@ -122,3 +122,7 @@ InlinePatSyn_ExplicitBidiBuilder: InlinePatSyn_ExplicitBidiMatcher: $(RM) -f InlinePatSyn_ExplicitBidiMatcher.o InlinePatSyn_ExplicitBidiMatcher.hi '$(TEST_HC)' $(TEST_HC_OPTS) -c InlinePatSyn_ExplicitBidiMatcher.hs -O -dsuppress-all -ddump-simpl | sed -n '/^test/,/^$$/p' | grep -vq 'Pattern' + +T24566: + '$(TEST_HC)' $(TEST_HC_OPTS) -c T24566.hs -fno-code -dno-typeable-binds -ddump-if-trace 2>&1 | grep Integer || true + # Not expecting any mention of Integer in the interface loading trace ===================================== testsuite/tests/typecheck/should_compile/T24566.hs ===================================== @@ -0,0 +1,7 @@ +module M where + +import GHC.Classes +default () + +data Foo a = Nothing | Just a + deriving (Eq, Ord) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -913,3 +913,4 @@ test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) test('T24470b', normal, compile, ['']) +test('T24566', [], makefile_test, []) ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f072fdcb4d6aa128bf4fd262b4523854ec075e25...e42aa90444ab522a689ba5ab211d9331103b2a5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f072fdcb4d6aa128bf4fd262b4523854ec075e25...e42aa90444ab522a689ba5ab211d9331103b2a5f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 14:09:48 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 22 Mar 2024 10:09:48 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Type-check default declarations before deriving clauses (#24566) Message-ID: <65fd912c63c07_11451d2cc90283127a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 4b676966 by Zubin Duggal at 2024-03-22T10:09:16-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 0aeb789f by Andreas Klebinger at 2024-03-22T10:09:17-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 28 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/Tc/Module.hs - libraries/ghc-internal/src/GHC/Internal/Maybe.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr - + testsuite/tests/simplCore/should_compile/T24551.hs - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/typecheck/should_compile/Makefile - + testsuite/tests/typecheck/should_compile/T24566.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,15 +301,20 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr _ = [] +jumpDestsOfInstr i = case i of + (CBZ _ t) -> [ mkDest t ] + (CBNZ _ t) -> [ mkDest t ] + (J t) -> [ mkDest t ] + (B t) -> [ mkDest t ] + (BL t _ _) -> [ mkDest t ] + (BCOND _ t) -> [ mkDest t ] + _ -> [] + where + mkDest (TBlock id) = Just id + mkDest TLabel{} = Nothing + mkDest TReg{} = Nothing -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,15 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> targets + BCTRL{} -> [Nothing] + BL{} -> [Nothing] + JMP{} -> [Nothing] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -85,6 +85,8 @@ import GHC.Utils.Panic import Control.Monad ( when ) import Data.List ( sortBy ) +import GHC.Types.Name.Env +import Data.Graph {- ********************************************************************* * * @@ -2108,6 +2110,27 @@ new binding is abstracted. Several points worth noting which showed that it's harder to do polymorphic specialisation well if there are dictionaries abstracted over unnecessary type variables. See Note [Weird special case for SpecDict] in GHC.Core.Opt.Specialise + +(AB5) We do dependency analysis on recursive groups prior to determining + which variables to abstract over. + This is useful, because ANFisation in prepareBinding may float out + values out of a complex recursive binding, e.g., + letrec { xs = g @a "blah"# ((:) 1 []) xs } in ... + ==> { prepareBinding } + letrec { foo = "blah"# + bar = [42] + xs = g @a foo bar xs } in + ... + and we don't want to abstract foo and bar over @a. + + (Why is it OK to float the unlifted `foo` there? + See Note [Core top-level string literals] in GHC.Core; + it is controlled by GHC.Core.Opt.Simplify.Env.unitLetFloat.) + + It is also necessary to do dependency analysis, because + otherwise (in #24551) we might get `foo = \@_ -> "missing"#` at the + top-level, and that triggers a CoreLint error because `foo` is *not* + manifestly a literal string. -} abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats @@ -2115,15 +2138,27 @@ abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats abstractFloats uf_opts top_lvl main_tvs floats body = assert (notNull body_floats) $ assert (isNilOL (sfJoinFloats floats)) $ - do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats + do { let sccs = concatMap to_sccs body_floats + ; (subst, float_binds) <- mapAccumLM abstract empty_subst sccs ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl body_floats = letFloatBinds (sfLetFloats floats) empty_subst = GHC.Core.Subst.mkEmptySubst (sfInScope floats) - abstract :: GHC.Core.Subst.Subst -> OutBind -> SimplM (GHC.Core.Subst.Subst, OutBind) - abstract subst (NonRec id rhs) + -- See wrinkle (AB5) in Note [Which type variables to abstract over] + -- for why we need to re-do dependency analysis + to_sccs :: OutBind -> [SCC (Id, CoreExpr, VarSet)] + to_sccs (NonRec id e) = [AcyclicSCC (id, e, emptyVarSet)] -- emptyVarSet: abstract doesn't need it + to_sccs (Rec prs) = sccs + where + (ids,rhss) = unzip prs + sccs = depAnal (\(id,_rhs,_fvs) -> [getName id]) + (\(_id,_rhs,fvs) -> nonDetStrictFoldVarSet ((:) . getName) [] fvs) -- Wrinkle (AB3) + (zip3 ids rhss (map exprFreeVars rhss)) + + abstract :: GHC.Core.Subst.Subst -> SCC (Id, CoreExpr, VarSet) -> SimplM (GHC.Core.Subst.Subst, OutBind) + abstract subst (AcyclicSCC (id, rhs, _empty_var_set)) = do { (poly_id1, poly_app) <- mk_poly1 tvs_here id ; let (poly_id2, poly_rhs) = mk_poly2 poly_id1 tvs_here rhs' !subst' = GHC.Core.Subst.extendIdSubst subst id poly_app @@ -2134,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body -- tvs_here: see Note [Which type variables to abstract over] tvs_here = choose_tvs (exprSomeFreeVars isTyVar rhs') - abstract subst (Rec prs) + abstract subst (CyclicSCC trpls) = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' @@ -2142,15 +2177,15 @@ abstractFloats uf_opts top_lvl main_tvs floats body , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where - (ids,rhss) = unzip prs - + (ids,rhss,_fvss) = unzip3 trpls -- tvs_here: see Note [Which type variables to abstract over] - tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs prs) + tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs trpls) -- See wrinkle (AB4) in Note [Which type variables to abstract over] - get_bind_fvs (id,rhs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs - get_rec_rhs_tvs rhs = nonDetStrictFoldVarSet get_tvs emptyVarSet (exprFreeVars rhs) + get_bind_fvs (id,_rhs,rhs_fvs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs_fvs + get_rec_rhs_tvs rhs_fvs = nonDetStrictFoldVarSet get_tvs emptyVarSet rhs_fvs + -- nonDet is safe because of wrinkle (AB3) get_tvs :: Var -> VarSet -> VarSet get_tvs var free_tvs ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,69 +1714,77 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +-- +-- See Note [Multiple Home Units], section 'Closure Property'. +checkHomeUnitsClosed :: UnitEnv -> [DriverMessages] +checkHomeUnitsClosed ue + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + home_id_set = unitEnv_keys $ ue_home_unit_graph ue + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2814,19 +2814,19 @@ characters into single bytes. {-# INLINE adjustChar #-} adjustChar :: Char -> Word8 -adjustChar c = fromIntegral $ ord adj_c - where non_graphic = '\x00' - upper = '\x01' - lower = '\x02' - digit = '\x03' - symbol = '\x04' - space = '\x05' - other_graphic = '\x06' - uniidchar = '\x07' +adjustChar c = adj_c + where non_graphic = 0x00 + upper = 0x01 + lower = 0x02 + digit = 0x03 + symbol = 0x04 + space = 0x05 + other_graphic = 0x06 + uniidchar = 0x07 adj_c | c <= '\x07' = non_graphic - | c <= '\x7f' = c + | c <= '\x7f' = fromIntegral (ord c) -- Alex doesn't handle Unicode, so when Unicode -- character is encountered we output these values -- with the actual character value hidden in the state. @@ -2866,15 +2866,18 @@ adjustChar c = fromIntegral $ ord adj_c -- -- See Note [Unicode in Alex] and #13986. alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (AI _ buf) = chr (fromIntegral (adjustChar pc)) +alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' +unsafeChr :: Int -> Char +unsafeChr (I# c) = C# (chr# c) + -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) alexGetChar inp = case alexGetByte inp of Nothing -> Nothing Just (b,i) -> c `seq` Just (c,i) - where c = chr $ fromIntegral b + where c = unsafeChr $ fromIntegral b -- See Note [Unicode in Alex] alexGetByte :: AlexInput -> Maybe (Word8,AlexInput) ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -738,7 +738,7 @@ writeExterns out = writeFile (out "all.js.externs") -- | Get all block dependencies for a given set of roots -- --- Returns the update block info map and the blocks. +-- Returns the updated block info map and the blocks. getDeps :: Map Module LocatedBlockInfo -- ^ Block info per module -> (Module -> IO LocatedBlockInfo) -- ^ Used to load block info if missing -> Set ExportedFun -- ^ start here @@ -754,7 +754,7 @@ getDeps init_infos load_info root_funs root_blocks = traverse_funs init_infos S. -- 1. We use the BlockInfos to find the block corresponding to every -- exported root functions. -- - -- 2. We had these blocks to the set of root_blocks if they aren't already + -- 2. We add these blocks to the set of root_blocks if they aren't already -- added to the result. -- -- 3. Then we traverse the root_blocks to find their dependencies and we ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -709,7 +709,7 @@ tcRnHsBootDecls boot_or_sig decls -- Typecheck type/class/instance decls ; traceTc "Tc2 (boot)" empty ; (tcg_env, inst_infos, _deriv_binds, _th_bndrs) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds + <- tcTyClsInstDecls tycl_decls deriv_decls def_decls val_binds ; setGblEnv tcg_env $ do { -- Emit Typeable bindings @@ -1612,7 +1612,7 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, traceTc "Tc3" empty ; (tcg_env, inst_infos, th_bndrs, XValBindsLR (NValBinds deriv_binds deriv_sigs)) - <- tcTyClsInstDecls tycl_decls deriv_decls val_binds ; + <- tcTyClsInstDecls tycl_decls deriv_decls default_decls val_binds ; updLclCtxt (\tcl_env -> tcl_env { tcl_th_bndrs = th_bndrs `plusNameEnv` tcl_th_bndrs tcl_env }) $ setGblEnv tcg_env $ do { @@ -1622,11 +1622,6 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, (fi_ids, fi_decls, fi_gres) <- tcForeignImports foreign_decls ; tcExtendGlobalValEnv fi_ids $ do { - -- Default declarations - traceTc "Tc4a" empty ; - default_tys <- tcDefaults default_decls ; - updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { - -- Value declarations next. -- It is important that we check the top-level value bindings -- before the GHC-generated derived bindings, since the latter @@ -1686,13 +1681,14 @@ tcTopSrcDecls (HsGroup { hs_tyclds = tycl_decls, addUsedGREs NoDeprecationWarnings (bagToList fo_gres) ; return (tcg_env', tcl_env) - }}}}}} + }}}}} tcTopSrcDecls _ = panic "tcTopSrcDecls: ValBindsIn" --------------------------- tcTyClsInstDecls :: [TyClGroup GhcRn] -> [LDerivDecl GhcRn] + -> [LDefaultDecl GhcRn] -> [(RecFlag, LHsBinds GhcRn)] -> TcM (TcGblEnv, -- The full inst env [InstInfo GhcRn], -- Source-code instance decls to @@ -1702,16 +1698,24 @@ tcTyClsInstDecls :: [TyClGroup GhcRn] HsValBinds GhcRn) -- Supporting bindings for derived -- instances -tcTyClsInstDecls tycl_decls deriv_decls binds +tcTyClsInstDecls tycl_decls deriv_decls default_decls binds = tcAddDataFamConPlaceholders (tycl_decls >>= group_instds) $ tcAddPatSynPlaceholders (getPatSynBinds binds) $ do { (tcg_env, inst_info, deriv_info, th_bndrs) <- tcTyAndClassDecls tycl_decls ; + ; setGblEnv tcg_env $ do { + -- With the @TyClDecl at s and @InstDecl at s checked we're ready to -- process the deriving clauses, including data family deriving -- clauses discovered in @tcTyAndClassDecls at . -- + -- But only after we've typechecked 'default' declarations. + -- See Note [Typechecking default declarations] + default_tys <- tcDefaults default_decls ; + updGblEnv (\gbl -> gbl { tcg_default = default_tys }) $ do { + + -- Careful to quit now in case there were instance errors, so that -- the deriving errors don't pile up as well. ; failIfErrsM @@ -1720,7 +1724,7 @@ tcTyClsInstDecls tycl_decls deriv_decls binds ; setGblEnv tcg_env' $ do { failIfErrsM ; pure ( tcg_env', inst_info' ++ inst_info, th_bndrs, val_binds ) - }}} + }}}} {- ********************************************************************* * * @@ -3141,3 +3145,43 @@ mark_plugin_unsafe dflags = unless (gopt Opt_PluginTrustworthy dflags) $ pluginUnsafe = singleMessage $ mkPlainMsgEnvelope diag_opts noSrcSpan TcRnUnsafeDueToPlugin + + +-- Note [Typechecking default declarations] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Typechecking default declarations requires careful placement: +-- +-- 1. We must check them after types (tcTyAndClassDecls) because they can refer +-- to them. E.g. +-- +-- data T = MkT ... +-- default(Int, T, Integer) +-- +-- -- or even (tested by T11974b and T2245) +-- default(Int, T, Integer) +-- data T = MkT ... +-- +-- 2. We must check them before typechecking deriving clauses (tcInstDeclsDeriv) +-- otherwise we may lookup default default types (Integer, Double) while checking +-- deriving clauses, ignoring the default declaration. +-- +-- Before this careful placement (#24566), compiling the following example +-- (T24566) with "-ddump-if-trace -ddump-tc-trace" showed a call to +-- `applyDefaultingRules` with default types set to "(Integer,Double)": +-- +-- module M where +-- +-- import GHC.Classes +-- default () +-- +-- data Foo a = Nothing | Just a +-- deriving (Eq, Ord) +-- +-- This was an issue while building modules like M in the ghc-internal package +-- because they would spuriously fail to build if the module defining Integer +-- (ghc-bignum:GHC.Num.Integer) wasn't compiled yet and its interface not to be +-- found. The implicit dependency between M and GHC.Num.Integer isn't known to +-- the build system. +-- In addition, trying to explicitly avoid the implicit dependency with `default +-- ()` didn't work, except if *standalone* deriving was used, which was an +-- inconsistent behavior. ===================================== libraries/ghc-internal/src/GHC/Internal/Maybe.hs ===================================== @@ -28,14 +28,5 @@ default () -- data Maybe a = Nothing | Just a deriving ( Eq -- ^ @since base-2.01 - - --, Ord -- ^ @since base-2.01 + , Ord -- ^ @since base-2.01 ) - --- ??? --- A non-standalone instance will slurp the interface file for GHC.Num.Integer. - -- During simplifyInstanceContexts, a call to GHC.Tc.Utils.Env.tcGetDefaultTys - -- apparently sees mb_defaults = Nothing and thus tries to bring in the - -- default "default" types, including Integer. This seems wrong. -deriving instance Ord a => Ord (Maybe a) -- ^ @since base-2.01 - ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} + +bar() { + return (2); +} \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] ===================================== testsuite/tests/simplCore/should_compile/T24551.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module T24551 (f) where + +import GHC.Exts + +f :: a -> a +f = repeatFB g + +repeatFB :: (Addr# -> (a -> a) -> a -> a) -> a -> a +repeatFB c = let xs = c "missing"# xs in xs +{-# INLINE [0] repeatFB #-} + +g :: Addr# -> (a -> a) -> a -> a +g _ _ x = x +{-# NOINLINE g #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T23209', [extra_files(['T23209_Aux.hs'])], multimod_compile, ['T23209', '- test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) +test('T24551', normal, compile, ['-O -dcore-lint']) ===================================== testsuite/tests/typecheck/should_compile/Makefile ===================================== @@ -122,3 +122,7 @@ InlinePatSyn_ExplicitBidiBuilder: InlinePatSyn_ExplicitBidiMatcher: $(RM) -f InlinePatSyn_ExplicitBidiMatcher.o InlinePatSyn_ExplicitBidiMatcher.hi '$(TEST_HC)' $(TEST_HC_OPTS) -c InlinePatSyn_ExplicitBidiMatcher.hs -O -dsuppress-all -ddump-simpl | sed -n '/^test/,/^$$/p' | grep -vq 'Pattern' + +T24566: + '$(TEST_HC)' $(TEST_HC_OPTS) -c T24566.hs -fno-code -dno-typeable-binds -ddump-if-trace 2>&1 | grep Integer || true + # Not expecting any mention of Integer in the interface loading trace ===================================== testsuite/tests/typecheck/should_compile/T24566.hs ===================================== @@ -0,0 +1,7 @@ +module M where + +import GHC.Classes +default () + +data Foo a = Nothing | Just a + deriving (Eq, Ord) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -913,3 +913,4 @@ test('T17594a', req_th, compile, ['']) test('T17594f', normal, compile, ['']) test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-context']) test('T24470b', normal, compile, ['']) +test('T24566', [], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fbad35abf2a06c8890d932e03782de507e169ec8...0aeb789f4fa6b0547540c6f2ea6670650b51e022 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fbad35abf2a06c8890d932e03782de507e169ec8...0aeb789f4fa6b0547540c6f2ea6670650b51e022 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 14:16:50 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 10:16:50 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 40 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65fd92d243084_11451d2f13e3c38021@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 6b93843c by Simon Peyton Jones at 2024-03-22T09:43:18+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 6a1bb930 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - c8b16745 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 74b9abf3 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Spelling, layout, pretty-printing only - - - - - 20d2d798 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 08df237a by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - 80c20812 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - 3606be16 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - e442423a by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Remove a long-commented-out line Pure refactoring - - - - - a83c5c34 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. - - - - - da989ef8 by Simon Peyton Jones at 2024-03-22T14:16:28+00:00 Testsuite message changes from simplifier improvements - - - - - 22 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/FloatOut.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/401113c9731c7dcd47e5f2e39ffb6c5ee3975af4...da989ef8dc838a0a78e94c43a3d04e5bd9789e69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/401113c9731c7dcd47e5f2e39ffb6c5ee3975af4...da989ef8dc838a0a78e94c43a3d04e5bd9789e69 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 14:24:41 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 10:24:41 -0400 Subject: [Git][ghc/ghc][wip/T24251a] 33 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65fd94a9df63d_11451d36609ec394dc@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - c8470ff9 by Simon Peyton Jones at 2024-03-22T12:22:44+00:00 Rename tryCaseMerge - - - - - 11ff00ab by Simon Peyton Jones at 2024-03-22T12:22:44+00:00 Try a more clever discard-eval Addresses programs like this f xs = xs `seq` (let t = reverse $ reverse $ reverse $ reverse $ reverse $ reverse xs in case xs of [] -> (t,True) (_:_) -> (t,False)) Also including the case where t is a join point. Relates to #24251. See GHC Log 13 March - - - - - b746fc5b by Simon Peyton Jones at 2024-03-22T12:22:44+00:00 Wibbles - - - - - 88148701 by Simon Peyton Jones at 2024-03-22T14:24:11+00:00 Move to CSE - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/CSE.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/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9975ad57752aacdf96eed7874c1a042bce3e05af...88148701841e8c6024fb22ba86b252ce95ffa850 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9975ad57752aacdf96eed7874c1a042bce3e05af...88148701841e8c6024fb22ba86b252ce95ffa850 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 16:12:09 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 12:12:09 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 2 commits: Simplifier improvements Message-ID: <65fdadd9cf159_11451d66014d061765@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: c4eb9d78 by Simon Peyton Jones at 2024-03-22T15:57:29+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. - - - - - d66a7c83 by Simon Peyton Jones at 2024-03-22T15:57:29+00:00 Testsuite message changes from simplifier improvements - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Tickish.hs - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity09.stderr - testsuite/tests/arityanal/should_compile/Arity13.stderr - testsuite/tests/cpranal/should_compile/T18401.stderr - testsuite/tests/dmdanal/sigs/T21081.stderr - testsuite/tests/driver/inline-check.stderr - testsuite/tests/lib/integer/Makefile - testsuite/tests/numeric/should_compile/T19641.stderr - testsuite/tests/perf/compiler/T15630.hs - + testsuite/tests/perf/compiler/T15630a.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T18013.stderr - − testsuite/tests/simplCore/should_compile/T18730.hs - − testsuite/tests/simplCore/should_compile/T18730_A.hs - testsuite/tests/simplCore/should_compile/T20103.stderr - testsuite/tests/simplCore/should_compile/T22428.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da989ef8dc838a0a78e94c43a3d04e5bd9789e69...d66a7c832871a7cb537f4f03d555a469ffcb6a31 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da989ef8dc838a0a78e94c43a3d04e5bd9789e69...d66a7c832871a7cb537f4f03d555a469ffcb6a31 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 16:18:27 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 12:18:27 -0400 Subject: [Git][ghc/ghc][wip/T24553] Print more info about kinds in error messages Message-ID: <65fdaf53bc2ad_11451d6793a8c63357@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24553 at Glasgow Haskell Compiler / GHC Commits: 40b623b7 by Simon Peyton Jones at 2024-03-22T16:17:58+00:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 13 changed files: - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -228,7 +228,7 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = andEq TEQX e = hasCast e andEq TEQ e = e - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare go (D _ (TyConApp tc1 [])) (D _ (TyConApp tc2 [])) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -12,8 +12,9 @@ module GHC.Core.TyCo.Compare ( nonDetCmpTypesX, nonDetCmpTc, eqVarBndrs, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTyConApps, + mayLookIdentical, -- * Visiblity comparision eqForAllVis, cmpForAllVis @@ -22,7 +23,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -129,52 +131,119 @@ Cabal. See #19226. -} +mayLookIdentical :: Type -> Type -> Bool +-- | Returns True if the /visible/ part of the types +-- might look equal, even if they are really unequal (in the invisible bits) +-- +-- This function is very similar to tc_eq_type but it is much more +-- heuristic. Notably, it is always safe to return True, even with types +-- that might (in truth) be unequal -- this affects error messages only +-- (Originally there were one function with an extra flag, but the result +-- was hard to understand.) +mayLookIdentical orig_ty1 orig_ty2 + = go orig_env orig_ty1 orig_ty2 + where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + + go :: RnEnv2 -> Type -> Type -> Bool + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True + + go env t1 t2 | Just t1' <- coreView t1 = go env t1' t2 + go env t1 t2 | Just t2' <- coreView t2 = go env t1 t2' + + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True + + go env (ForAllTy (Bndr tv1 vis1) ty1) + (ForAllTy (Bndr tv2 vis2) ty2) + = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] + && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- Visible stuff only: ignore kinds of binders + + -- If we have (forall (r::RunTimeRep). ty1 ~ blah) then respond + -- with True. Reason: the type pretty-printer defaults RuntimeRep + -- foralls (see Ghc.Iface.Type.hideNonStandardTypes). That can make, + -- say (forall r. TYPE r -> Type) into (Type -> Type), so it looks the + -- same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of mayLookIdentical) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | isDefaultableBndr b = True + go _ _ (ForAllTy b _) | isDefaultableBndr b = True + + go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) + = go env arg1 arg2 && go env res1 res2 && go env w1 w2 + -- Visible stuff only: ignore agg kinds + + -- See Note [Equality on AppTys] in GHC.Core.Type + go env (AppTy s1 t1) ty2 + | Just (s2, t2) <- tcSplitAppTyNoView_maybe ty2 + = go env s1 s2 && go env t1 t2 + go env ty1 (AppTy s2 t2) + | Just (s1, t1) <- tcSplitAppTyNoView_maybe ty1 + = go env s1 s2 && go env t1 t2 + + go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) + = tc1 == tc2 && gos env (tyConBinders tc1) ts1 ts2 + + go _ _ _ = False + + gos :: RnEnv2 -> [TyConBinder] -> [Type] -> [Type] -> Bool + gos _ _ [] [] = True + gos env bs (t1:ts1) (t2:ts2) + | (invisible, bs') <- case bs of + [] -> (False, []) + (b:bs) -> (isInvisibleTyConBinder b, bs) + = (invisible || go env t1 t2) && gos env bs' ts1 ts2 + + gos _ _ _ _ = False + + -- | Type equality comparing both visible and invisible arguments and expanding -- type synonyms. tcEqTypeNoSyns :: Type -> Type -> Bool -tcEqTypeNoSyns ta tb = tc_eq_type False False ta tb - --- | Like 'tcEqType', but returns True if the /visible/ part of the types --- are equal, even if they are really unequal (in the invisible bits) -tcEqTypeVis :: Type -> Type -> Bool -tcEqTypeVis ty1 ty2 = tc_eq_type False True ty1 ty2 +tcEqTypeNoSyns ta tb = tc_eq_type False ta tb -- | Like 'pickyEqTypeVis', but returns a Bool for convenience pickyEqType :: Type -> Type -> Bool -- Check when two types _look_ the same, _including_ synonyms. -- So (pickyEqType String [Char]) returns False -- This ignores kinds and coercions, because this is used only for printing. -pickyEqType ty1 ty2 = tc_eq_type True False ty1 ty2 +pickyEqType ty1 ty2 = tc_eq_type True ty1 ty2 -- | Real worker for 'tcEqType'. No kind check! tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms - -> Bool -- ^ True <=> compare visible args only -> Type -> Type -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type -tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +tc_eq_type keep_syns orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + go :: RnEnv2 -> Type -> Type -> Bool - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. - go _ (TyConApp tc1 []) (TyConApp tc2 []) - | tc1 == tc2 - = True + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True go env t1 t2 | not keep_syns, Just t1' <- coreView t1 = go env t1' t2 go env t1 t2 | not keep_syns, Just t2' <- coreView t2 = go env t1 t2' - go env (TyVarTy tv1) (TyVarTy tv2) - = rnOccL env tv1 == rnOccR env tv2 - - go _ (LitTy lit1) (LitTy lit2) - = lit1 == lit2 + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] - && (vis_only || go env (varType tv1) (varType tv2)) + && go env (varType tv1) (varType tv2) && go (rnBndr2 env tv1 tv2) ty1 ty2 -- Make sure we handle all FunTy cases since falling through to the @@ -183,11 +252,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- See Note [Equality on FunTys] in GHC.Core.TyCo.Rep: we must check -- kinds here go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) - = kinds_eq && go env arg1 arg2 && go env res1 res2 && go env w1 w2 - where - kinds_eq | vis_only = True - | otherwise = go env (typeKind arg1) (typeKind arg2) && - go env (typeKind res1) (typeKind res2) + = go env (typeKind arg1) (typeKind arg2) && + go env (typeKind res1) (typeKind res2) && + go env arg1 arg2 && go env res1 res2 && go env w1 w2 -- See Note [Equality on AppTys] in GHC.Core.Type go env (AppTy s1 t1) ty2 @@ -198,32 +265,24 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go env s1 s2 && go env t1 t2 go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) - = tc1 == tc2 && gos env (tc_vis tc1) ts1 ts2 - - go env (CastTy t1 _) t2 = go env t1 t2 - go env t1 (CastTy t2 _) = go env t1 t2 - go _ (CoercionTy {}) (CoercionTy {}) = True + = tc1 == tc2 && gos env ts1 ts2 go _ _ _ = False - gos _ _ [] [] = True - gos env (ig:igs) (t1:ts1) (t2:ts2) = (ig || go env t1 t2) - && gos env igs ts1 ts2 - gos _ _ _ _ = False + gos _ [] [] = True + gos env (t1:ts1) (t2:ts2) = go env t1 t2 && gos env ts1 ts2 + gos _ _ _ = False - tc_vis :: TyCon -> [Bool] -- True for the fields we should ignore - tc_vis tc | vis_only = inviss ++ repeat False -- Ignore invisibles - | otherwise = repeat False -- Ignore nothing - -- The repeat False is necessary because tycons - -- can legitimately be oversaturated - where - bndrs = tyConBinders tc - inviss = map isInvisibleTyConBinder bndrs - - orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] - -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function @@ -543,7 +602,7 @@ nonDetCmpTypeX env orig_t1 orig_t2 = -- Returns both the resulting ordering relation between -- the two types and whether either contains a cast. go :: RnEnv2 -> Type -> Type -> TypeOrdering - -- See Note [Comparing nullary type synonyms]. + -- See Note [Comparing nullary type synonyms] go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1066,7 +1066,7 @@ unify_ty :: UMEnv -- Respects newtypes, PredTypes -- See Note [Computing equality on types] in GHC.Core.Type unify_ty _env (TyConApp tc1 []) (TyConApp tc2 []) _kco - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare | tc1 == tc2 = return () ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,60 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = mayLookIdentical act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = mayLookIdentical ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when we find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by + `GHC.Core.TyCo.Compare.mayLookIdentical` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6089,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6172,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6434,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6458,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -311,7 +311,7 @@ can_eq_nc -> Type -> Type -- RHS, after and before type-synonym expansion, resp -> TcS (StopOrContinue (Either IrredCt EqCt)) --- See Note [Comparing nullary type synonyms] in GHC.Core.Type. +-- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare can_eq_nc _flat _rdr_env _envs ev eq_rel ty1@(TyConApp tc1 []) _ps_ty1 (TyConApp tc2 []) _ps_ty2 | tc1 == tc2 = canEqReflexive ev eq_rel ty1 ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -95,7 +95,7 @@ module GHC.Tc.Utils.TcType ( -- Re-exported from GHC.Core.TyCo.Compare -- mainly just for back-compat reasons eqType, eqTypes, nonDetCmpType, nonDetCmpTypes, eqTypeX, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, mayLookIdentical, tcEqTyConApps, eqForAllVis, eqVarBndrs, --------------------------------- @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40b623b7626de92c4d290a459fdb90c1e3f0ec36 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40b623b7626de92c4d290a459fdb90c1e3f0ec36 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 16:25:27 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Fri, 22 Mar 2024 12:25:27 -0400 Subject: [Git][ghc/ghc][wip/T24552] Fix for #24552 (see testcase T24552) Message-ID: <65fdb0f7da0bd_11451d6b5af1c6619f@gitlab.mail> Apoorv Ingle pushed to branch wip/T24552 at Glasgow Haskell Compiler / GHC Commits: 8cf58aef by Apoorv Ingle at 2024-03-22T11:24:48-05:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -797,6 +788,8 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' , text "matchPmChecked" <+> ppr (isMatchContextPmChecked dflags origin ctxt)]) ; matches_nablas <- if isMatchContextPmChecked dflags origin ctxt + -- See Note [Expanding HsDo with XXExprGhcRn] Part 1. Wrinkle 1 for + -- pmc for pattern synonyms -- See Note [Long-distance information] in GHC.HsToCore.Pmc then addHsScrutTmCs (concat scrs) new_vars $ @@ -843,16 +836,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -212,7 +212,7 @@ mk_failable_expr doFlav pat@(L loc _) expr fail_op = mk_fail_block :: HsDoFlavour -> LPat GhcRn -> LHsExpr GhcRn -> FailOperator GhcRn -> TcM (HsExpr GhcRn) mk_fail_block doFlav pat@(L ploc _) e (Just (SyntaxExprRn fail_op)) = do dflags <- getDynFlags - return $ HsLam noAnn LamSingle $ mkMatchGroup (doExpansionOrigin doFlav) -- \ + return $ HsLam noAnn LamCases $ mkMatchGroup (doExpansionOrigin doFlav) -- \ (wrapGenSpan [ genHsCaseAltDoExp doFlav (mkVisPat pat) e -- pat -> expr , fail_alt_case dflags pat fail_op -- _ -> fail "fail pattern" ]) @@ -356,25 +356,42 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash at runtime. -* That call of `fail` will (rightly) automatically generate a `MonadFail` constraint. So if the - pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate - a `MonadFail` constraint that isn't needed. +* According to the language specification, when the pattern is irrefutable, + we should not add the `fail` alternative. This is important because + the occurrence of `fail` means that the typechecker will generate a `MonadFail` constraint, + and irrefutable patterns shouldn't need a fail alternative. -* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. - When the pattern is irrefutable, we do not add the fail block. - This is important because the occurrence of `fail` means that the typechecker - will generate a `MonadFail` constraint, and the language spec says that - we should not do that for irrefutable patterns. +* _Wrinkel 1_: Note that pattern synonyms count as refutable during type checking, + (see `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`). They will hence generate a + `MonadFail` constraint and they will always be wrapped in a `fail`able-block. - Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate - a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + Consider a patten synonym declaration (testcase T24552): + + pattern MyJust :: a -> Maybe a + pattern MyJust x <- Just x where MyJust = Just + + and a `do`-block with the following bind and return statement + + do { MyJust x <- [MyNothing, MyJust ()] + ; return x } + + The `do`-expansion will generate the expansion + + (>>=) ([MyNothing, MyJust ()]) + (\case MyJust x -> return x -- (1) + _ -> fail "failable pattern .. " -- (2) + ) + + This code (specifically the `match` spanning lines (1) and (2)) is a compiler generated code; + the associated `Origin` in tagged `Generated` + The alternative statements will thus be ignored by the pattern match check (c.f. `isMatchContextPmChecked`). + This ensures we do not generate spurious redundant-pattern-match warnings due to the line (2) above. + See Note [Generated code and pattern-match checking] + See Note [Long-distance information in matchWrapper] * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we - attach to that constraint? It should be a good one, because it'll show up in error - messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the + attach to that constraint? When the `MonadFail` constraint can't be solved, it'll show up in error + messages and it needs to be a good location. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs) ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,14 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude +import qualified Prelude as P + +pattern MyNothing :: Maybe a +pattern MyNothing <- Nothing where MyNothing = Nothing + +pattern MyJust :: a -> Maybe a +pattern MyJust x <- Just x where MyJust = Just + +main = print $ do MyJust x <- [MyNothing, MyJust ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cf58aefb81d7c829b14d7c9d573489431a89c59 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cf58aefb81d7c829b14d7c9d573489431a89c59 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 17:09:02 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 13:09:02 -0400 Subject: [Git][ghc/ghc][wip/T24251a] Wibbles, and add test Message-ID: <65fdbb2e5d1c8_2767a6ca9c701030c1@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 91f2e3fc by Simon Peyton Jones at 2024-03-22T17:08:48+00:00 Wibbles, and add test - - - - - 4 changed files: - compiler/GHC/Core/Opt/CSE.hs - + testsuite/tests/simplCore/should_compile/T24251a.hs - + testsuite/tests/simplCore/should_compile/T24251a.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -15,12 +15,12 @@ import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding , idInlineActivation, setInlineActivation , zapIdOccInfo, zapIdUsageInfo, idInlinePragma , isJoinId, idJoinPointHood, idUnfolding, isDeadBinder ) -import GHC.Core.Utils ( mkAltExpr, exprIsTrivial - , exprIsTickedString +import GHC.Core.Utils ( mkAltExpr, exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) import GHC.Core.FVs ( exprFreeVars ) import GHC.Core.Type ( tyConAppArgs ) import GHC.Core +import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Utils.Outputable import GHC.Types.Basic import GHC.Types.Tickish @@ -714,25 +714,31 @@ cseExpr env (Case e bndr ty alts) = cseCase env e bndr ty alts cseCase :: CSEnv -> InExpr -> InId -> InType -> [InAlt] -> OutExpr cseCase env scrut bndr ty alts - = mkCase scrut1 bndr3 ty' $ - combineAlts (map cse_alt alts) + | Just body' <- caseElim scrut' bndr' alts' + = Let (NonRec bndr' scrut') body' + + | otherwise + = Case scrut' bndr' ty' alts' + where ty' = substTyUnchecked (csEnvSubst env) ty - (cse_done, scrut1) = try_for_cse env scrut + (cse_done, scrut') = try_for_cse env scrut bndr1 = zapIdOccInfo bndr -- Zapping the OccInfo is needed because the extendCSEnv -- in cse_alt may mean that a dead case binder -- becomes alive, and Lint rejects that (env1, bndr2) = addBinder env bndr1 - (alt_env, bndr3) = extendCSEnvWithBinding env1 bndr bndr2 scrut1 cse_done + (alt_env, bndr') = extendCSEnvWithBinding env1 bndr bndr2 scrut' cse_done -- extendCSEnvWithBinding: see Note [CSE for case expressions] + alts' = combineAlts (map cse_alt alts) + con_target :: OutExpr con_target = lookupSubst alt_env bndr arg_tys :: [OutType] - arg_tys = tyConAppArgs (idType bndr3) + arg_tys = tyConAppArgs (idType bndr') -- See Note [CSE for case alternatives] cse_alt (Alt (DataAlt con) args rhs) @@ -747,36 +753,43 @@ cseCase env scrut bndr ty alts where (env', args') = addBinders alt_env args -mkCase :: OutExpr -> OutId -> OutType -> [OutAlt] -> OutExpr --- Smart constructor for Case; see +caseElim :: OutExpr -> OutId -> [OutAlt] -> Maybe OutExpr +-- Can we eliminate the case altogether? If so return the body. -- Note [Eliminating redundant cases] -mkCase scrut bndr ty alts +caseElim scrut case_bndr alts | [Alt _ bndrs rhs] <- alts - , exprIsTrivial scrut + , Just (scrut_var, _) <- scrutBinderSwap_maybe scrut , all isDeadBinder bndrs - , isEvaldSoon bndr rhs - = Let (NonRec bndr scrut) rhs + , isEvaldSoon (scrut_var, case_bndr) rhs + = Just rhs | otherwise - = Case scrut bndr ty alts + = Nothing -isEvaldSoon :: InId -> InExpr -> Bool --- (isEvaldSoon b e) is True is evaluated soon by e -isEvaldSoon bndr expr +isEvaldSoon :: (OutId, OutId) -> OutExpr -> Bool +-- (isEvaldSoon (v1,v2) e) is True if either v1 or v2 is evaluated "soon" by e +isEvaldSoon (v1,v2) expr = go expr where - go (Var v) = v==bndr - go (Case scrut cb _ alts) - | Var v <- scrut, v==bndr = True - | otherwise = all go_alt alts && cb /= bndr && all ok_alt alts - -- ok_alt only runs if things look good + hit :: Var -> Bool + hit v = v==v1 || v==v2 + + go (Var v) = hit v go (Let _ e) = go e go (Tick _ e) = go e go (Cast e _) = go e - go _ = False + + go (Case scrut cb _ alts) + = go scrut || + (all go_alt alts && + not (hit cb) && -- Check for + all ok_alt alts) -- shadowing + -- ok_alt only runs if things look good + + go _ = False -- Lit, App, Lam, Coercion, Type go_alt (Alt _ _ rhs) = go rhs - ok_alt (Alt _ cbs _) = not (bndr `elem` cbs) + ok_alt (Alt _ cbs _) = not (any hit cbs) combineAlts :: [OutAlt] -> [OutAlt] -- See Note [Combine case alternatives] ===================================== testsuite/tests/simplCore/should_compile/T24251a.hs ===================================== @@ -0,0 +1,9 @@ +module T24251a where + +f xs = xs `seq` + (let t = reverse (reverse (reverse (reverse xs))) in + case xs of + [] -> (t,True) + (_:_) -> (t,False)) + +-- We start with an eval of xs, but that should disappear. ===================================== testsuite/tests/simplCore/should_compile/T24251a.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 33, types: 60, coercions: 0, joins: 0/1} + +$wf + = \ @a xs -> + let { + t = reverse1 (reverse1 (reverse1 (reverse1 xs []) []) []) [] } in + case xs of { + [] -> (# t, True #); + : ds ds1 -> (# t, False #) + } + +f = \ @a xs -> case $wf xs of { (# ww, ww1 #) -> (ww, ww1) } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24251a', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-all']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91f2e3fc4de5305ef45c74e960fdd3331e00afc2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91f2e3fc4de5305ef45c74e960fdd3331e00afc2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 17:12:07 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 13:12:07 -0400 Subject: [Git][ghc/ghc][wip/T24251a] Wibble Note Message-ID: <65fdbbe77a889_2767a6df68081054a2@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 46173fdb by Simon Peyton Jones at 2024-03-22T17:11:50+00:00 Wibble Note - - - - - 1 changed file: - compiler/GHC/Core/Opt/CSE.hs Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -773,7 +773,7 @@ isEvaldSoon (v1,v2) expr where hit :: Var -> Bool hit v = v==v1 || v==v2 - +l go (Var v) = hit v go (Let _ e) = go e go (Tick _ e) = go e @@ -842,6 +842,9 @@ turning K2 into 'x' increases the number of live variables. But * The next run of the simplifier will turn 'x' back into K2, so we won't permanently bloat the free-var count. +Note [Eliminating redundant cases] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Still to be written... TODO Note [Combine case alternatives] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46173fdb2a0260206bf588267b21c4cad220529d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46173fdb2a0260206bf588267b21c4cad220529d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 18:04:51 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 22 Mar 2024 14:04:51 -0400 Subject: [Git][ghc/ghc][wip/T24251a] Fix typo Message-ID: <65fdc843243fa_2767a626342a8111477@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 47840e74 by Simon Peyton Jones at 2024-03-22T18:03:38+00:00 Fix typo - - - - - 1 changed file: - compiler/GHC/Core/Opt/CSE.hs Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -773,7 +773,7 @@ isEvaldSoon (v1,v2) expr where hit :: Var -> Bool hit v = v==v1 || v==v2 -l + go (Var v) = hit v go (Let _ e) = go e go (Tick _ e) = go e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/47840e7407f57734190658778c9a42f19d3786a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/47840e7407f57734190658778c9a42f19d3786a2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 18:19:54 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 22 Mar 2024 14:19:54 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: driver: Make `checkHomeUnitsClosed` faster Message-ID: <65fdcbca6adfd_2767a62c86174115044@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 015c7d8c by Zubin Duggal at 2024-03-22T14:19:39-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - a238da1b by Andreas Klebinger at 2024-03-22T14:19:40-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 18 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Driver/Make.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,15 +301,20 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr _ = [] +jumpDestsOfInstr i = case i of + (CBZ _ t) -> [ mkDest t ] + (CBNZ _ t) -> [ mkDest t ] + (J t) -> [ mkDest t ] + (B t) -> [ mkDest t ] + (BL t _ _) -> [ mkDest t ] + (BCOND _ t) -> [ mkDest t ] + _ -> [] + where + mkDest (TBlock id) = Just id + mkDest TLabel{} = Nothing + mkDest TReg{} = Nothing -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,15 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> targets + BCTRL{} -> [Nothing] + BL{} -> [Nothing] + JMP{} -> [Nothing] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,69 +1714,77 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +-- +-- See Note [Multiple Home Units], section 'Closure Property'. +checkHomeUnitsClosed :: UnitEnv -> [DriverMessages] +checkHomeUnitsClosed ue + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + home_id_set = unitEnv_keys $ ue_home_unit_graph ue + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} + +bar() { + return (2); +} \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0aeb789f4fa6b0547540c6f2ea6670650b51e022...a238da1beb6dec6946bc1ca4d19a5f0ac309ee10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0aeb789f4fa6b0547540c6f2ea6670650b51e022...a238da1beb6dec6946bc1ca4d19a5f0ac309ee10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 20:10:00 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 22 Mar 2024 16:10:00 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 2 commits: Use lookupHsSymbol for PrimOps too Message-ID: <65fde598f115b_2767a65be35d413298f@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: ab2fa3a9 by Rodrigo Mesquita at 2024-03-22T15:20:25+00:00 Use lookupHsSymbol for PrimOps too - - - - - 10ad50a2 by Rodrigo Mesquita at 2024-03-22T18:22:38+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - 3 changed files: - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Runtime/Interpreter.hs - rts/Linker.c Changes: ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -24,6 +24,7 @@ import GHCi.RemoteTypes import GHCi.ResolvedBCO import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Ids import GHC.Builtin.Names import GHC.Unit.Types @@ -38,6 +39,7 @@ import GHC.Utils.Outputable import GHC.Types.Name import GHC.Types.Name.Env +import qualified GHC.Types.Id as Id import GHC.Types.Unique.DFM import Language.Haskell.Syntax.Module.Name @@ -125,10 +127,10 @@ lookupAddr interp pkgs_loaded ae addr_nm = do Nothing -> linkFail "GHC.ByteCode.Linker.lookupAddr" (unpackFS sym_to_find) -lookupPrimOp :: Interp -> PrimOp -> IO (RemotePtr ()) -lookupPrimOp interp primop = do +lookupPrimOp :: Interp -> PkgsLoaded -> PrimOp -> IO (RemotePtr ()) +lookupPrimOp interp pkgs_loaded primop = do let sym_to_find = primopToCLabel primop "closure" - m <- lookupSymbol interp (mkFastString sym_to_find) + m <- lookupHsSymbol interp pkgs_loaded (Id.idName $ primOpId primop) "closure" case m of Just p -> return (toRemotePtr p) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE(primop)" sym_to_find @@ -158,7 +160,7 @@ resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE" (unpackFS sym_to_find) BCOPtrPrimOp op - -> ResolvedBCOStaticPtr <$> lookupPrimOp interp op + -> ResolvedBCOStaticPtr <$> lookupPrimOp interp pkgs_loaded op BCOPtrBCO bco -> ResolvedBCOPtrBCO <$> linkBCO interp pkgs_loaded le bco_ix bco ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -458,7 +458,11 @@ lookupSymbolInDLL interp dll str = withSymbolCache interp str $ #if defined(HAVE_INTERNAL_INTERPRETER) InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) #endif - ExternalInterp _ -> panic "lookupSymbolInDLL: not implemented for external interpreter" -- FIXME + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbolInDLL dll (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = ===================================== rts/Linker.c ===================================== @@ -134,7 +134,7 @@ extern void iconv(); - Indexing (e.g. ocVerifyImage and ocGetNames) - Initialization (e.g. ocResolve) - RunInit (e.g. ocRunInit) - - Lookup (e.g. lookupSymbol) + - Lookup (e.g. lookupSymbol/lookupSymbolInDLL) This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/868226bcfb15e512e36ceb3651d17e5fd2fb5b8f...10ad50a248b98dc0e1f9a2973564492d0f0db292 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/868226bcfb15e512e36ceb3651d17e5fd2fb5b8f...10ad50a248b98dc0e1f9a2973564492d0f0db292 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 22 22:20:35 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 22 Mar 2024 18:20:35 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: driver: Make `checkHomeUnitsClosed` faster Message-ID: <65fe0433b6ae0_2767a696b8164150824@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 80b0f629 by Zubin Duggal at 2024-03-22T18:20:17-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - dd6d3b10 by Matthew Craven at 2024-03-22T18:20:19-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 7121ca6c by Andreas Klebinger at 2024-03-22T18:20:19-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 3acfad97 by Tristan Cacqueray at 2024-03-22T18:20:24-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 21 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Driver/Make.hs - docs/users_guide/hints.rst - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/Word.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,15 +301,20 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr _ = [] +jumpDestsOfInstr i = case i of + (CBZ _ t) -> [ mkDest t ] + (CBNZ _ t) -> [ mkDest t ] + (J t) -> [ mkDest t ] + (B t) -> [ mkDest t ] + (BL t _ _) -> [ mkDest t ] + (BCOND _ t) -> [ mkDest t ] + _ -> [] + where + mkDest (TBlock id) = Just id + mkDest TLabel{} = Nothing + mkDest TReg{} = Nothing -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,15 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> targets + BCTRL{} -> [Nothing] + BL{} -> [Nothing] + JMP{} -> [Nothing] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,69 +1714,77 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +-- +-- See Note [Multiple Home Units], section 'Closure Property'. +checkHomeUnitsClosed :: UnitEnv -> [DriverMessages] +checkHomeUnitsClosed ue + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + home_id_set = unitEnv_keys $ ue_home_unit_graph ue + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== docs/users_guide/hints.rst ===================================== @@ -273,22 +273,6 @@ Use ``foreign import`` (a GHC extension) to plug into fast libraries: :ref:`ffi` describes the foreign function interface. -Don't use ``Float``\s: - If you're using ``Complex``, definitely use ``Complex Double`` - rather than ``Complex Float`` (the former is specialised heavily, - but the latter isn't). - - ``Floats`` (probably 32-bits) are almost always a bad idea, anyway, - unless you Really Know What You Are Doing. Use ``Double``\s. - There's rarely a speed disadvantage—modern machines will use the - same floating-point unit for both. With ``Double``\s, you are much - less likely to hang yourself with numerical errors. - - One time when ``Float`` might be a good idea is if you have a *lot* - of them, say a giant array of ``Float``\s. They take up half the - space in the heap compared to ``Doubles``. However, this isn't true - on a 64-bit machine. - Use unboxed arrays (``UArray``) GHC supports arrays of unboxed elements, for several basic arithmetic element types including ``Int`` and ``Char``: see the ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.21.0.0 *TBA* + * Improve `toInteger :: Word32 -> Integer` on 64-bit platforms ([CLC proposal #259](https://github.com/haskell/core-libraries-committee/issues/259)) + ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * The top-level handler for uncaught exceptions now displays the output of `displayException` rather than `show` ([CLC proposal #198](https://github.com/haskell/core-libraries-committee/issues/198)) ===================================== libraries/ghc-internal/src/GHC/Internal/Word.hs ===================================== @@ -592,7 +592,13 @@ instance Integral Word32 where mod x y = rem x y divMod x y = quotRem x y - toInteger (W32# x#) = integerFromWord# (word32ToWord# x#) + toInteger (W32# x#) = +#if WORD_SIZE_IN_BITS > 32 + -- In this case the conversion to Int# cannot overflow. + IS (word2Int# (word32ToWord# x#)) +#else + integerFromWord# (word32ToWord# x#) +#endif -- | @since base-2.01 instance Bits Word32 where ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} + +bar() { + return (2); +} \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,8 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a238da1beb6dec6946bc1ca4d19a5f0ac309ee10...3acfad971a52062ee289fa8238f334045ad83ee9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a238da1beb6dec6946bc1ca4d19a5f0ac309ee10...3acfad971a52062ee289fa8238f334045ad83ee9 You're receiving 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 Mar 23 01:21:48 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 22 Mar 2024 21:21:48 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Improve toInteger @Word32 on 64-bit platforms Message-ID: <65fe2eac2b623_92bce41503fc1172d9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 77c39b86 by Matthew Craven at 2024-03-22T21:20:42-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0ff06794 by Apoorv Ingle at 2024-03-22T21:20:42-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - 65a3f458 by Simon Peyton Jones at 2024-03-22T21:20:42-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 08876875 by Tristan Cacqueray at 2024-03-22T21:20:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 21 changed files: - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - docs/users_guide/hints.rst - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/Word.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -228,7 +228,7 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = andEq TEQX e = hasCast e andEq TEQ e = e - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare go (D _ (TyConApp tc1 [])) (D _ (TyConApp tc2 [])) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -12,8 +12,9 @@ module GHC.Core.TyCo.Compare ( nonDetCmpTypesX, nonDetCmpTc, eqVarBndrs, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTyConApps, + mayLookIdentical, -- * Visiblity comparision eqForAllVis, cmpForAllVis @@ -22,7 +23,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -129,52 +131,119 @@ Cabal. See #19226. -} +mayLookIdentical :: Type -> Type -> Bool +-- | Returns True if the /visible/ part of the types +-- might look equal, even if they are really unequal (in the invisible bits) +-- +-- This function is very similar to tc_eq_type but it is much more +-- heuristic. Notably, it is always safe to return True, even with types +-- that might (in truth) be unequal -- this affects error messages only +-- (Originally there were one function with an extra flag, but the result +-- was hard to understand.) +mayLookIdentical orig_ty1 orig_ty2 + = go orig_env orig_ty1 orig_ty2 + where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + + go :: RnEnv2 -> Type -> Type -> Bool + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True + + go env t1 t2 | Just t1' <- coreView t1 = go env t1' t2 + go env t1 t2 | Just t2' <- coreView t2 = go env t1 t2' + + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True + + go env (ForAllTy (Bndr tv1 vis1) ty1) + (ForAllTy (Bndr tv2 vis2) ty2) + = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] + && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- Visible stuff only: ignore kinds of binders + + -- If we have (forall (r::RunTimeRep). ty1 ~ blah) then respond + -- with True. Reason: the type pretty-printer defaults RuntimeRep + -- foralls (see Ghc.Iface.Type.hideNonStandardTypes). That can make, + -- say (forall r. TYPE r -> Type) into (Type -> Type), so it looks the + -- same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of mayLookIdentical) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | isDefaultableBndr b = True + go _ _ (ForAllTy b _) | isDefaultableBndr b = True + + go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) + = go env arg1 arg2 && go env res1 res2 && go env w1 w2 + -- Visible stuff only: ignore agg kinds + + -- See Note [Equality on AppTys] in GHC.Core.Type + go env (AppTy s1 t1) ty2 + | Just (s2, t2) <- tcSplitAppTyNoView_maybe ty2 + = go env s1 s2 && go env t1 t2 + go env ty1 (AppTy s2 t2) + | Just (s1, t1) <- tcSplitAppTyNoView_maybe ty1 + = go env s1 s2 && go env t1 t2 + + go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) + = tc1 == tc2 && gos env (tyConBinders tc1) ts1 ts2 + + go _ _ _ = False + + gos :: RnEnv2 -> [TyConBinder] -> [Type] -> [Type] -> Bool + gos _ _ [] [] = True + gos env bs (t1:ts1) (t2:ts2) + | (invisible, bs') <- case bs of + [] -> (False, []) + (b:bs) -> (isInvisibleTyConBinder b, bs) + = (invisible || go env t1 t2) && gos env bs' ts1 ts2 + + gos _ _ _ _ = False + + -- | Type equality comparing both visible and invisible arguments and expanding -- type synonyms. tcEqTypeNoSyns :: Type -> Type -> Bool -tcEqTypeNoSyns ta tb = tc_eq_type False False ta tb - --- | Like 'tcEqType', but returns True if the /visible/ part of the types --- are equal, even if they are really unequal (in the invisible bits) -tcEqTypeVis :: Type -> Type -> Bool -tcEqTypeVis ty1 ty2 = tc_eq_type False True ty1 ty2 +tcEqTypeNoSyns ta tb = tc_eq_type False ta tb -- | Like 'pickyEqTypeVis', but returns a Bool for convenience pickyEqType :: Type -> Type -> Bool -- Check when two types _look_ the same, _including_ synonyms. -- So (pickyEqType String [Char]) returns False -- This ignores kinds and coercions, because this is used only for printing. -pickyEqType ty1 ty2 = tc_eq_type True False ty1 ty2 +pickyEqType ty1 ty2 = tc_eq_type True ty1 ty2 -- | Real worker for 'tcEqType'. No kind check! tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms - -> Bool -- ^ True <=> compare visible args only -> Type -> Type -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type -tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +tc_eq_type keep_syns orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + go :: RnEnv2 -> Type -> Type -> Bool - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. - go _ (TyConApp tc1 []) (TyConApp tc2 []) - | tc1 == tc2 - = True + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True go env t1 t2 | not keep_syns, Just t1' <- coreView t1 = go env t1' t2 go env t1 t2 | not keep_syns, Just t2' <- coreView t2 = go env t1 t2' - go env (TyVarTy tv1) (TyVarTy tv2) - = rnOccL env tv1 == rnOccR env tv2 - - go _ (LitTy lit1) (LitTy lit2) - = lit1 == lit2 + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] - && (vis_only || go env (varType tv1) (varType tv2)) + && go env (varType tv1) (varType tv2) && go (rnBndr2 env tv1 tv2) ty1 ty2 -- Make sure we handle all FunTy cases since falling through to the @@ -183,11 +252,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- See Note [Equality on FunTys] in GHC.Core.TyCo.Rep: we must check -- kinds here go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) - = kinds_eq && go env arg1 arg2 && go env res1 res2 && go env w1 w2 - where - kinds_eq | vis_only = True - | otherwise = go env (typeKind arg1) (typeKind arg2) && - go env (typeKind res1) (typeKind res2) + = go env (typeKind arg1) (typeKind arg2) && + go env (typeKind res1) (typeKind res2) && + go env arg1 arg2 && go env res1 res2 && go env w1 w2 -- See Note [Equality on AppTys] in GHC.Core.Type go env (AppTy s1 t1) ty2 @@ -198,32 +265,24 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go env s1 s2 && go env t1 t2 go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) - = tc1 == tc2 && gos env (tc_vis tc1) ts1 ts2 - - go env (CastTy t1 _) t2 = go env t1 t2 - go env t1 (CastTy t2 _) = go env t1 t2 - go _ (CoercionTy {}) (CoercionTy {}) = True + = tc1 == tc2 && gos env ts1 ts2 go _ _ _ = False - gos _ _ [] [] = True - gos env (ig:igs) (t1:ts1) (t2:ts2) = (ig || go env t1 t2) - && gos env igs ts1 ts2 - gos _ _ _ _ = False + gos _ [] [] = True + gos env (t1:ts1) (t2:ts2) = go env t1 t2 && gos env ts1 ts2 + gos _ _ _ = False - tc_vis :: TyCon -> [Bool] -- True for the fields we should ignore - tc_vis tc | vis_only = inviss ++ repeat False -- Ignore invisibles - | otherwise = repeat False -- Ignore nothing - -- The repeat False is necessary because tycons - -- can legitimately be oversaturated - where - bndrs = tyConBinders tc - inviss = map isInvisibleTyConBinder bndrs - - orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] - -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function @@ -543,7 +602,7 @@ nonDetCmpTypeX env orig_t1 orig_t2 = -- Returns both the resulting ordering relation between -- the two types and whether either contains a cast. go :: RnEnv2 -> Type -> Type -> TypeOrdering - -- See Note [Comparing nullary type synonyms]. + -- See Note [Comparing nullary type synonyms] go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1066,7 +1066,7 @@ unify_ty :: UMEnv -- Respects newtypes, PredTypes -- See Note [Computing equality on types] in GHC.Core.Type unify_ty _env (TyConApp tc1 []) (TyConApp tc2 []) _kco - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare | tc1 == tc2 = return () ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -797,6 +788,8 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' , text "matchPmChecked" <+> ppr (isMatchContextPmChecked dflags origin ctxt)]) ; matches_nablas <- if isMatchContextPmChecked dflags origin ctxt + -- See Note [Expanding HsDo with XXExprGhcRn] Part 1. Wrinkle 1 for + -- pmc for pattern synonyms -- See Note [Long-distance information] in GHC.HsToCore.Pmc then addHsScrutTmCs (concat scrs) new_vars $ @@ -843,16 +836,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,60 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = mayLookIdentical act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = mayLookIdentical ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when we find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by + `GHC.Core.TyCo.Compare.mayLookIdentical` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6089,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6172,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6434,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6458,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -212,7 +212,7 @@ mk_failable_expr doFlav pat@(L loc _) expr fail_op = mk_fail_block :: HsDoFlavour -> LPat GhcRn -> LHsExpr GhcRn -> FailOperator GhcRn -> TcM (HsExpr GhcRn) mk_fail_block doFlav pat@(L ploc _) e (Just (SyntaxExprRn fail_op)) = do dflags <- getDynFlags - return $ HsLam noAnn LamSingle $ mkMatchGroup (doExpansionOrigin doFlav) -- \ + return $ HsLam noAnn LamCases $ mkMatchGroup (doExpansionOrigin doFlav) -- \ (wrapGenSpan [ genHsCaseAltDoExp doFlav (mkVisPat pat) e -- pat -> expr , fail_alt_case dflags pat fail_op -- _ -> fail "fail pattern" ]) @@ -356,25 +356,42 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash at runtime. -* That call of `fail` will (rightly) automatically generate a `MonadFail` constraint. So if the - pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate - a `MonadFail` constraint that isn't needed. +* According to the language specification, when the pattern is irrefutable, + we should not add the `fail` alternative. This is important because + the occurrence of `fail` means that the typechecker will generate a `MonadFail` constraint, + and irrefutable patterns shouldn't need a fail alternative. -* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. - When the pattern is irrefutable, we do not add the fail block. - This is important because the occurrence of `fail` means that the typechecker - will generate a `MonadFail` constraint, and the language spec says that - we should not do that for irrefutable patterns. +* _Wrinkel 1_: Note that pattern synonyms count as refutable during type checking, + (see `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`). They will hence generate a + `MonadFail` constraint and they will always be wrapped in a `fail`able-block. - Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate - a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + Consider a patten synonym declaration (testcase T24552): + + pattern MyJust :: a -> Maybe a + pattern MyJust x <- Just x where MyJust = Just + + and a `do`-block with the following bind and return statement + + do { MyJust x <- [MyNothing, MyJust ()] + ; return x } + + The `do`-expansion will generate the expansion + + (>>=) ([MyNothing, MyJust ()]) + (\case MyJust x -> return x -- (1) + _ -> fail "failable pattern .. " -- (2) + ) + + This code (specifically the `match` spanning lines (1) and (2)) is a compiler generated code; + the associated `Origin` in tagged `Generated` + The alternative statements will thus be ignored by the pattern match check (c.f. `isMatchContextPmChecked`). + This ensures we do not generate spurious redundant-pattern-match warnings due to the line (2) above. + See Note [Generated code and pattern-match checking] + See Note [Long-distance information in matchWrapper] * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we - attach to that constraint? It should be a good one, because it'll show up in error - messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the + attach to that constraint? When the `MonadFail` constraint can't be solved, it'll show up in error + messages and it needs to be a good location. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs) ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -311,7 +311,7 @@ can_eq_nc -> Type -> Type -- RHS, after and before type-synonym expansion, resp -> TcS (StopOrContinue (Either IrredCt EqCt)) --- See Note [Comparing nullary type synonyms] in GHC.Core.Type. +-- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare can_eq_nc _flat _rdr_env _envs ev eq_rel ty1@(TyConApp tc1 []) _ps_ty1 (TyConApp tc2 []) _ps_ty2 | tc1 == tc2 = canEqReflexive ev eq_rel ty1 ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -95,7 +95,7 @@ module GHC.Tc.Utils.TcType ( -- Re-exported from GHC.Core.TyCo.Compare -- mainly just for back-compat reasons eqType, eqTypes, nonDetCmpType, nonDetCmpTypes, eqTypeX, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, mayLookIdentical, tcEqTyConApps, eqForAllVis, eqVarBndrs, --------------------------------- @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== docs/users_guide/hints.rst ===================================== @@ -273,22 +273,6 @@ Use ``foreign import`` (a GHC extension) to plug into fast libraries: :ref:`ffi` describes the foreign function interface. -Don't use ``Float``\s: - If you're using ``Complex``, definitely use ``Complex Double`` - rather than ``Complex Float`` (the former is specialised heavily, - but the latter isn't). - - ``Floats`` (probably 32-bits) are almost always a bad idea, anyway, - unless you Really Know What You Are Doing. Use ``Double``\s. - There's rarely a speed disadvantage—modern machines will use the - same floating-point unit for both. With ``Double``\s, you are much - less likely to hang yourself with numerical errors. - - One time when ``Float`` might be a good idea is if you have a *lot* - of them, say a giant array of ``Float``\s. They take up half the - space in the heap compared to ``Doubles``. However, this isn't true - on a 64-bit machine. - Use unboxed arrays (``UArray``) GHC supports arrays of unboxed elements, for several basic arithmetic element types including ``Int`` and ``Char``: see the ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.21.0.0 *TBA* + * Improve `toInteger :: Word32 -> Integer` on 64-bit platforms ([CLC proposal #259](https://github.com/haskell/core-libraries-committee/issues/259)) + ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * The top-level handler for uncaught exceptions now displays the output of `displayException` rather than `show` ([CLC proposal #198](https://github.com/haskell/core-libraries-committee/issues/198)) ===================================== libraries/ghc-internal/src/GHC/Internal/Word.hs ===================================== @@ -592,7 +592,13 @@ instance Integral Word32 where mod x y = rem x y divMod x y = quotRem x y - toInteger (W32# x#) = integerFromWord# (word32ToWord# x#) + toInteger (W32# x#) = +#if WORD_SIZE_IN_BITS > 32 + -- In this case the conversion to Int# cannot overflow. + IS (word2Int# (word32ToWord# x#)) +#else + integerFromWord# (word32ToWord# x#) +#endif -- | @since base-2.01 instance Bits Word32 where ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,14 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude +import qualified Prelude as P + +pattern MyNothing :: Maybe a +pattern MyNothing <- Nothing where MyNothing = Nothing + +pattern MyJust :: a -> Maybe a +pattern MyJust x <- Just x where MyJust = Just + +main = print $ do MyJust x <- [MyNothing, MyJust ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3acfad971a52062ee289fa8238f334045ad83ee9...08876875de854728a2146f8bc582ba5a0dc2abf6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3acfad971a52062ee289fa8238f334045ad83ee9...08876875de854728a2146f8bc582ba5a0dc2abf6 You're receiving 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 Mar 23 04:14:11 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Sat, 23 Mar 2024 00:14:11 -0400 Subject: [Git][ghc/ghc][wip/andreask/shortcut_bug] 30 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <65fe5713617d7_399d472c8a4543955@gitlab.mail> Cheng Shao pushed to branch wip/andreask/shortcut_bug at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 0b18bd27 by Andreas Klebinger at 2024-03-23T04:13:43+00:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d42a4e7d45dd90652d25f848c36bacb04d9fb64...0b18bd2767142490f2d6512ff82c1e4193383e34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d42a4e7d45dd90652d25f848c36bacb04d9fb64...0b18bd2767142490f2d6512ff82c1e4193383e34 You're receiving 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 Mar 23 04:21:22 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 00:21:22 -0400 Subject: [Git][ghc/ghc][master] Improve toInteger @Word32 on 64-bit platforms Message-ID: <65fe58c2e3b8b_399d473115a2891fa@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 2 changed files: - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/Word.hs Changes: ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,8 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.21.0.0 *TBA* + * Improve `toInteger :: Word32 -> Integer` on 64-bit platforms ([CLC proposal #259](https://github.com/haskell/core-libraries-committee/issues/259)) + ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * The top-level handler for uncaught exceptions now displays the output of `displayException` rather than `show` ([CLC proposal #198](https://github.com/haskell/core-libraries-committee/issues/198)) ===================================== libraries/ghc-internal/src/GHC/Internal/Word.hs ===================================== @@ -592,7 +592,13 @@ instance Integral Word32 where mod x y = rem x y divMod x y = quotRem x y - toInteger (W32# x#) = integerFromWord# (word32ToWord# x#) + toInteger (W32# x#) = +#if WORD_SIZE_IN_BITS > 32 + -- In this case the conversion to Int# cannot overflow. + IS (word2Int# (word32ToWord# x#)) +#else + integerFromWord# (word32ToWord# x#) +#endif -- | @since base-2.01 instance Bits Word32 where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a8ac65a51fd3163b4a189b427bd495bfdc61cf5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a8ac65a51fd3163b4a189b427bd495bfdc61cf5 You're receiving 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 Mar 23 04:22:00 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 00:22:00 -0400 Subject: [Git][ghc/ghc][master] Fix for #24552 (see testcase T24552) Message-ID: <65fe58e818581_399d4732b2ffc12050@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - 5 changed files: - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Tc/Gen/Do.hs - + testsuite/tests/patsyn/should_run/T24552.hs - + testsuite/tests/patsyn/should_run/T24552.stdout - testsuite/tests/patsyn/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..)) import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr) -import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated ) +import GHC.Types.Basic ( Origin(..), requiresPMC ) import GHC.Types.SourceText ( FractionalLit, @@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern. JJQC 30-Nov-1997 -} -matchWrapper ctxt scrs (MG { mg_alts = L _ matches' +matchWrapper ctxt scrs (MG { mg_alts = L _ matches , mg_ext = MatchGroupTc arg_tys rhs_ty origin }) = do { dflags <- getDynFlags ; locn <- getSrcSpanDs - ; let matches - = if any (is_pat_syn_match origin) matches' - then filter (non_gen_wc origin) matches' - -- filter out the wild pattern fail alternatives - -- which have a do expansion origin - -- They generate spurious overlapping warnings - -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do - else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys (m:_) -> @@ -797,6 +788,8 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' , text "matchPmChecked" <+> ppr (isMatchContextPmChecked dflags origin ctxt)]) ; matches_nablas <- if isMatchContextPmChecked dflags origin ctxt + -- See Note [Expanding HsDo with XXExprGhcRn] Part 1. Wrinkle 1 for + -- pmc for pattern synonyms -- See Note [Long-distance information] in GHC.HsToCore.Pmc then addHsScrutTmCs (concat scrs) new_vars $ @@ -843,16 +836,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' $ NEL.nonEmpty $ replicate (length (grhssGRHSs m)) ldi_nablas - is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin - = isPatSyn l_pat - is_pat_syn_match _ _ = False - -- generated match pattern that is not a wildcard - non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool - non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _)) - = not . isDoExpansionGenerated $ origin - non_gen_wc _ _ = True - {- Note [Long-distance information in matchWrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pattern match checking in matchWrapper is done conditionally, depending ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -212,7 +212,7 @@ mk_failable_expr doFlav pat@(L loc _) expr fail_op = mk_fail_block :: HsDoFlavour -> LPat GhcRn -> LHsExpr GhcRn -> FailOperator GhcRn -> TcM (HsExpr GhcRn) mk_fail_block doFlav pat@(L ploc _) e (Just (SyntaxExprRn fail_op)) = do dflags <- getDynFlags - return $ HsLam noAnn LamSingle $ mkMatchGroup (doExpansionOrigin doFlav) -- \ + return $ HsLam noAnn LamCases $ mkMatchGroup (doExpansionOrigin doFlav) -- \ (wrapGenSpan [ genHsCaseAltDoExp doFlav (mkVisPat pat) e -- pat -> expr , fail_alt_case dflags pat fail_op -- _ -> fail "fail pattern" ]) @@ -356,25 +356,42 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash at runtime. -* That call of `fail` will (rightly) automatically generate a `MonadFail` constraint. So if the - pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate - a `MonadFail` constraint that isn't needed. +* According to the language specification, when the pattern is irrefutable, + we should not add the `fail` alternative. This is important because + the occurrence of `fail` means that the typechecker will generate a `MonadFail` constraint, + and irrefutable patterns shouldn't need a fail alternative. -* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. - When the pattern is irrefutable, we do not add the fail block. - This is important because the occurrence of `fail` means that the typechecker - will generate a `MonadFail` constraint, and the language spec says that - we should not do that for irrefutable patterns. +* _Wrinkel 1_: Note that pattern synonyms count as refutable during type checking, + (see `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`). They will hence generate a + `MonadFail` constraint and they will always be wrapped in a `fail`able-block. - Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate - a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. - because after desugaring, it is marked as irrefutable! To avoid such - spurious warnings and type checker errors, we filter out those patterns that appear - in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + Consider a patten synonym declaration (testcase T24552): + + pattern MyJust :: a -> Maybe a + pattern MyJust x <- Just x where MyJust = Just + + and a `do`-block with the following bind and return statement + + do { MyJust x <- [MyNothing, MyJust ()] + ; return x } + + The `do`-expansion will generate the expansion + + (>>=) ([MyNothing, MyJust ()]) + (\case MyJust x -> return x -- (1) + _ -> fail "failable pattern .. " -- (2) + ) + + This code (specifically the `match` spanning lines (1) and (2)) is a compiler generated code; + the associated `Origin` in tagged `Generated` + The alternative statements will thus be ignored by the pattern match check (c.f. `isMatchContextPmChecked`). + This ensures we do not generate spurious redundant-pattern-match warnings due to the line (2) above. + See Note [Generated code and pattern-match checking] + See Note [Long-distance information in matchWrapper] * _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we - attach to that constraint? It should be a good one, because it'll show up in error - messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the + attach to that constraint? When the `MonadFail` constraint can't be solved, it'll show up in error + messages and it needs to be a good location. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs) ===================================== testsuite/tests/patsyn/should_run/T24552.hs ===================================== @@ -0,0 +1,14 @@ +{-# language PatternSynonyms #-} + +module Main where + +import Prelude +import qualified Prelude as P + +pattern MyNothing :: Maybe a +pattern MyNothing <- Nothing where MyNothing = Nothing + +pattern MyJust :: a -> Maybe a +pattern MyJust x <- Just x where MyJust = Just + +main = print $ do MyJust x <- [MyNothing, MyJust ()] ; return x ===================================== testsuite/tests/patsyn/should_run/T24552.stdout ===================================== @@ -0,0 +1 @@ +[()] ===================================== testsuite/tests/patsyn/should_run/all.T ===================================== @@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0']) test('T14228', normal, compile_and_run, ['']) test('records-poly-update', normal, compile_and_run, ['']) +test('T24552', normal, compile_and_run, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c48f2b952ad4ee995e4eafa458b7a8d3c442415 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c48f2b952ad4ee995e4eafa458b7a8d3c442415 You're receiving 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 Mar 23 04:22:55 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 00:22:55 -0400 Subject: [Git][ghc/ghc][master] Print more info about kinds in error messages Message-ID: <65fe591f78ce8_399d4732c73d0175b4@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 13 changed files: - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - + testsuite/tests/typecheck/should_fail/T24553.hs - + testsuite/tests/typecheck/should_fail/T24553.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -228,7 +228,7 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = andEq TEQX e = hasCast e andEq TEQ e = e - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare go (D _ (TyConApp tc1 [])) (D _ (TyConApp tc2 [])) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Compare.hs ===================================== @@ -12,8 +12,9 @@ module GHC.Core.TyCo.Compare ( nonDetCmpTypesX, nonDetCmpTc, eqVarBndrs, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTyConApps, + mayLookIdentical, -- * Visiblity comparision eqForAllVis, cmpForAllVis @@ -22,7 +23,8 @@ module GHC.Core.TyCo.Compare ( import GHC.Prelude -import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe ) +import GHC.Core.Type( typeKind, coreView, tcSplitAppTyNoView_maybe, splitAppTyNoView_maybe + , isLevityTy, isRuntimeRepTy, isMultiplicityTy ) import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs @@ -129,52 +131,119 @@ Cabal. See #19226. -} +mayLookIdentical :: Type -> Type -> Bool +-- | Returns True if the /visible/ part of the types +-- might look equal, even if they are really unequal (in the invisible bits) +-- +-- This function is very similar to tc_eq_type but it is much more +-- heuristic. Notably, it is always safe to return True, even with types +-- that might (in truth) be unequal -- this affects error messages only +-- (Originally there were one function with an extra flag, but the result +-- was hard to understand.) +mayLookIdentical orig_ty1 orig_ty2 + = go orig_env orig_ty1 orig_ty2 + where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + + go :: RnEnv2 -> Type -> Type -> Bool + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True + + go env t1 t2 | Just t1' <- coreView t1 = go env t1' t2 + go env t1 t2 | Just t2' <- coreView t2 = go env t1 t2' + + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True + + go env (ForAllTy (Bndr tv1 vis1) ty1) + (ForAllTy (Bndr tv2 vis2) ty2) + = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] + && go (rnBndr2 env tv1 tv2) ty1 ty2 + -- Visible stuff only: ignore kinds of binders + + -- If we have (forall (r::RunTimeRep). ty1 ~ blah) then respond + -- with True. Reason: the type pretty-printer defaults RuntimeRep + -- foralls (see Ghc.Iface.Type.hideNonStandardTypes). That can make, + -- say (forall r. TYPE r -> Type) into (Type -> Type), so it looks the + -- same as a very different type (#24553). By responding True, we + -- tell GHC (see calls of mayLookIdentical) to display without defaulting. + -- See Note [Showing invisible bits of types in error messages] + -- in GHC.Tc.Errors.Ppr + go _ (ForAllTy b _) _ | isDefaultableBndr b = True + go _ _ (ForAllTy b _) | isDefaultableBndr b = True + + go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) + = go env arg1 arg2 && go env res1 res2 && go env w1 w2 + -- Visible stuff only: ignore agg kinds + + -- See Note [Equality on AppTys] in GHC.Core.Type + go env (AppTy s1 t1) ty2 + | Just (s2, t2) <- tcSplitAppTyNoView_maybe ty2 + = go env s1 s2 && go env t1 t2 + go env ty1 (AppTy s2 t2) + | Just (s1, t1) <- tcSplitAppTyNoView_maybe ty1 + = go env s1 s2 && go env t1 t2 + + go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) + = tc1 == tc2 && gos env (tyConBinders tc1) ts1 ts2 + + go _ _ _ = False + + gos :: RnEnv2 -> [TyConBinder] -> [Type] -> [Type] -> Bool + gos _ _ [] [] = True + gos env bs (t1:ts1) (t2:ts2) + | (invisible, bs') <- case bs of + [] -> (False, []) + (b:bs) -> (isInvisibleTyConBinder b, bs) + = (invisible || go env t1 t2) && gos env bs' ts1 ts2 + + gos _ _ _ _ = False + + -- | Type equality comparing both visible and invisible arguments and expanding -- type synonyms. tcEqTypeNoSyns :: Type -> Type -> Bool -tcEqTypeNoSyns ta tb = tc_eq_type False False ta tb - --- | Like 'tcEqType', but returns True if the /visible/ part of the types --- are equal, even if they are really unequal (in the invisible bits) -tcEqTypeVis :: Type -> Type -> Bool -tcEqTypeVis ty1 ty2 = tc_eq_type False True ty1 ty2 +tcEqTypeNoSyns ta tb = tc_eq_type False ta tb -- | Like 'pickyEqTypeVis', but returns a Bool for convenience pickyEqType :: Type -> Type -> Bool -- Check when two types _look_ the same, _including_ synonyms. -- So (pickyEqType String [Char]) returns False -- This ignores kinds and coercions, because this is used only for printing. -pickyEqType ty1 ty2 = tc_eq_type True False ty1 ty2 +pickyEqType ty1 ty2 = tc_eq_type True ty1 ty2 -- | Real worker for 'tcEqType'. No kind check! tc_eq_type :: Bool -- ^ True <=> do not expand type synonyms - -> Bool -- ^ True <=> compare visible args only -> Type -> Type -> Bool -- Flags False, False is the usual setting for tc_eq_type -- See Note [Computing equality on types] in Type -tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 +{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +tc_eq_type keep_syns orig_ty1 orig_ty2 = go orig_env orig_ty1 orig_ty2 where + orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] + go :: RnEnv2 -> Type -> Type -> Bool - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. - go _ (TyConApp tc1 []) (TyConApp tc2 []) - | tc1 == tc2 - = True + -- See Note [Comparing nullary type synonyms] + go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = True go env t1 t2 | not keep_syns, Just t1' <- coreView t1 = go env t1' t2 go env t1 t2 | not keep_syns, Just t2' <- coreView t2 = go env t1 t2' - go env (TyVarTy tv1) (TyVarTy tv2) - = rnOccL env tv1 == rnOccR env tv2 - - go _ (LitTy lit1) (LitTy lit2) - = lit1 == lit2 + go env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 == rnOccR env tv2 + go _ (LitTy lit1) (LitTy lit2) = lit1 == lit2 + go env (CastTy t1 _) t2 = go env t1 t2 + go env t1 (CastTy t2 _) = go env t1 t2 + go _ (CoercionTy {}) (CoercionTy {}) = True go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) = vis1 `eqForAllVis` vis2 -- See Note [ForAllTy and type equality] - && (vis_only || go env (varType tv1) (varType tv2)) + && go env (varType tv1) (varType tv2) && go (rnBndr2 env tv1 tv2) ty1 ty2 -- Make sure we handle all FunTy cases since falling through to the @@ -183,11 +252,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 -- See Note [Equality on FunTys] in GHC.Core.TyCo.Rep: we must check -- kinds here go env (FunTy _ w1 arg1 res1) (FunTy _ w2 arg2 res2) - = kinds_eq && go env arg1 arg2 && go env res1 res2 && go env w1 w2 - where - kinds_eq | vis_only = True - | otherwise = go env (typeKind arg1) (typeKind arg2) && - go env (typeKind res1) (typeKind res2) + = go env (typeKind arg1) (typeKind arg2) && + go env (typeKind res1) (typeKind res2) && + go env arg1 arg2 && go env res1 res2 && go env w1 w2 -- See Note [Equality on AppTys] in GHC.Core.Type go env (AppTy s1 t1) ty2 @@ -198,32 +265,24 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 = go env s1 s2 && go env t1 t2 go env (TyConApp tc1 ts1) (TyConApp tc2 ts2) - = tc1 == tc2 && gos env (tc_vis tc1) ts1 ts2 - - go env (CastTy t1 _) t2 = go env t1 t2 - go env t1 (CastTy t2 _) = go env t1 t2 - go _ (CoercionTy {}) (CoercionTy {}) = True + = tc1 == tc2 && gos env ts1 ts2 go _ _ _ = False - gos _ _ [] [] = True - gos env (ig:igs) (t1:ts1) (t2:ts2) = (ig || go env t1 t2) - && gos env igs ts1 ts2 - gos _ _ _ _ = False + gos _ [] [] = True + gos env (t1:ts1) (t2:ts2) = go env t1 t2 && gos env ts1 ts2 + gos _ _ _ = False - tc_vis :: TyCon -> [Bool] -- True for the fields we should ignore - tc_vis tc | vis_only = inviss ++ repeat False -- Ignore invisibles - | otherwise = repeat False -- Ignore nothing - -- The repeat False is necessary because tycons - -- can legitimately be oversaturated - where - bndrs = tyConBinders tc - inviss = map isInvisibleTyConBinder bndrs - - orig_env = mkRnEnv2 $ mkInScopeSet $ tyCoVarsOfTypes [orig_ty1, orig_ty2] - -{-# INLINE tc_eq_type #-} -- See Note [Specialising tc_eq_type]. +isDefaultableBndr :: ForAllTyBinder -> Bool +-- This function should line up with the defaulting done +-- by GHC.Iface.Type.defaultIfaceTyVarsOfKind +-- See Note [Showing invisible bits of types in error messages] +-- in GHC.Tc.Errors.Ppr +isDefaultableBndr (Bndr tv vis) + = isInvisibleForAllTyFlag vis && is_defaultable (tyVarKind tv) + where + is_defaultable ki = isLevityTy ki || isRuntimeRepTy ki || isMultiplicityTy ki -- | Do these denote the same level of visibility? 'Required' -- arguments are visible, others are not. So this function @@ -543,7 +602,7 @@ nonDetCmpTypeX env orig_t1 orig_t2 = -- Returns both the resulting ordering relation between -- the two types and whether either contains a cast. go :: RnEnv2 -> Type -> Type -> TypeOrdering - -- See Note [Comparing nullary type synonyms]. + -- See Note [Comparing nullary type synonyms] go _ (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = TEQ ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Core.TyCo.Ppr pprTyVar, pprTyVars, pprThetaArrowTy, pprClassPred, pprKind, pprParendKind, pprTyLit, - pprDataCons, pprWithExplicitKindsWhen, + pprDataCons, pprWithInvisibleBitsWhen, pprWithTYPE, pprSourceTyCon, @@ -330,13 +330,14 @@ pprTypeApp tc tys -- TODO: toIfaceTcArgs seems rather wasteful here ------------------ --- | Display all kind information (with @-fprint-explicit-kinds@) when the --- provided 'Bool' argument is 'True'. --- See @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". -pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc -pprWithExplicitKindsWhen b +-- | Display all foralls, runtime-reps, and kind information +-- when provided 'Bool' argument is 'True'. See GHC.Tc.Errors.Ppr +-- Note [Showing invisible bits of types in error messages] +pprWithInvisibleBitsWhen :: Bool -> SDoc -> SDoc +pprWithInvisibleBitsWhen b = updSDocContext $ \ctx -> - if b then ctx { sdocPrintExplicitKinds = True } + if b then ctx { sdocPrintExplicitKinds = True + , sdocPrintExplicitRuntimeReps = True } else ctx -- | This variant preserves any use of TYPE in a type, effectively ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1066,7 +1066,7 @@ unify_ty :: UMEnv -- Respects newtypes, PredTypes -- See Note [Computing equality on types] in GHC.Core.Type unify_ty _env (TyConApp tc1 []) (TyConApp tc2 []) _kco - -- See Note [Comparing nullary type synonyms] in GHC.Core.Type. + -- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare | tc1 == tc2 = return () ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -1189,7 +1189,7 @@ defaultIfaceTyVarsOfKind def_rep def_mult ty = go emptyFsEnv True ty -> IfaceType go subs True (IfaceForAllTy (Bndr (IfaceTvBndr (var, var_kind)) argf) ty) | isInvisibleForAllTyFlag argf -- Don't default *visible* quantification - -- or we get the mess in #13963 + -- or we get the mess in #13963 , Just substituted_ty <- check_substitution var_kind = let subs' = extendFsEnv subs var substituted_ty -- Record that we should replace it with LiftedRep/Lifted/Many, ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -2094,10 +2094,9 @@ mkMismatchMsg item ty1 ty2 = case orig of TypeEqOrigin { uo_actual, uo_expected, uo_thing = mb_thing } -> (TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item - , teq_mismatch_ty1 = ty1 - , teq_mismatch_ty2 = ty2 + { teq_mismatch_item = item + , teq_mismatch_ty1 = ty1 + , teq_mismatch_ty2 = ty2 , teq_mismatch_actual = uo_actual , teq_mismatch_expected = uo_expected , teq_mismatch_what = mb_thing @@ -2121,25 +2120,6 @@ mkMismatchMsg item ty1 ty2 = where orig = errorItemOrigin item mb_same_occ = sameOccExtras ty2 ty1 - ppr_explicit_kinds = shouldPprWithExplicitKinds ty1 ty2 orig - --- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) --- in an 'SDoc' when a type mismatch occurs to due invisible kind arguments. --- --- This function first checks to see if the 'CtOrigin' argument is a --- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible --- equality; if it's not, definitely print the kinds. Even if the equality is --- a visible equality, check the expected/actual types to see if the types --- have equal visible components. If the 'CtOrigin' is --- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. -shouldPprWithExplicitKinds :: Type -> Type -> CtOrigin -> Bool -shouldPprWithExplicitKinds _ty1 _ty2 (TypeEqOrigin { uo_actual = act - , uo_expected = exp - , uo_visible = vis }) - | not vis = True -- See tests T15870, T16204c - | otherwise = tcEqTypeVis act exp -- See tests T9171, T9144. -shouldPprWithExplicitKinds ty1 ty2 _ct - = tcEqTypeVis ty1 ty2 {- Note [Insoluble mis-match] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2403,29 +2383,6 @@ results in in the import of ‘Data.Monoid’ -} -{- -Note [Kind arguments in error messages] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It can be terribly confusing to get an error message like (#9171) - - Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ - with actual type ‘GetParam Base (GetParam Base Int)’ - -The reason may be that the kinds don't match up. Typically you'll get -more useful information, but not when it's as a result of ambiguity. - -To mitigate this, GHC attempts to enable the -fprint-explicit-kinds flag -whenever any error message arises due to a kind mismatch. This means that -the above error message would instead be displayed as: - - Couldn't match expected type - ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ - with actual type - ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ - -Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. --} - ----------------------- -- relevantBindings looks at the value environment and finds values whose -- types mention any of the offending type variables. It has to be ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -54,8 +54,8 @@ import GHC.Core.ConLike import GHC.Core.FamInstEnv ( FamInst(..), famInstAxiom, pprFamInst ) import GHC.Core.InstEnv import GHC.Core.TyCo.Rep (Type(..)) -import GHC.Core.TyCo.Ppr (pprWithExplicitKindsWhen, - pprSourceTyCon, pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) +import GHC.Core.TyCo.Ppr (pprWithInvisibleBitsWhen, pprSourceTyCon, + pprTyVars, pprWithTYPE, pprTyVar, pprTidiedType) import GHC.Core.PatSyn ( patSynName, pprPatSynType ) import GHC.Core.Predicate import GHC.Core.Type @@ -536,7 +536,7 @@ instance Diagnostic TcRnMessage where , text "cannot be inferred from the right-hand side." ] in (injectivityErrorHerald $$ body $$ text "In the type family equation:", show_kinds) - in mkSimpleDecorated $ pprWithExplicitKindsWhen show_kinds $ + in mkSimpleDecorated $ pprWithInvisibleBitsWhen show_kinds $ hang herald 2 (vcat (map (pprCoAxBranchUser fam_tc) (eqn1 : rest_eqns))) TcRnBangOnUnliftedType ty @@ -1182,7 +1182,7 @@ instance Diagnostic TcRnMessage where ppr con <+> dcolon <+> ppr (dataConDisplayType True con)) IsGADT -> (text "A newtype must not be a GADT", - ppr con <+> dcolon <+> pprWithExplicitKindsWhen sneaky_eq_spec + ppr con <+> dcolon <+> pprWithInvisibleBitsWhen sneaky_eq_spec (ppr $ dataConDisplayType show_linear_types con)) HasConstructorContext -> (text "A newtype constructor must not have a context in its type", @@ -1432,7 +1432,7 @@ instance Diagnostic TcRnMessage where , text "Perhaps enable PolyKinds or add a kind signature" ]) TcRnUninferrableTyVar tidied_tvs context -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Uninferrable type variable" <> plural tidied_tvs <+> pprWithCommas pprTyVar tidied_tvs @@ -1440,7 +1440,7 @@ instance Diagnostic TcRnMessage where , pprUninferrableTyVarCtx context ] TcRnSkolemEscape escapees tv orig_ty -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ sep [ text "Cannot generalise type; skolem" <> plural escapees , quotes $ pprTyVars escapees , text "would escape" <+> itsOrTheir escapees <+> text "scope" @@ -1884,7 +1884,7 @@ instance Diagnostic TcRnMessage where TcRnInvalidDefaultedTyVar wanteds proposal bad_tvs -> mkSimpleDecorated $ - pprWithExplicitKindsWhen True $ + pprWithInvisibleBitsWhen True $ vcat [ text "Invalid defaulting proposal." , hang (text "The following type variable" <> plural (NE.toList bad_tvs) <+> text "cannot be defaulted, as" <+> why <> colon) 2 (pprQuotedList (NE.toList bad_tvs)) @@ -4146,17 +4146,18 @@ pprMismatchMsg _ | otherwise = text "kind" <+> quotes (ppr exp) pprMismatchMsg ctxt - (TypeEqMismatch { teq_mismatch_ppr_explicit_kinds = ppr_explicit_kinds - , teq_mismatch_item = item + (TypeEqMismatch { teq_mismatch_item = item , teq_mismatch_ty1 = ty1 -- These types are the actual types , teq_mismatch_ty2 = ty2 -- that don't match; may be swapped , teq_mismatch_expected = exp -- These are the context of , teq_mismatch_actual = act -- the mis-match , teq_mismatch_what = mb_thing , teq_mb_same_occ = mb_same_occ }) - = addArising ct_loc $ pprWithExplicitKindsWhen ppr_explicit_kinds msg - $$ maybe empty pprSameOccInfo mb_same_occ + = addArising ct_loc $ + pprWithInvisibleBitsWhen ppr_invis_bits msg + $$ maybe empty pprSameOccInfo mb_same_occ where + msg | Just (torc, rep) <- sORTKind_maybe exp = msg_for_exp_sort torc rep @@ -4219,6 +4220,7 @@ pprMismatchMsg ctxt ct_loc = errorItemCtLoc item orig = errorItemOrigin item level = ctLocTypeOrKind_maybe ct_loc `orElse` TypeLevel + ppr_invis_bits = shouldPprWithInvisibleBits ty1 ty2 orig num_args_msg = case level of KindLevel @@ -4310,6 +4312,60 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra) _ -> pprTheta wanteds +-- | Whether to print explicit kinds (with @-fprint-explicit-kinds@) +-- in an 'SDoc' when a type mismatch occurs to due invisible parts of the types. +-- See Note [Showing invisible bits of types in error messages] +-- +-- This function first checks to see if the 'CtOrigin' argument is a +-- 'TypeEqOrigin'. If so, it first checks whether the equality is a visible +-- equality; if it's not, definitely print the kinds. Even if the equality is +-- a visible equality, check the expected/actual types to see if the types +-- have equal visible components. If the 'CtOrigin' is +-- not a 'TypeEqOrigin', fall back on the actual mismatched types themselves. +shouldPprWithInvisibleBits :: Type -> Type -> CtOrigin -> Bool +shouldPprWithInvisibleBits _ty1 _ty2 (TypeEqOrigin { uo_actual = act + , uo_expected = exp + , uo_visible = vis }) + | not vis = True -- See tests T15870, T16204c + | otherwise = mayLookIdentical act exp -- See tests T9171, T9144. +shouldPprWithInvisibleBits ty1 ty2 _ct + = mayLookIdentical ty1 ty2 + +{- Note [Showing invisible bits of types in error messages] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It can be terribly confusing to get an error message like (#9171) + + Couldn't match expected type ‘GetParam Base (GetParam Base Int)’ + with actual type ‘GetParam Base (GetParam Base Int)’ + +The reason may be that the kinds don't match up. Typically you'll get +more useful information, but not when it's as a result of ambiguity. + +To mitigate this, when we find a type or kind mis-match: + +* See if normally-visible parts of the type would make the two types + look different. This check is made by + `GHC.Core.TyCo.Compare.mayLookIdentical` + +* If not, display the types with their normally-visible parts made visible, + by setting flags in the `SDocContext": + Specifically: + - Display kind arguments: sdocPrintExplicitKinds + - Don't default away runtime-reps: sdocPrintExplicitRuntimeReps, + which controls `GHC.Iface.Type.hideNonStandardTypes` + (NB: foralls are always printed by pprType, it turns out.) + +As a result the above error message would instead be displayed as: + + Couldn't match expected type + ‘GetParam @* @k2 @* Base (GetParam @* @* @k2 Base Int)’ + with actual type + ‘GetParam @* @k20 @* Base (GetParam @* @* @k20 Base Int)’ + +Which makes it clearer that the culprit is the mismatch between `k2` and `k20`. + +Another example of what goes wrong without this: #24553. +-} {- ********************************************************************* * * @@ -6033,7 +6089,7 @@ pprIllegalInstance = \case IllegalFamilyInstance reason -> pprIllegalFamilyInstance reason IllegalFamilyApplicationInInstance inst_ty invis_arg tf_tc tf_args -> - pprWithExplicitKindsWhen invis_arg $ + pprWithInvisibleBitsWhen invis_arg $ hang (text "Illegal type synonym family application" <+> quotes (ppr tf_ty) <+> text "in instance" <> colon) 2 (ppr inst_ty) @@ -6116,7 +6172,7 @@ pprNotCovered clas , not_covered_invis_vis_tvs = undetermined_tvs , not_covered_liberal = which_cc_failed } = - pprWithExplicitKindsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ + pprWithInvisibleBitsWhen (isEmptyVarSet $ pSnd undetermined_tvs) $ vcat [ sep [ text "The" <+> ppWhen liberal (text "liberal") <+> text "coverage condition fails in class" @@ -6378,7 +6434,7 @@ pprInvalidAssocInstance = \case , text "mentions none of the type or kind variables of the class" <+> quotes (ppr cls <+> hsep (map ppr (classTyVars cls)))] AssocTyVarsDontMatch vis fam_tc exp_tys act_tys -> - pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $ + pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag vis) $ vcat [ text "Type indexes must match class instance head" , text "Expected:" <+> pp exp_tys , text " Actual:" <+> pp act_tys ] @@ -6402,7 +6458,7 @@ pprInvalidAssocDefault = \case let (pat_tv, pat_vis) = NE.head dups in (pat_vis, text "Illegal duplicate variable" <+> quotes (ppr pat_tv) <+> text "in:") - in pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ + in pprWithInvisibleBitsWhen (isInvisibleForAllTyFlag pat_vis) $ hang main_msg 2 (vcat [ppr_eqn, suggestion]) where ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -5508,8 +5508,7 @@ data MismatchMsg -- -- Test cases: T1470, tcfail212. | TypeEqMismatch - { teq_mismatch_ppr_explicit_kinds :: Bool - , teq_mismatch_item :: ErrorItem + { teq_mismatch_item :: ErrorItem , teq_mismatch_ty1 :: Type , teq_mismatch_ty2 :: Type , teq_mismatch_expected :: Type -- ^ The overall expected type ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -311,7 +311,7 @@ can_eq_nc -> Type -> Type -- RHS, after and before type-synonym expansion, resp -> TcS (StopOrContinue (Either IrredCt EqCt)) --- See Note [Comparing nullary type synonyms] in GHC.Core.Type. +-- See Note [Comparing nullary type synonyms] in GHC.Core.TyCo.Compare can_eq_nc _flat _rdr_env _envs ev eq_rel ty1@(TyConApp tc1 []) _ps_ty1 (TyConApp tc2 []) _ps_ty2 | tc1 == tc2 = canEqReflexive ev eq_rel ty1 ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -95,7 +95,7 @@ module GHC.Tc.Utils.TcType ( -- Re-exported from GHC.Core.TyCo.Compare -- mainly just for back-compat reasons eqType, eqTypes, nonDetCmpType, nonDetCmpTypes, eqTypeX, - pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, tcEqTypeVis, + pickyEqType, tcEqType, tcEqKind, tcEqTypeNoKindCheck, mayLookIdentical, tcEqTyConApps, eqForAllVis, eqVarBndrs, --------------------------------- @@ -888,7 +888,8 @@ tcTyFamInsts = map (\(_,b,c) -> (b,c)) . tcTyFamInstsAndVis -- to @C@, whereas @F Bool@ is paired with 'False' since it appears an a -- /visible/ argument to @C at . -- --- See also @Note [Kind arguments in error messages]@ in "GHC.Tc.Errors". +-- See also Note [Showing invisible bits of types in error messages] +-- in "GHC.Tc.Errors.Ppr". tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] tcTyFamInstsAndVis = tcTyFamInstsAndVisX False ===================================== testsuite/tests/typecheck/should_fail/T24553.hs ===================================== @@ -0,0 +1,8 @@ +module T24553 where + +import GHC.Exts + +type Foo :: * -> forall r. TYPE r -> * +newtype Foo m a = MkFoo () + +type Bar = Foo :: forall r. * -> TYPE r -> * ===================================== testsuite/tests/typecheck/should_fail/T24553.stderr ===================================== @@ -0,0 +1,6 @@ + +T24553.hs:8:12: error: [GHC-83865] + • Expected kind ‘forall (r :: RuntimeRep). * -> TYPE r -> *’, + but ‘Foo’ has kind ‘* -> forall (r :: RuntimeRep). TYPE r -> *’ + • In the type ‘Foo :: forall r. * -> TYPE r -> *’ + In the type declaration for ‘Bar’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -724,3 +724,5 @@ test('T17594d', normal, compile_fail, ['']) test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) +test('T24553', normal, compile_fail, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b72705e9b2ae5575aef92ede6ff975bbbe43004d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b72705e9b2ae5575aef92ede6ff975bbbe43004d You're receiving 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 Mar 23 04:23:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 00:23:34 -0400 Subject: [Git][ghc/ghc][master] docs: remove the don't use float hint Message-ID: <65fe59468e6d1_399d4736e84a020442@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 1 changed file: - docs/users_guide/hints.rst Changes: ===================================== docs/users_guide/hints.rst ===================================== @@ -273,22 +273,6 @@ Use ``foreign import`` (a GHC extension) to plug into fast libraries: :ref:`ffi` describes the foreign function interface. -Don't use ``Float``\s: - If you're using ``Complex``, definitely use ``Complex Double`` - rather than ``Complex Float`` (the former is specialised heavily, - but the latter isn't). - - ``Floats`` (probably 32-bits) are almost always a bad idea, anyway, - unless you Really Know What You Are Doing. Use ``Double``\s. - There's rarely a speed disadvantage—modern machines will use the - same floating-point unit for both. With ``Double``\s, you are much - less likely to hang yourself with numerical errors. - - One time when ``Float`` might be a good idea is if you have a *lot* - of them, say a giant array of ``Float``\s. They take up half the - space in the heap compared to ``Doubles``. However, this isn't true - on a 64-bit machine. - Use unboxed arrays (``UArray``) GHC supports arrays of unboxed elements, for several basic arithmetic element types including ``Int`` and ``Char``: see the View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f7cfc7ee00978fda14f31ce4a56ad4639c07138 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f7cfc7ee00978fda14f31ce4a56ad4639c07138 You're receiving 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 Mar 23 15:33:29 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 23 Mar 2024 11:33:29 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] 6 commits: Fix iface sharing Message-ID: <65fef649881f5_ba7dfd1204dc124731@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: 976e9697 by Matthew Pickering at 2024-03-21T14:11:59+00:00 Fix iface sharing - - - - - 4cee1644 by Matthew Pickering at 2024-03-23T11:58:13+00:00 Wip:mp - - - - - e5238b19 by Fendor at 2024-03-23T11:58:27+00:00 Migrate Finder to OsPath - - - - - a02da988 by Matthew Pickering at 2024-03-23T15:09:56+00:00 Delay deserialising IfaceExpr - - - - - 3d7910e5 by Matthew Pickering at 2024-03-23T15:11:36+00:00 lazyPutMaybe mi_extra_decls This seems like an oversight in the original patch to me. - - - - - 98269144 by Matthew Pickering at 2024-03-23T15:32:59+00:00 Missing nfdata - - - - - 26 changed files: - compiler/GHC.hs - compiler/GHC/Data/Strict.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Errors.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp/Binary.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/Module/Location.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - ghc/GHCi/UI.hs - ghc/ghc-bin.cabal.in - hadrian/src/Settings/Packages.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -76,6 +76,12 @@ module GHC ( ModuleGraph, emptyMG, mapMG, mkModuleGraph, mgModSummaries, mgLookupModule, ModSummary(..), ms_mod_name, ModLocation(..), + ml_hs_file, + ml_hi_file, + ml_dyn_hi_file, + ml_obj_file, + ml_dyn_obj_file, + ml_hie_file, getModSummary, getModuleGraph, isLoaded, ===================================== compiler/GHC/Data/Strict.hs ===================================== @@ -9,8 +9,11 @@ module GHC.Data.Strict ( Maybe(Nothing, Just), fromMaybe, + GHC.Data.Strict.maybe, Pair(And), - + expectJust, + fromLazy, + toLazy, -- Not used at the moment: -- -- Either(Left, Right), @@ -18,9 +21,12 @@ module GHC.Data.Strict ( ) where import GHC.Prelude hiding (Maybe(..), Either(..)) +import GHC.Stack.Types + import Control.Applicative import Data.Semigroup import Data.Data +import qualified Data.Maybe as Lazy data Maybe a = Nothing | Just !a deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data) @@ -29,6 +35,10 @@ fromMaybe :: a -> Maybe a -> a fromMaybe d Nothing = d fromMaybe _ (Just x) = x +maybe :: b -> (a -> b) -> Maybe a -> b +maybe d _ Nothing = d +maybe _ f (Just x) = f x + apMaybe :: Maybe (a -> b) -> Maybe a -> Maybe b apMaybe (Just f) (Just x) = Just (f x) apMaybe _ _ = Nothing @@ -37,6 +47,19 @@ altMaybe :: Maybe a -> Maybe a -> Maybe a altMaybe Nothing r = r altMaybe l _ = l +fromLazy :: Lazy.Maybe a -> Maybe a +fromLazy (Lazy.Just a) = Just a +fromLazy Lazy.Nothing = Nothing + +toLazy :: Maybe a -> Lazy.Maybe a +toLazy (Just a) = Lazy.Just a +toLazy Nothing = Lazy.Nothing + +expectJust :: HasCallStack => String -> Maybe a -> a +{-# INLINE expectJust #-} +expectJust _ (Just x) = x +expectJust err Nothing = error ("expectJust " ++ err) + instance Semigroup a => Semigroup (Maybe a) where Nothing <> b = b a <> Nothing = a ===================================== compiler/GHC/Driver/Backpack.hs ===================================== @@ -772,7 +772,7 @@ summariseRequirement pn mod_name = do let PackageName pn_fs = pn let location = mkHomeModLocation2 fopts mod_name - (unpackFS pn_fs moduleNameSlashes mod_name) "hsig" + (unsafeEncodeUtf $ unpackFS pn_fs moduleNameSlashes mod_name) (unsafeEncodeUtf "hsig") env <- getBkpEnv src_hash <- liftIO $ getFileHash (bkp_filename env) @@ -855,12 +855,12 @@ hsModuleToModSummary home_keys pn hsc_src modname -- these filenames to figure out where the hi files go. -- A travesty! let location0 = mkHomeModLocation2 fopts modname - (unpackFS unit_fs + (unsafeEncodeUtf $ unpackFS unit_fs moduleNameSlashes modname) (case hsc_src of - HsigFile -> "hsig" - HsBootFile -> "hs-boot" - HsSrcFile -> "hs") + HsigFile -> unsafeEncodeUtf "hsig" + HsBootFile -> unsafeEncodeUtf "hs-boot" + HsSrcFile -> unsafeEncodeUtf "hs") -- DANGEROUS: bootifying can POISON the module finder cache let location = case hsc_src of HsBootFile -> addBootSuffixLocnOut location0 ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -259,7 +259,7 @@ outputForeignStubs Maybe FilePath) -- C file created outputForeignStubs logger tmpfs dflags unit_state mod location stubs = do - let stub_h = mkStubPaths (initFinderOpts dflags) (moduleName mod) location + let stub_h = unsafeDecodeUtf $ mkStubPaths (initFinderOpts dflags) (moduleName mod) location stub_c <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "c" case stubs of ===================================== compiler/GHC/Driver/Config/Finder.hs ===================================== @@ -5,30 +5,32 @@ module GHC.Driver.Config.Finder ( import GHC.Prelude +import qualified GHC.Data.Strict as Strict import GHC.Driver.DynFlags import GHC.Unit.Finder.Types import GHC.Data.FastString - +-- TODO: this must not be here, replace with 'GHC.Data.OsPath' +import GHC.Unit.Module.Location -- | Create a new 'FinderOpts' from DynFlags. initFinderOpts :: DynFlags -> FinderOpts initFinderOpts flags = FinderOpts - { finder_importPaths = importPaths flags + { finder_importPaths = fmap unsafeEncodeUtf $ importPaths flags , finder_lookupHomeInterfaces = isOneShot (ghcMode flags) , finder_bypassHiFileCheck = MkDepend == (ghcMode flags) , finder_ways = ways flags , finder_enableSuggestions = gopt Opt_HelpfulErrors flags - , finder_workingDirectory = workingDirectory flags + , finder_workingDirectory = fmap unsafeEncodeUtf $ Strict.fromLazy $ workingDirectory flags , finder_thisPackageName = mkFastString <$> thisPackageName flags , finder_hiddenModules = hiddenModules flags , finder_reexportedModules = reexportedModules flags - , finder_hieDir = hieDir flags - , finder_hieSuf = hieSuf flags - , finder_hiDir = hiDir flags - , finder_hiSuf = hiSuf_ flags - , finder_dynHiSuf = dynHiSuf_ flags - , finder_objectDir = objectDir flags - , finder_objectSuf = objectSuf_ flags - , finder_dynObjectSuf = dynObjectSuf_ flags - , finder_stubDir = stubDir flags + , finder_hieDir = fmap unsafeEncodeUtf $ Strict.fromLazy $ hieDir flags + , finder_hieSuf = unsafeEncodeUtf $ hieSuf flags + , finder_hiDir = fmap unsafeEncodeUtf $ Strict.fromLazy $ hiDir flags + , finder_hiSuf = unsafeEncodeUtf $ hiSuf_ flags + , finder_dynHiSuf = unsafeEncodeUtf $ dynHiSuf_ flags + , finder_objectDir = fmap unsafeEncodeUtf $ Strict.fromLazy $ objectDir flags + , finder_objectSuf = unsafeEncodeUtf $ objectSuf_ flags + , finder_dynObjectSuf = unsafeEncodeUtf $ dynObjectSuf_ flags + , finder_stubDir = fmap unsafeEncodeUtf $ Strict.fromLazy $ stubDir flags } ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -262,6 +262,7 @@ import qualified GHC.LanguageExtensions as LangExt import GHC.Data.FastString import GHC.Data.Bag +import qualified GHC.Data.Strict as Strict import GHC.Data.StringBuffer import qualified GHC.Data.Stream as Stream import GHC.Data.Stream (Stream) @@ -286,6 +287,7 @@ import Data.List.NonEmpty (NonEmpty ((:|))) import GHC.Unit.Module.WholeCoreBindings import GHC.Types.TypeEnv import System.IO +import System.OsPath (OsPath) import {-# SOURCE #-} GHC.Driver.Pipeline import Data.Time @@ -541,9 +543,9 @@ hscParse' mod_summary $ filter (not . isPrefixOf "<") $ map unpackFS $ srcfiles pst - srcs1 = case ml_hs_file (ms_location mod_summary) of - Just f -> filter (/= FilePath.normalise f) srcs0 - Nothing -> srcs0 + srcs1 = case ml_hs_file_ (ms_location mod_summary) of + Strict.Just f -> filter (/= FilePath.normalise (unsafeDecodeUtf f)) srcs0 + Strict.Nothing -> srcs0 -- sometimes we see source files from earlier -- preprocessing stages that cannot be found, so just @@ -964,25 +966,13 @@ loadByteCode iface mod_sum = do -- Compilers -------------------------------------------------------------- -shareIface :: NameCache -> ModIface -> IO ModIface -shareIface nc mi = do - bh <- openBinMem (1024 * 1024) - -- Todo, not quite right (See ext fields etc) - start <- tellBin @() bh - putWithUserData QuietBinIFace bh mi - seekBin bh start - res <- getWithUserData nc bh - let resiface = res { mi_src_hash = mi_src_hash mi } - forceModIface resiface - return resiface -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] -initModDetails :: HscEnv -> ModIface -> IO (ModIface, ModDetails) -initModDetails hsc_env raw_iface = do - iface <- shareIface (hsc_NC hsc_env) raw_iface - d <- fixIO $ \details' -> do +initModDetails :: HscEnv -> ModIface -> IO ModDetails +initModDetails hsc_env iface = do + fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) let !hsc_env' = hscUpdateHPT act hsc_env @@ -991,7 +981,6 @@ initModDetails hsc_env raw_iface = do -- any further typechecking. It's much more useful -- in make mode, since this HMI will go into the HPT. genModDetails hsc_env' iface - return (iface, d) -- Hydrate any WholeCoreBindings linkables into BCOs initWholeCoreBindings :: HscEnv -> ModIface -> ModDetails -> Linkable -> IO Linkable @@ -2100,12 +2089,12 @@ hscCompileCmmFile hsc_env original_filename filename output_filename = runHsc hs rawCmms return stub_c_exists where - 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", - ml_dyn_hi_file = panic "hscCompileCmmFile: no dyn obj file", - ml_hie_file = panic "hscCompileCmmFile: no hie file"} + no_loc = ModLocation{ ml_hs_file_ = Strict.Just $ unsafeEncodeUtf 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", + ml_dyn_hi_file_ = panic "hscCompileCmmFile: no dyn obj file", + ml_hie_file_ = panic "hscCompileCmmFile: no hie file"} -------------------- Stuff for new code gen --------------------- @@ -2340,12 +2329,12 @@ hscParsedDecls hsc_env decls = runInteractiveHsc hsc_env $ do {- Desugar it -} -- We use a basically null location for iNTERACTIVE - let iNTERACTIVELoc = ModLocation{ ml_hs_file = Nothing, - ml_hi_file = panic "hsDeclsWithLocation:ml_hi_file", - ml_obj_file = panic "hsDeclsWithLocation:ml_obj_file", - ml_dyn_obj_file = panic "hsDeclsWithLocation:ml_dyn_obj_file", - ml_dyn_hi_file = panic "hsDeclsWithLocation:ml_dyn_hi_file", - ml_hie_file = panic "hsDeclsWithLocation:ml_hie_file" } + let iNTERACTIVELoc = ModLocation{ ml_hs_file_ = Strict.Nothing, + ml_hi_file_ = panic "hsDeclsWithLocation:ml_hi_file", + ml_obj_file_ = panic "hsDeclsWithLocation:ml_obj_file", + ml_dyn_obj_file_ = panic "hsDeclsWithLocation:ml_dyn_obj_file", + ml_dyn_hi_file_ = panic "hsDeclsWithLocation:ml_dyn_hi_file", + ml_hie_file_ = panic "hsDeclsWithLocation:ml_hie_file" } ds_result <- hscDesugar' iNTERACTIVELoc tc_gblenv {- Simplify -} @@ -2624,12 +2613,12 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do {- Lint if necessary -} lintInteractiveExpr (text "hscCompileCoreExpr") hsc_env prepd_expr - let this_loc = ModLocation{ ml_hs_file = Nothing, - ml_hi_file = panic "hscCompileCoreExpr':ml_hi_file", - ml_obj_file = panic "hscCompileCoreExpr':ml_obj_file", - ml_dyn_obj_file = panic "hscCompileCoreExpr': ml_obj_file", - ml_dyn_hi_file = panic "hscCompileCoreExpr': ml_dyn_hi_file", - ml_hie_file = panic "hscCompileCoreExpr':ml_hie_file" } + let this_loc = ModLocation{ ml_hs_file_ = Strict.Nothing, + ml_hi_file_ = panic "hscCompileCoreExpr':ml_hi_file", + ml_obj_file_ = panic "hscCompileCoreExpr':ml_obj_file", + ml_dyn_obj_file_ = panic "hscCompileCoreExpr': ml_obj_file", + ml_dyn_hi_file_ = panic "hscCompileCoreExpr': ml_dyn_hi_file", + ml_hie_file_ = panic "hscCompileCoreExpr':ml_hie_file" } -- Ensure module uniqueness by giving it a name like "GhciNNNN". -- This uniqueness is needed by the JS linker. Without it we break the 1-1 ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -72,6 +72,7 @@ import GHC.Iface.Load ( cannotFindModule ) import GHC.IfaceToCore ( typecheckIface ) import GHC.Iface.Recomp ( RecompileRequired(..), CompileReason(..) ) +import qualified GHC.Data.Strict as Strict import GHC.Data.Bag ( listToBag ) import GHC.Data.Graph.Directed import GHC.Data.FastString @@ -336,12 +337,15 @@ warnMissingHomeModules dflags targets mod_graph = -> moduleName (ms_mod mod) == name && tuid == ms_unitid mod TargetFile target_file _ - | Just mod_file <- ml_hs_file (ms_location mod) + | Strict.Just mod_file <- ml_hs_file_ (ms_location mod) -> - augmentByWorkingDirectory dflags target_file == mod_file || + let + target_os_file = unsafeEncodeUtf target_file + in + augmentByWorkingDirectory dflags target_file == unsafeDecodeUtf mod_file || -- Don't warn on B.hs-boot if B.hs is specified (#16551) - addBootSuffix target_file == mod_file || + addBootSuffix target_os_file == mod_file || -- We can get a file target even if a module name was -- originally specified in a command line because it can @@ -1830,7 +1834,7 @@ enableCodeGenWhen logger tmpfs staticLife dynLife unit_env mod_graph = tn <- newTempName logger tmpfs (tmpDir dflags) staticLife suf let dyn_tn = tn -<.> dynsuf addFilesToClean tmpfs dynLife [dyn_tn] - return (tn, dyn_tn) + return (unsafeEncodeUtf tn, unsafeEncodeUtf dyn_tn) -- We don't want to create .o or .hi files unless we have been asked -- to by the user. But we need them, so we patch their locations in -- the ModSummary with temporary files. @@ -1839,8 +1843,8 @@ enableCodeGenWhen logger tmpfs staticLife dynLife unit_env mod_graph = -- If ``-fwrite-interface` is specified, then the .o and .hi files -- are written into `-odir` and `-hidir` respectively. #16670 if gopt Opt_WriteInterface dflags - then return ((ml_hi_file ms_location, ml_dyn_hi_file ms_location) - , (ml_obj_file ms_location, ml_dyn_obj_file ms_location)) + then return ((ml_hi_file_ ms_location, ml_dyn_hi_file_ ms_location) + , (ml_obj_file_ ms_location, ml_dyn_obj_file_ ms_location)) else (,) <$> (new_temp_file (hiSuf_ dflags) (dynHiSuf_ dflags)) <*> (new_temp_file (objectSuf_ dflags) (dynObjectSuf_ dflags)) let new_dflags = case enable_spec of @@ -1849,10 +1853,10 @@ enableCodeGenWhen logger tmpfs staticLife dynLife unit_env mod_graph = EnableByteCodeAndObject -> (gopt_set dflags Opt_ByteCodeAndObjectCode) { backend = defaultBackendOf ms} let ms' = ms { ms_location = - ms_location { ml_hi_file = hi_file - , ml_obj_file = o_file - , ml_dyn_hi_file = dyn_hi_file - , ml_dyn_obj_file = dyn_o_file } + ms_location { ml_hi_file_ = hi_file + , ml_obj_file_ = o_file + , ml_dyn_hi_file_ = dyn_hi_file + , ml_dyn_obj_file_ = dyn_o_file } , ms_hspp_opts = updOptLevel 0 $ new_dflags } -- Recursive call to catch the other cases @@ -2037,7 +2041,7 @@ summariseFile hsc_env' home_unit old_summaries src_fn mb_phase maybe_buf let fopts = initFinderOpts (hsc_dflags hsc_env) -- Make a ModLocation for this file - let location = mkHomeModLocation fopts pi_mod_name src_fn + let location = mkHomeModLocation fopts pi_mod_name (unsafeEncodeUtf src_fn) -- Tell the Finder cache where it is, so that subsequent calls -- to findModule will find it, even if it's not on any search path ===================================== compiler/GHC/Driver/MakeFile.hs ===================================== @@ -297,7 +297,7 @@ findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps = do Found loc _ -- Home package: just depend on the .hi or hi-boot file | isJust (ml_hs_file loc) || include_pkg_deps - -> return (Just (addBootSuffix_maybe is_boot (ml_hi_file loc))) + -> return (Just (unsafeDecodeUtf $ addBootSuffix_maybe is_boot (ml_hi_file_ loc))) -- Not in this package: we don't need a dependency | otherwise ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -244,9 +244,9 @@ compileOne' mHscMessage let pipeline = hscPipeline pipe_env (setDumpPrefix pipe_env plugin_hsc_env, upd_summary, status) (iface, linkable) <- runPipeline (hsc_hooks plugin_hsc_env) pipeline -- See Note [ModDetails and --make mode] - (shared_iface, details) <- initModDetails plugin_hsc_env iface - linkable' <- traverse (initWholeCoreBindings plugin_hsc_env shared_iface details) (homeMod_bytecode linkable) - return $! HomeModInfo shared_iface details (linkable { homeMod_bytecode = linkable' }) + details <- initModDetails plugin_hsc_env iface + linkable' <- traverse (initWholeCoreBindings plugin_hsc_env iface details) (homeMod_bytecode linkable) + return $! HomeModInfo iface details (linkable { homeMod_bytecode = linkable' }) where lcl_dflags = ms_hspp_opts summary location = ms_location summary ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -759,7 +759,7 @@ mkOneShotModLocation :: PipeEnv -> DynFlags -> HscSource -> ModuleName -> IO Mod mkOneShotModLocation pipe_env dflags src_flavour mod_name = do let PipeEnv{ src_basename=basename, src_suffix=suff } = pipe_env - let location1 = mkHomeModLocation2 fopts mod_name basename suff + let location1 = mkHomeModLocation2 fopts mod_name (unsafeEncodeUtf basename) (unsafeEncodeUtf suff) -- Boot-ify it if necessary let location2 @@ -771,11 +771,11 @@ mkOneShotModLocation pipe_env dflags src_flavour mod_name = do -- This can't be done in mkHomeModuleLocation because -- it only applies to the module being compiles let ohi = outputHi dflags - location3 | Just fn <- ohi = location2{ ml_hi_file = fn } + location3 | Just fn <- ohi = location2{ ml_hi_file_ = unsafeEncodeUtf fn } | otherwise = location2 let dynohi = dynOutputHi dflags - location4 | Just fn <- dynohi = location3{ ml_dyn_hi_file = fn } + location4 | Just fn <- dynohi = location3{ ml_dyn_hi_file_ = unsafeEncodeUtf fn } | otherwise = location3 -- Take -o into account if present @@ -789,10 +789,10 @@ mkOneShotModLocation pipe_env dflags src_flavour mod_name = do location5 | Just ofile <- expl_o_file , let dyn_ofile = fromMaybe (ofile -<.> dynObjectSuf_ dflags) expl_dyn_o_file , isNoLink (ghcLink dflags) - = location4 { ml_obj_file = ofile - , ml_dyn_obj_file = dyn_ofile } + = location4 { ml_obj_file_ = unsafeEncodeUtf ofile + , ml_dyn_obj_file_ = unsafeEncodeUtf dyn_ofile } | Just dyn_ofile <- expl_dyn_o_file - = location4 { ml_dyn_obj_file = dyn_ofile } + = location4 { ml_dyn_obj_file_ = unsafeEncodeUtf dyn_ofile } | otherwise = location4 return location5 where ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -338,14 +338,15 @@ initReadIfaceTyConTable :: HasCallStack => IO (ReadIfaceTable (SymbolTable Iface initReadIfaceTyConTable = do pure $ ReadIfaceTable - { getTable = getGenericSymbolTable getIfaceTyCon + { getTable = getGenericSymbolTable (\_ -> getIfaceTyCon) } initReadIfaceTypeTable :: HasCallStack => IO (ReadIfaceTable (SymbolTable IfaceType)) initReadIfaceTypeTable = do pure $ ReadIfaceTable - { getTable = getGenericSymbolTable getIfaceType + { getTable = getGenericSymbolTable (\optr bh -> IfaceSerialisedType <$> freezeBinHandle optr bh) + } ===================================== compiler/GHC/Iface/Errors.hs ===================================== @@ -55,13 +55,13 @@ cantFindInstalledErr unit_state mhome_unit profile mod_name find_result InstalledNotFound files mb_pkg | Just pkg <- mb_pkg , notHomeUnitId mhome_unit pkg - -> not_found_in_package pkg files + -> not_found_in_package pkg $ fmap unsafeDecodeUtf files | null files -> NotAModule | otherwise - -> CouldntFindInFiles files + -> CouldntFindInFiles $ fmap unsafeDecodeUtf files _ -> panic "cantFindInstalledErr" ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -69,10 +69,13 @@ import GHC.Types.HpcInfo import GHC.Types.CompleteMatch import GHC.Types.SourceText import GHC.Types.SrcLoc ( unLoc ) +import GHC.Types.Name.Cache import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Logger +import GHC.Utils.Binary +import GHC.Iface.Binary import GHC.Data.FastString import GHC.Data.Maybe @@ -147,8 +150,21 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do let unit_state = hsc_units hsc_env putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "FINAL INTERFACE" FormatText (pprModIface unit_state full_iface) + final_iface <- shareIface (hsc_NC hsc_env) full_iface + return final_iface + +shareIface :: NameCache -> ModIface -> IO ModIface +shareIface nc mi = do + bh <- openBinMem (1024 * 1024) + -- Todo, not quite right (See ext fields etc) + start <- tellBin @() bh + putWithUserData QuietBinIFace bh mi + seekBin bh start + res <- getWithUserData nc bh + let resiface = res { mi_src_hash = mi_src_hash mi } + forceModIface resiface + return resiface - return full_iface updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] updateDecl decls Nothing Nothing = decls @@ -240,6 +256,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program mkFullIface hsc_env partial_iface Nothing Nothing + mkIface_ :: HscEnv -> Module -> CoreProgram -> HscSource -> Bool -> Dependencies -> GlobalRdrEnv -> NameEnv FixItem -> Warnings GhcRn -> HpcInfo @@ -300,7 +317,7 @@ mkIface_ hsc_env trust_info = setSafeMode safe_mode annotations = map mkIfaceAnnotation anns icomplete_matches = map mkIfaceCompleteMatch complete_matches - !rdrs = maybeGlobalRdrEnv rdr_env + _ = maybeGlobalRdrEnv rdr_env ModIface { mi_module = this_mod, ===================================== compiler/GHC/Iface/Recomp/Binary.hs ===================================== @@ -16,6 +16,7 @@ import GHC.Types.Name import GHC.Utils.Panic.Plain import GHC.Iface.Type import Data.Proxy +import GHC.Utils.Outputable fingerprintBinMem :: BinHandle -> IO Fingerprint fingerprintBinMem bh = withBinBuffer bh f @@ -33,7 +34,9 @@ computeFingerprint :: (Binary a) -> IO Fingerprint computeFingerprint put_nonbinding_name a = do bh <- fmap set_user_data $ openBinMem (3*1024) -- just less than a block + pprTraceM "comput" (text "abc") put_ bh a + pprTraceM "comput" (text "cde") fingerprintBinMem bh where set_user_data bh = ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -37,6 +37,8 @@ module GHC.Iface.Syntax ( fromIfaceWarnings, fromIfaceWarningTxt, + getIfaceExpr, + -- Free Names freeNamesIfDecl, freeNamesIfRule, freeNamesIfFamInst, freeNamesIfConDecls, @@ -131,7 +133,9 @@ putIfaceTopBndr bh name = data IfaceDecl - = IfaceId { ifName :: IfaceTopBndr, + = IfaceSerialisedDecl { ifName :: IfaceTopBndr + , ifSerialisedDecl :: FullBinData } + | IfaceId { ifName :: IfaceTopBndr, ifType :: IfaceType, ifIdDetails :: IfaceIdDetails, ifIdInfo :: IfaceIdInfo @@ -615,7 +619,8 @@ fromIfaceStringLiteral (IfStringLiteral st fs) = StringLiteral st fs Nothing -} data IfaceExpr - = IfaceLcl IfLclName + = IfaceSerialisedExpr FullBinData + | IfaceLcl IfLclName | IfaceExt IfExtName | IfaceType IfaceType | IfaceCo IfaceCoercion @@ -2478,6 +2483,10 @@ instance Binary IfaceAlt where return (IfaceAlt a b c) instance Binary IfaceExpr where + + putNoStack_ bh (IfaceSerialisedExpr f) = do + deserialised <- getIfaceExpr =<< thawBinHandle f + putNoStack_ bh deserialised putNoStack_ bh (IfaceLcl aa) = do putByte bh 0 put_ bh aa @@ -2537,7 +2546,19 @@ instance Binary IfaceExpr where putNoStack_ bh (IfaceLitRubbish ConstraintLike r) = do putByte bh 15 put_ bh r + get bh = do + start <- tellBin @() bh + _ <- getIfaceExpr bh + end <- tellBin @() bh + seekBinNoExpand bh start + frozen <- IfaceSerialisedExpr <$> freezeBinHandle end bh + seekBinNoExpand bh end + return frozen + + + +getIfaceExpr bh = do h <- getByte bh case h of 0 -> do aa <- get bh @@ -2831,6 +2852,7 @@ instance NFData IfaceUnfolding where instance NFData IfaceExpr where rnf = \case + IfaceSerialisedExpr bd -> bd `seq` () IfaceLcl nm -> rnf nm IfaceExt nm -> rnf nm IfaceType ty -> rnf ty ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -97,6 +97,7 @@ import Control.DeepSeq import Data.Proxy import Control.Monad ((<$!>)) import Control.Arrow (first) +import Data.ByteString (ByteString) {- ************************************************************************ @@ -160,7 +161,8 @@ type IfaceKind = IfaceType -- Any time a 'Type' is pretty-printed, it is first converted to an 'IfaceType' -- before being printed. See Note [Pretty printing via Iface syntax] in "GHC.Types.TyThing.Ppr" data IfaceType - = IfaceFreeTyVar TyVar -- See Note [Free tyvars in IfaceType] + = IfaceSerialisedType FullBinData + | IfaceFreeTyVar TyVar -- See Note [Free tyvars in IfaceType] | IfaceTyVar IfLclName -- Type/coercion variable only, not tycon | IfaceLitTy IfaceTyLit | IfaceAppTy IfaceType IfaceAppArgs @@ -2004,7 +2006,7 @@ putIfaceTyCon bh (IfaceTyCon n i) = put_ bh n >> put_ bh i getIfaceTyCon :: HasCallStack => BinHandle -> IO IfaceTyCon getIfaceTyCon bh = do n <- get bh - i <- get bh + !i <- get bh return (IfaceTyCon n i) instance Binary IfaceTyConSort where @@ -2128,6 +2130,11 @@ instance Binary IfaceType where tbl -> getEntry tbl bh +putIfaceType bh (IfaceSerialisedType fb) = do -- putFullBinData bh fb + deserialised <- getIfaceType =<< thawBinHandle fb + putIfaceType bh deserialised + + putIfaceType _ (IfaceFreeTyVar tv) = pprPanic "Can't serialise IfaceFreeTyVar" (ppr tv) @@ -2378,6 +2385,7 @@ instance Binary (DefMethSpec IfaceType) where instance NFData IfaceType where rnf = \case + IfaceSerialisedType bh -> bh `seq` () IfaceFreeTyVar f1 -> f1 `seq` () IfaceTyVar f1 -> rnf f1 IfaceLitTy f1 -> rnf f1 ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -131,6 +131,7 @@ import Data.Foldable import GHC.Builtin.Names (ioTyConName, rOOT_MAIN) import GHC.Iface.Errors.Types import Language.Haskell.Syntax.Extension (NoExtField (NoExtField)) +import GHC.Utils.Binary {- This module takes @@ -1384,6 +1385,12 @@ loop. See #19744. tcIfaceType :: IfaceType -> IfL Type tcIfaceType = go where + go (IfaceSerialisedType bs) = do + pprTraceM "thawing" (text @SDoc "abc") + deserialised <- liftIO (getIfaceType =<< thawBinHandle bs) + go deserialised + + go (IfaceTyVar n) = TyVarTy <$> tcIfaceTyVar n go (IfaceFreeTyVar n) = pprPanic "tcIfaceType:IfaceFreeTyVar" (ppr n) go (IfaceLitTy l) = LitTy <$> tcIfaceTyLit l @@ -1502,6 +1509,10 @@ tcIfaceUnivCoProv (IfacePluginProv str) = return $ PluginProv str -} tcIfaceExpr :: IfaceExpr -> IfL CoreExpr +tcIfaceExpr (IfaceSerialisedExpr fbh) = do + pprTraceM "thawing" (text @SDoc "e") + deserialised <- liftIO (getIfaceExpr =<< thawBinHandle fbh) + tcIfaceExpr deserialised tcIfaceExpr (IfaceType ty) = Type <$> tcIfaceType ty ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -342,7 +342,7 @@ data IfLclEnv -- Whether or not the IfaceDecl came from a boot -- file or not; we'll use this to choose between -- NoUnfolding and BootUnfolding - if_boot :: IsBootInterface, + if_boot :: !IsBootInterface, -- The field is used only for error reporting -- if (say) there's a Lint error in it ===================================== compiler/GHC/Unit/Finder.hs ===================================== @@ -42,6 +42,8 @@ import GHC.Platform.Ways import GHC.Builtin.Names ( gHC_PRIM ) +import qualified GHC.Data.Strict as Strict + import GHC.Unit.Env import GHC.Unit.Types import GHC.Unit.Module @@ -49,7 +51,6 @@ import GHC.Unit.Home import GHC.Unit.State import GHC.Unit.Finder.Types -import GHC.Data.Maybe ( expectJust ) import qualified GHC.Data.ShortText as ST import GHC.Utils.Misc @@ -61,8 +62,7 @@ import GHC.Types.PkgQual import GHC.Fingerprint import Data.IORef -import System.Directory -import System.FilePath +import System.Directory.OsPath import Control.Monad import Data.Time import qualified Data.Map as M @@ -70,9 +70,11 @@ import GHC.Driver.Env ( hsc_home_unit_maybe, HscEnv(hsc_FC, hsc_dflags, hsc_unit_env) ) import GHC.Driver.Config.Finder import qualified Data.Set as Set +import System.OsPath (OsPath, (), (<.>)) +import qualified System.OsPath as OsPath -type FileExt = String -- Filename extension -type BaseName = String -- Basename of file +type FileExt = OsPath -- Filename extension +type BaseName = OsPath -- Basename of file -- ----------------------------------------------------------------------------- -- The Finder @@ -286,7 +288,7 @@ findLookupResult fc fopts r = case r of -- implicit locations from the instances InstalledFound loc _ -> return (Found loc m) InstalledNoPackage _ -> return (NoPackage (moduleUnit m)) - InstalledNotFound fp _ -> return (NotFound{ fr_paths = fp, fr_pkg = Just (moduleUnit m) + InstalledNotFound fp _ -> return (NotFound{ fr_paths = fmap unsafeDecodeUtf fp, fr_pkg = Just (moduleUnit m) , fr_pkgs_hidden = [] , fr_mods_hidden = [] , fr_unusables = [] @@ -357,7 +359,7 @@ findHomeModule fc fopts home_unit mod_name = do InstalledFound loc _ -> Found loc (mkHomeModule home_unit mod_name) InstalledNoPackage _ -> NoPackage uid -- impossible InstalledNotFound fps _ -> NotFound { - fr_paths = fps, + fr_paths = fmap unsafeDecodeUtf fps, fr_pkg = Just uid, fr_mods_hidden = [], fr_pkgs_hidden = [], @@ -382,7 +384,7 @@ findHomePackageModule fc fopts home_unit mod_name = do InstalledFound loc _ -> Found loc (mkModule uid mod_name) InstalledNoPackage _ -> NoPackage uid -- impossible InstalledNotFound fps _ -> NotFound { - fr_paths = fps, + fr_paths = fmap unsafeDecodeUtf fps, fr_pkg = Just uid, fr_mods_hidden = [], fr_pkgs_hidden = [], @@ -413,22 +415,22 @@ findInstalledHomeModule fc fopts home_unit mod_name = do let maybe_working_dir = finder_workingDirectory fopts home_path = case maybe_working_dir of - Nothing -> finder_importPaths fopts - Just fp -> augmentImports fp (finder_importPaths fopts) + Strict.Nothing -> finder_importPaths fopts + Strict.Just fp -> augmentImports fp (finder_importPaths fopts) hi_dir_path = case finder_hiDir fopts of - Just hiDir -> case maybe_working_dir of - Nothing -> [hiDir] - Just fp -> [fp hiDir] - Nothing -> home_path + Strict.Just hiDir -> case maybe_working_dir of + Strict.Nothing -> [hiDir] + Strict.Just fp -> [fp hiDir] + Strict.Nothing -> home_path hisuf = finder_hiSuf fopts mod = mkModule home_unit mod_name source_exts = - [ ("hs", mkHomeModLocationSearched fopts mod_name "hs") - , ("lhs", mkHomeModLocationSearched fopts mod_name "lhs") - , ("hsig", mkHomeModLocationSearched fopts mod_name "hsig") - , ("lhsig", mkHomeModLocationSearched fopts mod_name "lhsig") + [ (unsafeEncodeUtf "hs", mkHomeModLocationSearched fopts mod_name $ unsafeEncodeUtf "hs") + , (unsafeEncodeUtf "lhs", mkHomeModLocationSearched fopts mod_name $ unsafeEncodeUtf "lhs") + , (unsafeEncodeUtf "hsig", mkHomeModLocationSearched fopts mod_name $ unsafeEncodeUtf "hsig") + , (unsafeEncodeUtf "lhsig", mkHomeModLocationSearched fopts mod_name $ unsafeEncodeUtf "lhsig") ] -- we use mkHomeModHiOnlyLocation instead of mkHiOnlyModLocation so that @@ -453,9 +455,9 @@ findInstalledHomeModule fc fopts home_unit mod_name = do else searchPathExts search_dirs mod exts -- | Prepend the working directory to the search path. -augmentImports :: FilePath -> [FilePath] -> [FilePath] +augmentImports :: OsPath -> [OsPath] -> [OsPath] augmentImports _work_dir [] = [] -augmentImports work_dir (fp:fps) | isAbsolute fp = fp : augmentImports work_dir fps +augmentImports work_dir (fp:fps) | OsPath.isAbsolute fp = fp : augmentImports work_dir fps | otherwise = (work_dir fp) : augmentImports work_dir fps -- | Search for a module in external packages only. @@ -488,14 +490,14 @@ findPackageModule_ fc fopts mod pkg_conf = do tag = waysBuildTag (finder_ways fopts) -- hi-suffix for packages depends on the build tag. - package_hisuf | null tag = "hi" - | otherwise = tag ++ "_hi" + package_hisuf | null tag = unsafeEncodeUtf $ "hi" + | otherwise = unsafeEncodeUtf $ tag ++ "_hi" - package_dynhisuf = waysBuildTag (addWay WayDyn (finder_ways fopts)) ++ "_hi" + package_dynhisuf = unsafeEncodeUtf $ waysBuildTag (addWay WayDyn (finder_ways fopts)) ++ "_hi" mk_hi_loc = mkHiOnlyModLocation fopts package_hisuf package_dynhisuf - import_dirs = map ST.unpack $ unitImportDirs pkg_conf + import_dirs = map (unsafeEncodeUtf . ST.unpack) $ unitImportDirs pkg_conf -- we never look for a .hi-boot file in an external package; -- .hi-boot files only make sense for the home package. in @@ -503,7 +505,7 @@ findPackageModule_ fc fopts mod pkg_conf = do [one] | finder_bypassHiFileCheck fopts -> -- there's only one place that this .hi file can be, so -- don't bother looking for it. - let basename = moduleNameSlashes (moduleName mod) + let basename = unsafeEncodeUtf $ moduleNameSlashes (moduleName mod) loc = mk_hi_loc one basename in return $ InstalledFound loc mod _otherwise -> @@ -512,24 +514,24 @@ findPackageModule_ fc fopts mod pkg_conf = do -- ----------------------------------------------------------------------------- -- General path searching -searchPathExts :: [FilePath] -- paths to search +searchPathExts :: [OsPath] -- paths to search -> InstalledModule -- module name -> [ ( FileExt, -- suffix - FilePath -> BaseName -> ModLocation -- action + OsPath -> BaseName -> ModLocation -- action ) ] -> IO InstalledFindResult searchPathExts paths mod exts = search to_search where - basename = moduleNameSlashes (moduleName mod) + basename = unsafeEncodeUtf $ moduleNameSlashes (moduleName mod) - to_search :: [(FilePath, ModLocation)] + to_search :: [(OsPath, ModLocation)] to_search = [ (file, fn path basename) | path <- paths, (ext,fn) <- exts, - let base | path == "." = basename + let base | path == unsafeEncodeUtf "." = basename | otherwise = path basename file = base <.> ext ] @@ -543,7 +545,7 @@ searchPathExts paths mod exts = search to_search else search rest mkHomeModLocationSearched :: FinderOpts -> ModuleName -> FileExt - -> FilePath -> BaseName -> ModLocation + -> OsPath -> BaseName -> ModLocation mkHomeModLocationSearched fopts mod suff path basename = mkHomeModLocation2 fopts mod (path basename) suff @@ -581,18 +583,18 @@ mkHomeModLocationSearched fopts mod suff path basename = -- ext -- The filename extension of the source file (usually "hs" or "lhs"). -mkHomeModLocation :: FinderOpts -> ModuleName -> FilePath -> ModLocation +mkHomeModLocation :: FinderOpts -> ModuleName -> OsPath -> ModLocation mkHomeModLocation dflags mod src_filename = - let (basename,extension) = splitExtension src_filename + let (basename,extension) = OsPath.splitExtension src_filename in mkHomeModLocation2 dflags mod basename extension mkHomeModLocation2 :: FinderOpts -> ModuleName - -> FilePath -- Of source module, without suffix - -> String -- Suffix + -> OsPath -- Of source module, without suffix + -> OsPath -- Suffix -> ModLocation mkHomeModLocation2 fopts mod src_basename ext = - let mod_basename = moduleNameSlashes mod + let mod_basename = unsafeEncodeUtf $ moduleNameSlashes mod obj_fn = mkObjPath fopts src_basename mod_basename dyn_obj_fn = mkDynObjPath fopts src_basename mod_basename @@ -600,72 +602,72 @@ mkHomeModLocation2 fopts mod src_basename ext = dyn_hi_fn = mkDynHiPath fopts src_basename mod_basename hie_fn = mkHiePath fopts src_basename mod_basename - in (ModLocation{ ml_hs_file = Just (src_basename <.> ext), - ml_hi_file = hi_fn, - ml_dyn_hi_file = dyn_hi_fn, - ml_obj_file = obj_fn, - ml_dyn_obj_file = dyn_obj_fn, - ml_hie_file = hie_fn }) + in (ModLocation{ ml_hs_file_ = Strict.Just (src_basename <.> ext), + ml_hi_file_ = hi_fn, + ml_dyn_hi_file_ = dyn_hi_fn, + ml_obj_file_ = obj_fn, + ml_dyn_obj_file_ = dyn_obj_fn, + ml_hie_file_ = hie_fn }) mkHomeModHiOnlyLocation :: FinderOpts -> ModuleName - -> FilePath + -> OsPath -> BaseName -> ModLocation mkHomeModHiOnlyLocation fopts mod path basename = - let loc = mkHomeModLocation2 fopts mod (path basename) "" - in loc { ml_hs_file = Nothing } + let loc = mkHomeModLocation2 fopts mod (path basename) mempty + in loc { ml_hs_file_ = Strict.Nothing } -- This function is used to make a ModLocation for a package module. Hence why -- we explicitly pass in the interface file suffixes. -mkHiOnlyModLocation :: FinderOpts -> Suffix -> Suffix -> FilePath -> String +mkHiOnlyModLocation :: FinderOpts -> OsPath -> OsPath -> OsPath -> OsPath -> ModLocation mkHiOnlyModLocation fopts hisuf dynhisuf path basename = let full_basename = path basename obj_fn = mkObjPath fopts full_basename basename dyn_obj_fn = mkDynObjPath fopts full_basename basename hie_fn = mkHiePath fopts full_basename basename - in ModLocation{ ml_hs_file = Nothing, - ml_hi_file = full_basename <.> hisuf, + in ModLocation{ ml_hs_file_ = Strict.Nothing, + ml_hi_file_ = full_basename <.> hisuf, -- Remove the .hi-boot suffix from -- hi_file, if it had one. We always -- want the name of the real .hi file -- in the ml_hi_file field. - ml_dyn_obj_file = dyn_obj_fn, + ml_dyn_obj_file_ = dyn_obj_fn, -- MP: TODO - ml_dyn_hi_file = full_basename <.> dynhisuf, - ml_obj_file = obj_fn, - ml_hie_file = hie_fn + ml_dyn_hi_file_ = full_basename <.> dynhisuf, + ml_obj_file_ = obj_fn, + ml_hie_file_ = hie_fn } -- | Constructs the filename of a .o file for a given source file. -- Does /not/ check whether the .o file exists mkObjPath :: FinderOpts - -> FilePath -- the filename of the source file, minus the extension - -> String -- the module name with dots replaced by slashes - -> FilePath -mkObjPath fopts basename mod_basename = obj_basename <.> osuf + -> OsPath -- the filename of the source file, minus the extension + -> OsPath -- the module name with dots replaced by slashes + -> OsPath +mkObjPath fopts basename mod_basename = obj_basename OsPath.<.> osuf where odir = finder_objectDir fopts osuf = finder_objectSuf fopts - obj_basename | Just dir <- odir = dir mod_basename + obj_basename | Strict.Just dir <- odir = dir OsPath. mod_basename | otherwise = basename -- | Constructs the filename of a .dyn_o file for a given source file. -- Does /not/ check whether the .dyn_o file exists mkDynObjPath :: FinderOpts - -> FilePath -- the filename of the source file, minus the extension - -> String -- the module name with dots replaced by slashes - -> FilePath + -> OsPath -- the filename of the source file, minus the extension + -> OsPath -- the module name with dots replaced by slashes + -> OsPath mkDynObjPath fopts basename mod_basename = obj_basename <.> dynosuf where odir = finder_objectDir fopts dynosuf = finder_dynObjectSuf fopts - obj_basename | Just dir <- odir = dir mod_basename + obj_basename | Strict.Just dir <- odir = dir mod_basename | otherwise = basename @@ -673,45 +675,45 @@ mkDynObjPath fopts basename mod_basename = obj_basename <.> dynosuf -- Does /not/ check whether the .hi file exists mkHiPath :: FinderOpts - -> FilePath -- the filename of the source file, minus the extension - -> String -- the module name with dots replaced by slashes - -> FilePath + -> OsPath -- the filename of the source file, minus the extension + -> OsPath -- the module name with dots replaced by slashes + -> OsPath mkHiPath fopts basename mod_basename = hi_basename <.> hisuf where hidir = finder_hiDir fopts hisuf = finder_hiSuf fopts - hi_basename | Just dir <- hidir = dir mod_basename + hi_basename | Strict.Just dir <- hidir = dir mod_basename | otherwise = basename -- | Constructs the filename of a .dyn_hi file for a given source file. -- Does /not/ check whether the .dyn_hi file exists mkDynHiPath :: FinderOpts - -> FilePath -- the filename of the source file, minus the extension - -> String -- the module name with dots replaced by slashes - -> FilePath + -> OsPath -- the filename of the source file, minus the extension + -> OsPath -- the module name with dots replaced by slashes + -> OsPath mkDynHiPath fopts basename mod_basename = hi_basename <.> dynhisuf where hidir = finder_hiDir fopts dynhisuf = finder_dynHiSuf fopts - hi_basename | Just dir <- hidir = dir mod_basename + hi_basename | Strict.Just dir <- hidir = dir mod_basename | otherwise = basename -- | Constructs the filename of a .hie file for a given source file. -- Does /not/ check whether the .hie file exists mkHiePath :: FinderOpts - -> FilePath -- the filename of the source file, minus the extension - -> String -- the module name with dots replaced by slashes - -> FilePath + -> OsPath -- the filename of the source file, minus the extension + -> OsPath -- the module name with dots replaced by slashes + -> OsPath mkHiePath fopts basename mod_basename = hie_basename <.> hiesuf where hiedir = finder_hieDir fopts hiesuf = finder_hieSuf fopts - hie_basename | Just dir <- hiedir = dir mod_basename + hie_basename | Strict.Just dir <- hiedir = dir mod_basename | otherwise = basename @@ -726,23 +728,23 @@ mkStubPaths :: FinderOpts -> ModuleName -> ModLocation - -> FilePath + -> OsPath mkStubPaths fopts mod location = let stubdir = finder_stubDir fopts - mod_basename = moduleNameSlashes mod - src_basename = dropExtension $ expectJust "mkStubPaths" - (ml_hs_file location) + mod_basename = unsafeEncodeUtf $ moduleNameSlashes mod + src_basename = OsPath.dropExtension $ Strict.expectJust "mkStubPaths" + (ml_hs_file_ location) stub_basename0 - | Just dir <- stubdir = dir mod_basename + | Strict.Just dir <- stubdir = dir mod_basename | otherwise = src_basename - stub_basename = stub_basename0 ++ "_stub" + stub_basename = stub_basename0 `mappend` unsafeEncodeUtf "_stub" in - stub_basename <.> "h" + stub_basename <.> unsafeEncodeUtf "h" -- ----------------------------------------------------------------------------- -- findLinkable isn't related to the other stuff in here, ===================================== compiler/GHC/Unit/Finder/Types.hs ===================================== @@ -9,6 +9,7 @@ where import GHC.Prelude import GHC.Unit +import qualified GHC.Data.Strict as Strict import qualified Data.Map as M import GHC.Fingerprint import GHC.Platform.Ways @@ -16,6 +17,7 @@ import GHC.Platform.Ways import Data.IORef import GHC.Data.FastString import qualified Data.Set as Set +import System.OsPath (OsPath) -- | The 'FinderCache' maps modules to the result of -- searching for that module. It records the results of searching for @@ -31,7 +33,7 @@ data FinderCache = FinderCache { fcModuleCache :: (IORef FinderCacheState) data InstalledFindResult = InstalledFound ModLocation InstalledModule | InstalledNoPackage UnitId - | InstalledNotFound [FilePath] (Maybe UnitId) + | InstalledNotFound [OsPath] (Maybe UnitId) -- | The result of searching for an imported module. -- @@ -70,7 +72,7 @@ data FindResult -- -- Should be taken from 'DynFlags' via 'initFinderOpts'. data FinderOpts = FinderOpts - { finder_importPaths :: [FilePath] + { finder_importPaths :: [OsPath] -- ^ Where are we allowed to look for Modules and Source files , finder_lookupHomeInterfaces :: Bool -- ^ When looking up a home module: @@ -88,17 +90,17 @@ data FinderOpts = FinderOpts , finder_enableSuggestions :: Bool -- ^ If we encounter unknown modules, should we suggest modules -- that have a similar name. - , finder_workingDirectory :: Maybe FilePath + , finder_workingDirectory :: Strict.Maybe OsPath , finder_thisPackageName :: Maybe FastString , finder_hiddenModules :: Set.Set ModuleName , finder_reexportedModules :: Set.Set ModuleName - , finder_hieDir :: Maybe FilePath - , finder_hieSuf :: String - , finder_hiDir :: Maybe FilePath - , finder_hiSuf :: String - , finder_dynHiSuf :: String - , finder_objectDir :: Maybe FilePath - , finder_objectSuf :: String - , finder_dynObjectSuf :: String - , finder_stubDir :: Maybe FilePath + , finder_hieDir :: Strict.Maybe OsPath + , finder_hieSuf :: OsPath + , finder_hiDir :: Strict.Maybe OsPath + , finder_hiSuf :: OsPath + , finder_dynHiSuf :: OsPath + , finder_objectDir :: Strict.Maybe OsPath + , finder_objectSuf :: OsPath + , finder_dynObjectSuf :: OsPath + , finder_stubDir :: Strict.Maybe OsPath } deriving Show ===================================== compiler/GHC/Unit/Module/Location.hs ===================================== @@ -7,12 +7,23 @@ module GHC.Unit.Module.Location , addBootSuffixLocn , addBootSuffixLocnOut , removeBootSuffix + , ml_hs_file + , ml_hi_file + , ml_dyn_hi_file + , ml_obj_file + , ml_dyn_obj_file + , ml_hie_file + , unsafeEncodeUtf + , unsafeDecodeUtf ) where +import Data.Either import GHC.Prelude import GHC.Unit.Types import GHC.Utils.Outputable +import qualified GHC.Data.Strict as Strict +import System.OsPath -- | Module Location -- @@ -39,30 +50,30 @@ import GHC.Utils.Outputable data ModLocation = ModLocation { - ml_hs_file :: Maybe FilePath, + ml_hs_file_ :: Strict.Maybe OsPath, -- ^ The source file, if we have one. Package modules -- probably don't have source files. - ml_hi_file :: FilePath, + ml_hi_file_ :: !OsPath, -- ^ Where the .hi file is, whether or not it exists -- yet. Always of form foo.hi, even if there is an -- hi-boot file (we add the -boot suffix later) - ml_dyn_hi_file :: FilePath, + ml_dyn_hi_file_ :: !OsPath, -- ^ Where the .dyn_hi file is, whether or not it exists -- yet. - ml_obj_file :: FilePath, + ml_obj_file_ :: !OsPath, -- ^ Where the .o file is, whether or not it exists yet. -- (might not exist either because the module hasn't -- been compiled yet, or because it is part of a -- unit with a .a file) - ml_dyn_obj_file :: FilePath, + ml_dyn_obj_file_ :: !OsPath, -- ^ Where the .dy file is, whether or not it exists -- yet. - ml_hie_file :: FilePath + ml_hie_file_ :: !OsPath -- ^ Where the .hie file is, whether or not it exists -- yet. } deriving Show @@ -70,9 +81,15 @@ data ModLocation instance Outputable ModLocation where ppr = text . show +unsafeEncodeUtf :: FilePath -> OsPath +unsafeEncodeUtf = fromRight (error "unsafeEncodeUtf: Internal error") . encodeUtf + +unsafeDecodeUtf :: OsPath -> FilePath +unsafeDecodeUtf = fromRight (error "unsafeEncodeUtf: Internal error") . decodeUtf + -- | Add the @-boot@ suffix to .hs, .hi and .o files -addBootSuffix :: FilePath -> FilePath -addBootSuffix path = path ++ "-boot" +addBootSuffix :: OsPath -> OsPath +addBootSuffix path = path `mappend` unsafeEncodeUtf "-boot" -- | Remove the @-boot@ suffix to .hs, .hi and .o files removeBootSuffix :: FilePath -> FilePath @@ -82,7 +99,7 @@ removeBootSuffix [] = error "removeBootSuffix: no -boot suffix" -- | Add the @-boot@ suffix if the @Bool@ argument is @True@ -addBootSuffix_maybe :: IsBootInterface -> FilePath -> FilePath +addBootSuffix_maybe :: IsBootInterface -> OsPath -> OsPath addBootSuffix_maybe is_boot path = case is_boot of IsBoot -> addBootSuffix path NotBoot -> path @@ -95,22 +112,38 @@ addBootSuffixLocn_maybe is_boot locn = case is_boot of -- | Add the @-boot@ suffix to all file paths associated with the module addBootSuffixLocn :: ModLocation -> ModLocation addBootSuffixLocn locn - = locn { ml_hs_file = fmap addBootSuffix (ml_hs_file locn) - , ml_hi_file = addBootSuffix (ml_hi_file locn) - , ml_dyn_hi_file = addBootSuffix (ml_dyn_hi_file locn) - , ml_obj_file = addBootSuffix (ml_obj_file locn) - , ml_dyn_obj_file = addBootSuffix (ml_dyn_obj_file locn) - , ml_hie_file = addBootSuffix (ml_hie_file locn) } + = locn { ml_hs_file_ = fmap addBootSuffix (ml_hs_file_ locn) + , ml_hi_file_ = addBootSuffix (ml_hi_file_ locn) + , ml_dyn_hi_file_ = addBootSuffix (ml_dyn_hi_file_ locn) + , ml_obj_file_ = addBootSuffix (ml_obj_file_ locn) + , ml_dyn_obj_file_ = addBootSuffix (ml_dyn_obj_file_ locn) + , ml_hie_file_ = addBootSuffix (ml_hie_file_ locn) } -- | Add the @-boot@ suffix to all output file paths associated with the -- module, not including the input file itself addBootSuffixLocnOut :: ModLocation -> ModLocation addBootSuffixLocnOut locn - = locn { ml_hi_file = addBootSuffix (ml_hi_file locn) - , ml_dyn_hi_file = addBootSuffix (ml_dyn_hi_file locn) - , ml_obj_file = addBootSuffix (ml_obj_file locn) - , ml_dyn_obj_file = addBootSuffix (ml_dyn_obj_file locn) - , ml_hie_file = addBootSuffix (ml_hie_file locn) + = locn { ml_hi_file_ = addBootSuffix (ml_hi_file_ locn) + , ml_dyn_hi_file_ = addBootSuffix (ml_dyn_hi_file_ locn) + , ml_obj_file_ = addBootSuffix (ml_obj_file_ locn) + , ml_dyn_obj_file_ = addBootSuffix (ml_dyn_obj_file_ locn) + , ml_hie_file_ = addBootSuffix (ml_hie_file_ locn) } +ml_hs_file :: ModLocation -> Maybe FilePath +ml_hs_file = fmap unsafeDecodeUtf . Strict.toLazy . ml_hs_file_ + +ml_hi_file :: ModLocation -> FilePath +ml_hi_file = unsafeDecodeUtf . ml_hi_file_ + +ml_dyn_hi_file :: ModLocation -> FilePath +ml_dyn_hi_file = unsafeDecodeUtf . ml_dyn_hi_file_ + +ml_obj_file :: ModLocation -> FilePath +ml_obj_file = unsafeDecodeUtf . ml_obj_file_ + +ml_dyn_obj_file :: ModLocation -> FilePath +ml_dyn_obj_file = unsafeDecodeUtf . ml_dyn_obj_file_ +ml_hie_file :: ModLocation -> FilePath +ml_hie_file = unsafeDecodeUtf . ml_hie_file_ ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -414,7 +414,8 @@ instance Binary ModIface where lazyPut bh warns lazyPut bh anns put_ bh decls - put_ bh extra_decls + lazyPutMaybe bh extra_decls +-- put_ bh extra_decls put_ bh insts put_ bh fam_insts lazyPut bh rules @@ -446,7 +447,8 @@ instance Binary ModIface where warns <- {-# SCC "bin_warns" #-} lazyGet bh anns <- {-# SCC "bin_anns" #-} lazyGet bh decls <- {-# SCC "bin_tycldecls" #-} get bh - extra_decls <- get bh + extra_decls <- lazyGetMaybe bh +-- extra_decls <- get bh insts <- {-# SCC "bin_insts" #-} get bh fam_insts <- {-# SCC "bin_fam_insts" #-} get bh rules <- {-# SCC "bin_rules" #-} lazyGet bh ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -31,7 +31,7 @@ module GHC.Utils.Binary openBinMem, -- closeBin, - seekBin, + seekBin, seekBinNoExpand, tellBin, castBin, withBinBuffer, @@ -86,7 +86,9 @@ module GHC.Utils.Binary addDecoder, -- * Newtype wrappers - BinSpan(..), BinSrcSpan(..), BinLocated(..) + BinSpan(..), BinSrcSpan(..), BinLocated(..), + + FullBinData, freezeBinHandle, thawBinHandle, putFullBinData, ) where import GHC.Prelude @@ -182,6 +184,42 @@ dataHandle (BinData size bin) = do handleData :: BinHandle -> IO BinData handleData (BinMem _ ixr _ binr _) = BinData <$> readFastMutInt ixr <*> readIORef binr +--- +-- FullBinData +-- -- Frozen BinHandle + +data FullBinData = FullBinData UserData {-# UNPACK #-} !Int -- start offset + {-# UNPACK #-} !Int -- end offset + {-# UNPACK #-} !Int -- total buffer size + {-# UNPACK #-} !BinArray + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData a b c d e) == (FullBinData a1 b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> BinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (BinMem user_data ixr sz binr _) = + FullBinData user_data <$> readFastMutInt ixr <*> pure len <*> readFastMutInt sz <*> readIORef binr + +thawBinHandle :: FullBinData -> IO BinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + szr <- newFastMutInt sz + binr <- newIORef ba + bp <- initBinProf + return $ BinMem user_data ixr szr binr bp + + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -251,6 +289,7 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i @@ -1089,7 +1128,7 @@ forwardGet bh get_A = do lazyPut :: Binary a => BinHandle -> a -> IO () lazyPut = lazyPut' putNoStack_ lazyGet :: Binary a => BinHandle -> IO a -lazyGet = lazyGet' Nothing get +lazyGet = lazyGet' Nothing (\_ -> get) lazyPut' :: HasCallStack => (BinHandle -> a -> IO ()) -> BinHandle -> a -> IO () lazyPut' f bh a = do @@ -1101,7 +1140,7 @@ lazyPut' f bh a = do putAt bh pre_a q -- fill in slot before a with ptr to q seekBin bh q -- finally carry on writing at q -lazyGet' :: HasCallStack => Maybe (IORef BinHandle) -> (BinHandle -> IO a) -> BinHandle -> IO a +lazyGet' :: HasCallStack => Maybe (IORef BinHandle) -> (Bin () -> BinHandle -> IO a) -> BinHandle -> IO a lazyGet' mbh f bh = do p <- get @(Bin ()) bh -- a BinPtr p_a <- tellBin bh @@ -1112,7 +1151,7 @@ lazyGet' mbh f bh = do off_r <- newFastMutInt 0 let bh' = inner_bh { _off_r = off_r } seekBin bh' p_a - f bh' + f p bh' seekBin bh p -- skip over the object for now return a @@ -1239,7 +1278,7 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop 0) -getGenericSymbolTable :: forall a. (BinHandle -> IO a) -> IORef BinHandle -> BinHandle -> IO (SymbolTable a) +getGenericSymbolTable :: forall a. (Bin () -> BinHandle -> IO a) -> IORef BinHandle -> BinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bhRef bh = do sz <- forwardGet bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) ===================================== ghc/GHCi/UI.hs ===================================== @@ -171,6 +171,7 @@ import GHC.TopHandler ( topHandler ) import GHCi.Leak import qualified GHC.Unit.Module.Graph as GHC +import GHC.Profiling.Eras ----------------------------------------------------------------------------- @@ -2159,6 +2160,7 @@ reloadModuleDefer = wrapDeferTypeErrors . reloadModule -- sessions. doLoadAndCollectInfo :: GhciMonad m => LoadType -> LoadHowMuch -> m SuccessFlag doLoadAndCollectInfo load_type howmuch = do + liftIO $ incrementUserEra 1 doCollectInfo <- isOptionSet CollectInfo doLoad load_type howmuch >>= \case ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -45,7 +45,8 @@ Executable ghc containers >= 0.5 && < 0.8, transformers >= 0.5 && < 0.7, ghc-boot == @ProjectVersionMunged@, - ghc == @ProjectVersionMunged@ + ghc == @ProjectVersionMunged@, + ghc-experimental if flag(ghc-debug) build-depends: ghc-debug-stub ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -100,7 +100,7 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter" , notStage0 `cabalFlag` "ghc-debug" - , stage0 `cabalFlag` "ghc-debug" +-- , stage0 `cabalFlag` "ghc-debug" , ifM stage0 -- We build a threaded stage 1 if the bootstrapping compiler -- supports it. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b8cbe10266f7ea9b25a544175ff4bae9afcc29d...9826914441cbc41108903a6d230e8e58a339e5fd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b8cbe10266f7ea9b25a544175ff4bae9afcc29d...9826914441cbc41108903a6d230e8e58a339e5fd You're receiving 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 Mar 23 15:58:44 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 23 Mar 2024 11:58:44 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Force inner_bh outside of unsafeInterleaveIO Message-ID: <65fefc349e13_ba7dfdb1cd001269c9@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: bc2c4a52 by Matthew Pickering at 2024-03-23T15:58:14+00:00 Force inner_bh outside of unsafeInterleaveIO This reduces the size of the FUN closure from 96 to 56 bytes. - - - - - 1 changed file: - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -1144,15 +1144,17 @@ lazyGet' :: HasCallStack => Maybe (IORef BinHandle) -> (Bin () -> BinHandle -> I lazyGet' mbh f bh = do p <- get @(Bin ()) bh -- a BinPtr p_a <- tellBin bh + -- Do this before to avoid retaining reference to old BH inside the unsafeInterleaveIO. + let !get_inner_bh = maybe (pure bh) readIORef mbh a <- unsafeInterleaveIO $ do -- NB: Use a fresh off_r variable in the child thread, for thread -- safety. - inner_bh <- maybe (pure bh) readIORef mbh + inner_bh <- get_inner_bh off_r <- newFastMutInt 0 let bh' = inner_bh { _off_r = off_r } - seekBin bh' p_a + seekBinNoExpand bh' p_a f p bh' - seekBin bh p -- skip over the object for now + seekBinNoExpand bh p -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1282,6 +1284,8 @@ getGenericSymbolTable :: forall a. (Bin () -> BinHandle -> IO a) -> IORef BinHan getGenericSymbolTable deserialiser bhRef bh = do sz <- forwardGet bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) + -- Using lazyPut/lazyGet is quite space inefficient as each usage will allocate a large closure + -- (6 arguments-ish). forM_ [0..(sz-1)] $ \i -> do f <- lazyGet' (Just bhRef) deserialiser bh writeArray mut_arr i f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bc2c4a5231550fed6f14fb3075a50b20a61366a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bc2c4a5231550fed6f14fb3075a50b20a61366a5 You're receiving 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 Mar 23 16:00:19 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 23 Mar 2024 12:00:19 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Force inner_bh outside of unsafeInterleaveIO Message-ID: <65fefc9373f1_ba7dfdb818b812718e@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: 4ef9f2b1 by Matthew Pickering at 2024-03-23T15:59:39+00:00 Force inner_bh outside of unsafeInterleaveIO This reduces the size of the FUN closure from 96 to 56 bytes. Which saves ~12mb live bytes overall. - - - - - 1 changed file: - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -1144,15 +1144,17 @@ lazyGet' :: HasCallStack => Maybe (IORef BinHandle) -> (Bin () -> BinHandle -> I lazyGet' mbh f bh = do p <- get @(Bin ()) bh -- a BinPtr p_a <- tellBin bh + -- Do this before to avoid retaining reference to old BH inside the unsafeInterleaveIO. + let !get_inner_bh = maybe (pure bh) readIORef mbh a <- unsafeInterleaveIO $ do -- NB: Use a fresh off_r variable in the child thread, for thread -- safety. - inner_bh <- maybe (pure bh) readIORef mbh + inner_bh <- get_inner_bh off_r <- newFastMutInt 0 let bh' = inner_bh { _off_r = off_r } - seekBin bh' p_a + seekBinNoExpand bh' p_a f p bh' - seekBin bh p -- skip over the object for now + seekBinNoExpand bh p -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1282,6 +1284,8 @@ getGenericSymbolTable :: forall a. (Bin () -> BinHandle -> IO a) -> IORef BinHan getGenericSymbolTable deserialiser bhRef bh = do sz <- forwardGet bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) + -- Using lazyPut/lazyGet is quite space inefficient as each usage will allocate a large closure + -- (6 arguments-ish). forM_ [0..(sz-1)] $ \i -> do f <- lazyGet' (Just bhRef) deserialiser bh writeArray mut_arr i f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ef9f2b17f1ef12e735475a21c99564135176632 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ef9f2b17f1ef12e735475a21c99564135176632 You're receiving 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 Mar 23 17:22:48 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 23 Mar 2024 13:22:48 -0400 Subject: [Git][ghc/ghc][wip/T24251a] 2 commits: wibble dropping evals Message-ID: <65ff0fe810e72_ba7dffd508f4138176@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: d9299d71 by Simon Peyton Jones at 2024-03-23T16:37:03+00:00 wibble dropping evals - - - - - 2417f339 by Simon Peyton Jones at 2024-03-23T17:17:36+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 5 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - + testsuite/tests/perf/compiler/T24582.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -14,12 +14,14 @@ import GHC.Types.Var.Env ( mkInScopeSet ) import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding , idInlineActivation, setInlineActivation , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding, isDeadBinder ) + , isJoinId, idJoinPointHood, idUnfolding + , zapIdUnfolding, isDeadBinder ) import GHC.Core.Utils ( mkAltExpr, exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) import GHC.Core.FVs ( exprFreeVars ) import GHC.Core.Type ( tyConAppArgs ) import GHC.Core +import GHC.Core.Utils ( exprIsTrivial ) import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Utils.Outputable import GHC.Types.Basic @@ -714,8 +716,10 @@ cseExpr env (Case e bndr ty alts) = cseCase env e bndr ty alts cseCase :: CSEnv -> InExpr -> InId -> InType -> [InAlt] -> OutExpr cseCase env scrut bndr ty alts - | Just body' <- caseElim scrut' bndr' alts' - = Let (NonRec bndr' scrut') body' + | Just body <- caseElim scrut bndr alts + , -- See Note [Eliminating redundant cases] + let zapped_bndr = zapIdUnfolding bndr -- Wrinkle (ERC1) + = cseExpr env (Let (NonRec zapped_bndr scrut) body) | otherwise = Case scrut' bndr' ty' alts' @@ -753,7 +757,7 @@ cseCase env scrut bndr ty alts where (env', args') = addBinders alt_env args -caseElim :: OutExpr -> OutId -> [OutAlt] -> Maybe OutExpr +caseElim :: InExpr -> InId -> [InAlt] -> Maybe InExpr -- Can we eliminate the case altogether? If so return the body. -- Note [Eliminating redundant cases] caseElim scrut case_bndr alts @@ -781,7 +785,8 @@ isEvaldSoon (v1,v2) expr go (Case scrut cb _ alts) = go scrut || - (all go_alt alts && + (exprIsTrivial scrut && + all go_alt alts && not (hit cb) && -- Check for all ok_alt alts) -- shadowing -- ok_alt only runs if things look good @@ -844,7 +849,44 @@ turning K2 into 'x' increases the number of live variables. But Note [Eliminating redundant cases] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Still to be written... TODO +Consider + case x of x' { DEFAULT -> + case y of y' { DEFAULT -> + let v = in + case x' of { True -> e1; False -> e2 } + body }}} + +The initial `seq` of `x` is redundant. But the Simplifier is generally +careful not to drop that outer `case x` based on its demand-info: see Note +[Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration. + +Instead we piggy-back on CSE to eliminate it, based on peeking at the body +of the case, using isEvaldSonn, to see `x` is evaluated "soon" in the code +path that follows. If so we transform the `case` to a `let` + let x' = x in + case y of y' ... etc... + + +The notion of "soon" is a bit squishy. We allow +interchanging eval's (as in the `case x` vs `case y` above. But what about + case x of x' { DEFAULT -> + case (f y) of y' { DEFAULT -> + case x' of { True -> e1; False -> e2 } +If we drop the `seq` on `x` we fall vicitm of #21741. There is nothing +wrong semantically with dropping the `seq`, but the case of #21741 it causes +a big space leak. + +To so the conditions in isEvaldSoon are quite narrow: the two evals are +separated only by lets and other evals on /variables/. + +As Note [Case-to-let for strictly-used binders] point out, dropping the eval is +not a huge deal, because the inner eval should just be a multi-way jump (no actual +eval), but it tidies up the code. By putting it here in CSE we don't impose a +significant peformance penalty. + +Wrinkle (ERC1): + x' will have an (OtherCon []) unfolding on it. We want to zap that + unfolding before turning it into (let x' = x in ...). Note [Combine case alternatives] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -983,7 +983,7 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine | mb_join@(JoinPoint {}) <- idJoinPointHood bndr = -- Analyse the RHS and /then/ the body let -- Analyse the rhs first, generating rhs_uds - !(rhs_uds_s, bndr', rhs') = occAnalNonRecRhs env ire mb_join bndr rhs + !(rhs_uds_s, bndr', rhs') = occAnalNonRecRhs env lvl ire mb_join bndr rhs rhs_uds = foldr1 orUDs rhs_uds_s -- NB: orUDs. See (W4) of -- Note [Occurrence analysis for join points] @@ -1009,7 +1009,7 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine -- => join arity O of Note [Join arity prediction based on joinRhsArity] (tagged_bndr, mb_join) = tagNonRecBinder lvl occ bndr - !(rhs_uds_s, final_bndr, rhs') = occAnalNonRecRhs env ire mb_join tagged_bndr rhs + !(rhs_uds_s, final_bndr, rhs') = occAnalNonRecRhs env lvl ire mb_join tagged_bndr rhs in WUD (foldr andUDs body_uds rhs_uds_s) -- Note `andUDs` (combine [NonRec final_bndr rhs'] body) @@ -1024,10 +1024,10 @@ occAnalNonRecBody env bndr thing_inside in WUD inner_uds (occ, res) ----------------- -occAnalNonRecRhs :: OccEnv -> ImpRuleEdges -> JoinPointHood - -> Id -> CoreExpr +occAnalNonRecRhs :: OccEnv -> TopLevelFlag -> ImpRuleEdges + -> JoinPointHood -> Id -> CoreExpr -> ([UsageDetails], Id, CoreExpr) -occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs +occAnalNonRecRhs !env lvl imp_rule_edges mb_join bndr rhs | null rules, null imp_rule_infos = -- Fast path for common case of no rules. This is only worth -- 0.1% perf on average, but it's also only a line or two of code @@ -1046,7 +1046,7 @@ occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs -- j will never be scrutinised. env1 | is_join_point = setTailCtxt env | otherwise = setNonTailCtxt rhs_ctxt env -- Zap occ_join_points - rhs_ctxt = mkNonRecRhsCtxt bndr unf + rhs_ctxt = mkNonRecRhsCtxt lvl bndr unf -- See Note [Sources of one-shot information] rhs_env = addOneShotsFromDmd bndr env1 @@ -1092,9 +1092,9 @@ occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs [ l `andUDs` adjustTailArity mb_join r | (_,l,r) <- rules_w_uds ] -mkNonRecRhsCtxt :: Id -> Unfolding -> OccEncl +mkNonRecRhsCtxt :: TopLevelFlag -> Id -> Unfolding -> OccEncl -- Precondition: Id is not a join point -mkNonRecRhsCtxt bndr unf +mkNonRecRhsCtxt lvl bndr unf | certainly_inline = OccVanilla -- See Note [Cascading inlines] | otherwise = OccRhs where @@ -1103,11 +1103,12 @@ mkNonRecRhsCtxt bndr unf -- has set the OccInfo for this binder before calling occAnalNonRecRhs case idOccInfo bndr of OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 } - -> active && not_stable + -> active && not stable_unf && not top_bottoming _ -> False active = isAlwaysActive (idInlineActivation bndr) - not_stable = not (isStableUnfolding unf) + stable_unf = isStableUnfolding unf + top_bottoming = isTopLevel lvl && isDeadEndId bndr ----------------- occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] @@ -2410,7 +2411,7 @@ float ==> This is worse than the slow cascade, so we only want to say "certainly_inline" if it really is certain. Look at the note with preInlineUnconditionally -for the various clauses. +for the various clauses. See #24582 for an example of the two getting out of sync. ************************************************************************ ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -749,7 +749,7 @@ prepareRhs env top_lvl occ rhs0 | is_expandable = anfise rhs0 | otherwise = return (emptyLetFloats, rhs0) where - -- We can' use exprIsExpandable because the WHOLE POINT is that + -- We can't use exprIsExpandable because the WHOLE POINT is that -- we want to treat (K ) as expandable, because we are just -- about "anfise" the expression. exprIsExpandable would -- just say no! ===================================== testsuite/tests/perf/compiler/T24582.hs ===================================== @@ -0,0 +1,18 @@ +{-# OPTIONS_GHC -fmax-simplifier-iterations=20 #-} +-- This module made the Simplifier iterate for ever + +module T24582(woo) where + + +foo :: String -> Int -> a +{-# NOINLINE foo #-} +foo s _ = error s + +f :: (Int->Int) -> Int +{-# NOINLINE f #-} +f g = g 3 + +x :: Int -> a +x = foo "urk" + +woo = f x ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -716,3 +716,8 @@ test ('LookupFusion', test('T24471', [req_th, collect_compiler_stats('all', 5)], multimod_compile, ['T24471', '-v0 -O']) + +test ('T24582', + [ collect_compiler_stats('bytes allocated',5) ], + compile, + ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47840e7407f57734190658778c9a42f19d3786a2...2417f3397040d302e041bc73b0a7c15a94ec79fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47840e7407f57734190658778c9a42f19d3786a2...2417f3397040d302e041bc73b0a7c15a94ec79fe You're receiving 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 Mar 23 17:28:35 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 13:28:35 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Improve toInteger @Word32 on 64-bit platforms Message-ID: <65ff11437747a_ba7df103b53e813858e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - d696649b by Andreas Klebinger at 2024-03-23T13:28:28-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 646d254a by Ben Gamari at 2024-03-23T13:28:28-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - − docs/users_guide/9.10.1-notes.rst - + docs/users_guide/9.12.1-notes.rst - − docs/users_guide/9.6.1-notes.rst - − docs/users_guide/9.8.1-notes.rst - docs/users_guide/hints.rst - docs/users_guide/release-notes.rst - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/Word.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08876875de854728a2146f8bc582ba5a0dc2abf6...646d254a2a64f26db6638ea2c4ef78a434b7e967 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08876875de854728a2146f8bc582ba5a0dc2abf6...646d254a2a64f26db6638ea2c4ef78a434b7e967 You're receiving 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 Mar 23 20:19:11 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 16:19:11 -0400 Subject: [Git][ghc/ghc][master] NCG: Fix a bug in jump shortcutting. Message-ID: <65ff393fc0d06_e6c612ee5a5016036@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 12 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,15 +301,20 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr _ = [] +jumpDestsOfInstr i = case i of + (CBZ _ t) -> [ mkDest t ] + (CBNZ _ t) -> [ mkDest t ] + (J t) -> [ mkDest t ] + (B t) -> [ mkDest t ] + (BL t _ _) -> [ mkDest t ] + (BCOND _ t) -> [ mkDest t ] + _ -> [] + where + mkDest (TBlock id) = Just id + mkDest TLabel{} = Nothing + mkDest TReg{} = Nothing -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,15 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> targets + BCTRL{} -> [Nothing] + BL{} -> [Nothing] + JMP{} -> [Nothing] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +bar() { + return (2); +} + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bd8ed53dcefe10b72acb5729789e19ceb22df66 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bd8ed53dcefe10b72acb5729789e19ceb22df66 You're receiving 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 Mar 23 20:19:47 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 23 Mar 2024 16:19:47 -0400 Subject: [Git][ghc/ghc][master] docs: Drop old release notes, add for 9.12.1 Message-ID: <65ff39635884a_e6c61303ebcc189b8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 5 changed files: - − docs/users_guide/9.10.1-notes.rst - + docs/users_guide/9.12.1-notes.rst - − docs/users_guide/9.6.1-notes.rst - − docs/users_guide/9.8.1-notes.rst - docs/users_guide/release-notes.rst Changes: ===================================== docs/users_guide/9.10.1-notes.rst deleted ===================================== @@ -1,379 +0,0 @@ -.. _release-9-10-1: - -Version 9.10.1 -============== - -Language -~~~~~~~~ - -- The :extension:`GHC2024` language edition is now supported. It builds on top of - :extension:`GHC2021`, adding the following extensions: - - * :extension:`DataKinds` - * :extension:`DerivingStrategies` - * :extension:`DisambiguateRecordFields` - * :extension:`ExplicitNamespaces` - * :extension:`GADTs` - * :extension:`MonoLocalBinds` - * :extension:`LambdaCase` - * :extension:`RoleAnnotations` - - At the moment, :extension:`GHC2021` remains the default langauge edition that - is used when no other language edition is explicitly loaded (e.g. when running - ``ghc`` directly). Because language editions are not necessarily backwards - compatible, and future releases of GHC may change the default, it is highly - recommended to specify the language edition explicitly. - -- GHC Proposal `#281 `_ - "Visible forall in types of terms" has been partially implemented. - The following code is now accepted by GHC:: - - {-# LANGUAGE RequiredTypeArguments #-} - - vshow :: forall a -> Show a => a -> String - vshow t x = show (x :: t) - - s1 = vshow Int 42 -- "42" - s2 = vshow Double 42 -- "42.0" - - The use of ``forall a ->`` instead of ``forall a.`` indicates a *required* type - argument. A required type argument is visually indistinguishable from a value - argument but does not exist at runtime. - - This feature is guarded behind :extension:`RequiredTypeArguments`. - -- The :extension:`ExplicitNamespaces` extension can now be used in conjunction - with :extension:`RequiredTypeArguments` to select the type namespace in a - required type argument:: - - data T = T -- the name `T` is ambiguous - f :: forall a -> ... -- `f` expects a required type argument - - x1 = f T -- refers to the /data/ constructor `T` - x2 = f (type T) -- refers to the /type/ constructor `T` - -- With :extension:`LinearTypes`, ``let`` and ``where`` bindings can - now be linear. So the following now typechecks:: - - f :: A %1 -> B - g :: B %1 -> C - - h :: A %1 -> C - h x = g y - where - y = f x - -- Due to an oversight, previous GHC releases (starting from 9.4) allowed the use - of promoted data types in kinds, even when :extension:`DataKinds` was not - enabled. That is, GHC would erroneously accept the following code: :: - - {-# LANGUAGE NoDataKinds #-} - - import Data.Kind (Type) - import GHC.TypeNats (Nat) - - -- Nat shouldn't be allowed here without DataKinds - data Vec :: Nat -> Type -> Type - - This oversight has now been fixed. If you wrote code that took advantage of - this oversight, you may need to enable :extension:`DataKinds` in your code to - allow it to compile with GHC 9.10. - - For more information on what types are allowed in kinds, see the - :ref:`promotion` section. - -- Using ``forall`` as an identifier is now a parse error, as forewarned - by :ghc-flag:`-Wforall-identifier`:: - - forall :: (Variable a, MonadQSAT s m) => m a - -- parse error on input ‘forall’ - - Library authors are advised to use a different name for their functions, - such as ``forAll``, ``for_all``, or ``forall_``. - -- GHC Proposal `#65 `_ - "Require namespacing fixity declarations for type names and WARNING/DEPRECATED pragmas" has been partially implemented. - Now, with :extension:`ExplicitNamespaces` enabled, you can specify the - namespace of a name in fixity signatures, ``DEPRECATED`` and ``WARNING`` pragmas: :: - - type f $ a = f a - f $ a = f a - - infixl 9 type $ -- type-level $ is left-associative with priority 9 - infixr 0 data $ -- term-level $ is right-associative with priority 0 - - {-# DEPRECATED type D "Use `()` instead" #-} -- this will deprecate type D, but will not touch pattern synonym - data D = MkD - - {-# DEPRECATED data D "Use `MkD` instead" #-} -- this will deprecate pattern synonym only - pattern D = MkD - - pattern Head x <- (head -> x) - {-# WARNING in "x-partial" data Head [ "This is a partial synonym," - , "it throws an error on empty lists."] #-} - -- GHC Proposal `#475 `_ - "Non-punning list and tuple syntax" has been partially implemented. - When the newly introduced extension :extension:`ListTuplePuns` is disabled, - bracket syntax for lists, tuples and sums only denotes their data - constructors, while their type constructors have been changed to use regular - prefix syntax:: - - data List a = [] | a : List a - data Tuple2 a b = (a, b) - - The extension is enabled by default, establishing the usual behavior. - -- In accordance with GHC Proposal `#448 `_, - the :extension:`TypeAbstractions` extension has been extended to support - ``@``-binders in lambdas and function equations:: - - id :: forall a. a -> a - id @t x = x :: t - -- ^^ @-binder in a function equation - - e = higherRank (\ @t -> ... ) - -- ^^ @-binder in a lambda - - This feature is an experimental alternative to :extension:`ScopedTypeVariables`, - see the :ref:`type-abstractions-in-functions` section. - -Compiler -~~~~~~~~ - -- GHC Proposal `#516 - `_ - has been implemented. It introduces a warning :ghc-flag:`-Wincomplete-record-selectors` which warns about when - an invocation of a record selector may fail due to being applied to a constructor for which it is not defined. - - For example :: - - data T = T1 | T2 { x :: Int } - f :: T -> Int - f a = x a + 1 -- emit a warning here, since `f T1` will fail - - Unlike :ghc-flag:`-Wpartial-fields` this produces a warning about incomplete selectors at use sites instead of - definition sites, so it is useful in cases when the library does intend for incomplete record selectors to be - used but only in specific circumstances (e.g. when other cases are handled by previous pattern matches). - -- The :ghc-flag:`-finfo-table-map-with-stack` and - :ghc-flag:`-finfo-table-map-with-fallback` flags have been introduced. These - flags include ``STACK`` info tables and info tables with default source - location information in the info table map, respectively. They are implied by - the :ghc-flag:`-finfo-table-map` flag. The corresponding negative flags - (:ghc-flag:`-fno-info-table-map-with-stack`, - :ghc-flag:`-fno-info-table-map-with-fallback`) are useful for omitting these - info tables from the info table map and reducing the size of executables - containing info table profiling information. In a test on the `Agda codebase - `_, the size of the build results was reduced by - about 10% when these info tables were omitted. - -- Fixed a bug where compiling with both :ghc-flag:`-ddump-timings` and :ghc-flag:`-ddump-to-file` did not - suppress printing timings to the console. See :ghc-ticket:`20316`. - -- Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting - of multi-parameter type classes. See :ghc-ticket:`23832`. - -- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples - containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` - will no longer be considered small and therefore not unboxed by default under `-O` - even when used as strict field. :ghc-ticket:`22309`. - -- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling - for a 64bit platform. Even when generating code for a 32bit platform. - This makes core optimizations more consistent between 32bit and 64bit platforms - at the cost of slightly worse 32bit performance in edge cases. - -- Type abstractions in constructor patterns that were previously admitted without enabling the :extension:`TypeAbstractions` - extension now trigger a warning, :ghc-flag:`-Wdeprecated-type-abstractions`. - This new warning is part of the :ghc-flag:`-Wcompat` warning group and will become an error in a future GHC release. - -- The :ghc-flag:`-Wforall-identifier` flag is now deprecated and removed from :ghc-flag:`-Wdefault`, - as ``forall`` is no longer parsed as an identifier. - -- Late plugins have been added. These are plugins which can access and/or modify - the core of a module after optimization and after interface creation. See :ghc-ticket:`24254`. - -- If you use :ghc-flag:`-fllvm` we now use an assembler from the LLVM toolchain rather than - the preconfigured assembler. This is typically ``clang``. The ``LLVMAS`` environment - variable can be specified at configure time to instruct GHC which ``clang`` to use. - This means that if you are using ``-fllvm`` you now need ``llc``, ``opt`` and ``clang`` - available. - -- The :ghc-flag:`-fprof-late-overloaded` flag has been introduced. It causes - cost centres to be added to *overloaded* top level bindings, unlike - :ghc-flag:`-fprof-late` which adds cost centres to all top level bindings. - -- The :ghc-flag:`-fprof-late-overloaded-calls` flag has been introduced. It - causes cost centres to be inserted at call sites including instance dictionary - arguments. This may be preferred over :ghc-flag:`-fprof-late-overloaded` since - it may reveal whether imported functions are called overloaded. - -JavaScript backend -~~~~~~~~~~~~~~~~~~ - -- The JavaScript backend now supports linking with C sources. It uses Emscripten - to compile them to WebAssembly. The resulting JS file embeds and loads these - WebAssembly files. Important note: JavaScript wrappers are required to call - into C functions and pragmas have been added to indicate which C functions are - exported (see the users guide). - -WebAssembly backend -~~~~~~~~~~~~~~~~~~~ - -- The wasm backend now implements JavaScript FFI, allowing JavaScript - to be called from Haskell and vice versa when targetting JavaScript - environments like browsers and node.js. See :ref:`JavaScript FFI in - the wasm backend ` for details. - -GHCi -~~~~ - -- GHCi now differentiates between adding, unadding, loading, unloading and reloading - in its responses to using the respective commands. The output with `-fshow-loaded-modules` - is not changed to keep backwards compatibility for tooling. - -Runtime system -~~~~~~~~~~~~~~ - -- Internal fragmentation incurred by the non-moving GC's allocator has been reduced for small objects. - In one real-world application, this has reduced resident set size by about 20% and modestly improved run-time. - See :ghc-ticket:`23340`. - :rts-flag:`--nonmoving-dense-allocator-count=⟨count⟩` has been added to fine-tune this behaviour. -- Add support for heap profiling with the non-moving GC. - See :ghc-ticket:`22221`. - -- Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on - startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. - -- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual - memory address space reserved by the two step allocator on a 64-bit - platform. The default size is now 1T on aarch64 as well. See - :ghc-ticket:`24498`. - -``base`` library -~~~~~~~~~~~~~~~~ - -- Updated to `Unicode 15.1.0 `_. - -- The functions :base-ref:`GHC.Exts.dataToTag#` and - :base-ref:`GHC.Base.getTag` have had their types changed to the - following: - - :: - - dataToTag#, getTag - :: forall {lev :: Levity} (a :: TYPE (BoxedRep lev)) - . DataToTag a => a -> Int# - - In particular, they are now applicable only at some (not all) - lifted types. However, if ``t`` is an algebraic data type (i.e. ``t`` - matches a ``data`` or ``data instance`` declaration) with all of its - constructors in scope and the levity of ``t`` is statically known, - then the constraint ``DataToTag t`` can always be solved. - -- Exceptions can now carry arbitrary user-defined annotations via the new - :base-ref:`GHC.Exception.Type.ExceptionContext` implicit parameter of - ``SomeException``. These annotations are intended to be used to carry - context describing the provenance of an exception. - -- GHC now collects backtraces for synchronous exceptions. These are carried by - the exception via the ``ExceptionContext`` mechanism described above. - GHC supports several mechanisms by which backtraces can be collected which - can be individually enabled and disabled via - :base-ref:`GHC.Exception.Backtrace.setEnabledBacktraceMechanisms`. - - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -- ``dataToTag#`` has been moved from ``GHC.Prim``. It remains - exported by ``GHC.Exts``, but with a different type, as described in - the notes for ``base`` above. - -- New primops for unaligned ``Addr#`` access. - These primops will be emulated on platforms that don't support unaligned access. - These primops take the form - - .. code-block:: haskell - - indexWord8OffAddrAs :: Addr# -> Int# -> # - readWord8OffAddrAs :: Addr# -> Int# -> State# s -> (# State# s, # #) - writeWord8OffAddrAs :: Addr# -> Int# -> # -> State# s -> State# s - - where ```` is one of: - - - ``Word`` - - ``Word{16,32,64}`` - - ``Int`` - - ``Int{16,32,64,}`` - - ``Char`` - - ``WideChar`` - - ``Addr`` - - ``Float`` - - ``Double`` - - ``StablePtr`` - -``ghc`` library -~~~~~~~~~~~~~~~ - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - -``ghc-experimental`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- ``ghc-experimental`` is a new library for functions and data types with - weaker stability guarantees. Introduced per the HF Technical Proposal `#51 - `_. - -``template-haskell`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Extend ``Pat`` with ``TypeP`` and ``Exp`` with ``TypeE``, - introduce functions ``typeP`` and ``typeE`` (Template Haskell support for GHC Proposal `#281 - `_). - -Included libraries -~~~~~~~~~~~~~~~~~~ - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -0,0 +1,88 @@ +.. _release-9-11-1: + +Version 9.12.1 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. See the `migration guide +`_ on the GHC Wiki +for specific guidance on migrating programs to this release. + +Language +~~~~~~~~ + + +Compiler +~~~~~~~~ + + +GHCi +~~~~ + + +Runtime system +~~~~~~~~~~~~~~ + +``base`` library +~~~~~~~~~~~~~~~~ + + +``ghc-prim`` library +~~~~~~~~~~~~~~~~~~~~ + +``ghc`` library +~~~~~~~~~~~~~~~ + +``ghc-heap`` library +~~~~~~~~~~~~~~~~~~~~ + +``ghc-experimental`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``template-haskell`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Included libraries +~~~~~~~~~~~~~~~~~~ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + libraries/os-string/os-string.cabal: Dependency of ``filepath`` library ===================================== docs/users_guide/9.6.1-notes.rst deleted ===================================== @@ -1,267 +0,0 @@ -.. _release-9-6-1: - -Version 9.6.1 -============== - -Language -~~~~~~~~ - -- GHC is now more conservative when solving constraints that arise from - superclass expansion in terms of other constraints that also arise from - superclass expansion. - - For example: :: - - class C a - class C a => D a b - instance D a a => D a b - - When typechecking the instance, we need to also solve the constraints arising - from the superclasses of ``D``; in this case, we need ``C a``. We could obtain - evidence for this constraint by expanding the superclasses of the context, - as ``D a a`` also has a superclass context of ``C a``. - However, is it unsound to do so in general, as we might be assuming precisely - the predicate we want to prove! This can lead to programs that loop at runtime. - - When such potentially-loopy situations arise, GHC now emits a warning. - In future releases, this behaviour will no longer be supported, and the - typechecker will outright refuse to solve these constraints, emitting a - ``Could not deduce`` error. - - In practice, you should be able to fix these issues by adding the necessary - constraint to the context, e.g. for the above example: :: - - instance (C a, D a a) => D a b - -- Record updates for GADTs and other existential datatypes are now - fully supported. - - For example: :: - - data D b where - MkD :: { fld1 :: a -> a, fld2 :: a -> (), fld3 :: b } -> D b - - foo :: D b -> D b - foo d = d { fld1 = id, fld2 = const () } - - In this example, we have an existential variable ``a``, and we update - all fields whose type involves ``a`` at once, so the update is valid. - - A side-effect of this change is that GHC now rejects some record updates - involving fields whose types contain type families (these record updates - were previously erroneously accepted). - - Example: :: - - type family F a where - F Int = Char - F Float = Char - - data T b = MkT { x :: [Int], y :: [F b] } - - emptyT :: forall b. T b - emptyT = MkT [] [] - - bar :: T Int - bar = emptyT { x = [3] } - - In this example, we can't infer the type of ``emptyT`` in ``bar``: it could be - ``T Int``, but it could also be ``T Float`` because the type family ``F`` - is not injective and ``T Float ~ T Int``. Indeed, the following typechecks :: - - baz :: T Int - baz = case ( emptyT :: T Float ) of { MkT _ y -> MkT [3] y } - - This means that the type of ``emptyT`` is ambiguous in the definition - of ``bar`` above, and thus GHC rejects the record update: :: - - Couldn't match type `F b0' with `Char' - Expected: [F Int] - Actual: [F b0] - NB: ‘F’ is a non-injective type family - The type variable ‘b0’ is ambiguous - - To fix these issues, add a type signature to the expression that the - record update is applied to (``emptyT`` in the example above), or - add an injectivity annotation to the type family in the case that - the type family is in fact injective. - -- Error messages are now assigned unique error codes, of the form ``[GHC-12345]``. - -- GHC Proposal `#106 - `_ - has been implemented, introducing a new language extension - :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. - -- GHC proposal `#170 Unrestricted OverloadedLabels - `_ - has been implemented. - This extends the variety syntax for constructing labels under :extension:`OverloadedLabels`. - Examples of newly allowed syntax: - - Leading capital letters: `#Foo` equivalant to `getLabel @"Foo"` - - Numeric characters: `#1728` equivalent to `getLabel @"1728"` - - Arbitrary strings: `#"Hello, World!"` equivalent to `getLabel @"Hello, World!"` - -Compiler -~~~~~~~~ - -- The `WebAssembly backend - `_ - has been merged. This allows GHC to be built as a cross-compiler - that targets ``wasm32-wasi`` and compiles Haskell code to - self-contained WebAssembly modules that can be executed on a variety - of different runtimes. There are a few caveats to be aware of: - - - To use the WebAssembly backend, one would need to follow the - instructions on `ghc-wasm-meta - `_. The WebAssembly - backend is not included in the GHC release bindists for the time - being, nor is it supported by ``ghcup`` or ``stack`` yet. - - The WebAssembly backend is still under active development. It's - presented in this GHC version as a technology preview, bugs and - missing features are expected. - -- The JavaScript backend has been merged. GHC is now able to be built as a - cross-compiler targeting the JavaScript platform. The backend should be - considered a technology preview. As such it is not ready for use in - production, is not distributed in the GHC release bindists and requires the - user to manually build GHC as a cross-compiler. See the JavaScript backend - `wiki `_ page - on the GHC wiki for the current status, project roadmap, build instructions - and demos. - -- 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 ``:``). - -- The :ghc-flag:`-Wstar-is-type` warning is now enabled by default. - -- The 32bit x86 NCG backend will now generate inline assembly for most common 64bit - operations. This improves Int64/Word64 performance substantially on this platform. - -GHCi -~~~~ - -- GHCi will now accept any file-header pragmas it finds, such as - ``{-# OPTIONS_GHC ... #-}`` and ``{-# LANGUAGE ... #-}`` (see :ref:`pragmas`). For example, - instead of using :ghci-cmd:`:set` to enable :ghc-flag:`-Wmissing-signatures`, - you could instead write: - - .. code-block:: none - - ghci> {-# OPTIONS_GHC -Wmissing-signatures #-} - -This can be convenient when pasting large multi-line blocks of code into GHCi. - -Runtime system -~~~~~~~~~~~~~~ - -- The `Delimited continuation primops `_ - proposal has been implemented, adding native support for first-class, - delimited continuations to the RTS. For the reasons given in the proposal, - 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.Prim`` for more details. - -- The behaviour of the ``-M`` flag has been made more strict. It will now trigger - a heap overflow if the total amount of memory used by the Haskell heap exceeds the limit. - Previously only live blocks were taken into account. - This makes it more likely to trigger promptly when the heap is highly fragmented. - -- Fixed a bug that sometimes caused live sparks to be GC'ed too early either during - minor GC or major GC with workstealing disabled. See #22528. - - -``base`` library -~~~~~~~~~~~~~~~~ - -- Exceptions thrown by weak pointer finalizers can now be reported by setting - a global exception handler, using ``GHC.Weak.Finalize.setFinalizerExceptionHandler``. - The default behaviour is unchanged (exceptions are ignored and not reported). - -- GHC now provides a set of operations for introspecting on the threads of a - program, ``GHC.Conc.listThreads``, as well as operations for querying a thread's - label (:base-ref:`GHC.Conc.Sync.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 - -- Updated to `Unicode 15.0.0 `_. - -- Add standard Unicode case predicates :base-ref:`Data.Char.isUpperCase` and - :base-ref:`Data.Char.isLowerCase`. These predicates use the standard Unicode - case properties and are more intuitive than :base-ref:`Data.Char.isUpper` and - :base-ref:`Data.Char.isLower`. - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -``ghc`` library -~~~~~~~~~~~~~~~ - -- Add `Foreign.C.Types.ConstPtr` was added to encode ``const``-qualified pointer return - types in foreign declarations when using ``CApiFFI`` extension. - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - - -Included libraries ------------------- - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/9.8.1-notes.rst deleted ===================================== @@ -1,334 +0,0 @@ -.. _release-9-8-1: - -Version 9.8.1 -============= - -Language -~~~~~~~~ - -- There is a new extension :extension:`ExtendedLiterals`, which enables - sized primitive literals, e.g. ``123#Int8`` is a literal of type ``Int8#``. - See the GHC proposal `#451 `_. - Derived ``Show`` instances for datatypes containing sized literals (``Int8#``, ``Word8#``, ``Int16#`` etc.) - now use the extended literal syntax, per GHC proposal `#596 `_. - Furthermore, it is now possible to derive ``Show`` for datatypes containing - fields of types ``Int64#`` and ``Word64#``. - -- GHC Proposal `#425 - `_ - has been partially implemented. Namely, the ``@k``-binders in type declarations are now permitted:: - - type T :: forall k. k -> forall j. j -> Type - data T @k (a :: k) @(j :: Type) (b :: j) - - This feature is guarded behind :extension:`TypeAbstractions`. - -- In accordance with GHC proposal `#425 - `_ - GHC no longer implicitly quantifies over type variables that appear only in the RHS of type and - data family instances. This code will no longer work: :: - - type family F1 a :: k - type instance F1 Int = Any :: j -> j - - Instead you should write:: - - type instance F1 @(j -> j) Int = Any :: j -> j - - Or:: - - type instance forall j . F1 Int = Any :: j -> j - -- GHC proposal `#475 `_ - has been partially implemented. Namely, tuple data types, which were previously represented using a brackets-with-commas - syntax form ((), (,), (,,), and so on) have been renamed to common names of the form ``Unit``, ``Tuple2``, ``Tuple3``, - and so on, where the number after ``Tuple`` indicates its arity: :: - - data Unit = () - - data Tuple2 a b = (a,b) - data Tuple3 a b c = (a, b, c) - -- and so on, up to Tuple64 - - For consistency, we also introduce type aliases: :: - - type Tuple0 = Unit - type Tuple1 = Solo - - The renamed tuple data types and the new type aliases can be found in the ``GHC.Tuple`` module. This renaming - does not break existing code that directly uses tuple data types, but it does affect tools and libraries - that have access to the data type names, such as ``Generic`` and Template Haskell. - -Compiler -~~~~~~~~ - -- Added a new warning :ghc-flag:`-Wterm-variable-capture` that helps to make code compatible with - the future extension ``RequiredTypeArguments``. - -- Rewrite rules now support a limited form of higher order matching when a - pattern variable is applied to distinct locally bound variables. For example: :: - - forall f. foo (\x -> f x) - - Now matches: :: - - foo (\x -> x*2 + x) - -- GHC Proposal `#496 - `_ - has been implemented, allowing ``{..}`` syntax for constructors without fields, for consistency. - This is convenient for TH code generation, as you can now uniformly use record wildcards - regardless of number of fields. - -- Incoherent instance applications are no longer specialised. The previous implementation of - specialisation resulted in nondeterministic instance resolution in certain cases, breaking - the specification described in the documentation of the `INCOHERENT` pragma. See :ghc-ticket:`22448` for further details. - -- Fix a bug in TH causing excessive calls to ``setNumCapabilities`` when ``-j`` is greater than ``-N``. - See :ghc-ticket:`23049`. - -- The ``-Wno-⟨wflag⟩``, ``-Werror=⟨wflag⟩`` and ``-Wwarn=⟨wflag⟩`` options are - now defined systematically for all warning groups (for example, - ``-Wno-default``, ``-Werror=unused-binds`` and ``-Wwarn=all`` are now - accepted). See :ref:`options-sanity`. - -- ``WARNING`` pragmas may now be annotated with a category, following - `GHC proposal #541 `_, in which case they are controlled with new - ``-Wx-⟨category⟩`` flags rather than :ghc-flag:`-Wdeprecations`. - A new warning group :ghc-flag:`-Wextended-warnings` includes all such warnings - regardless of category. See :ref:`warning-deprecated-pragma`. - -- GHC is now better at disambiguating record updates in the presence of duplicate - record fields. The following program is now accepted :: - - {-# LANGUAGE DuplicateRecordFields #-} - - data R = MkR1 { foo :: Int } - | MkR2 { bar :: Int } - - data S = MkS { foo :: Int, bar :: Int } - - blah x = x { foo = 5, bar = 6 } - - The point is that only the type S has a constructor with both fields "foo" - and "bar", so this record update is unambiguous. - -- Data types with ``deriving`` clauses now reject inferred instance contexts - that mention ``TypeError`` constraints (see :ref:`custom-errors`), such as - this one: :: - - newtype Foo = Foo Int - - class Bar a where - bar :: a - - instance (TypeError (Text "Boo")) => Bar Foo where - bar = undefined - - newtype Baz = Baz Foo - deriving Bar - - Here, the derived ``Bar`` instance for ``Baz`` would look like this: :: - - instance TypeError (Text "Boo") => Bar Baz - - While GHC would accept this before, GHC 9.8 now rejects it, emitting "``Boo``" - in the resulting error message. If you really want to derive this instance and - defer the error to sites where the instance is used, you must do so manually - with :extension:`StandaloneDeriving`, e.g. :: - - deriving instance TypeError (Text "Boo") => Bar Baz - -- GHC Proposal `#540 `_ has been implemented. - This adds the `-jsem`:ghc-flag: flag, which instructs GHC to act as a jobserver client. - This enables multiple GHC processes running at once to share system resources - with each other, communicating via the system semaphore specified by - the flag argument. - -- GHC Proposal `#433 - `_ - has been implemented. This adds the class ``Unsatisfiable :: ErrorMessage -> Constraint`` - to the ``GHC.TypeError`` module. Constraints of the form ``Unsatisfiable msg`` - provide a mechanism for custom type errors that reports the errors in a more - predictable behaviour than ``TypeError``, as these constraints are - handled purely during constraint solving. - - For example: :: - - instance Unsatisfiable (Text "There is no Eq instance for functions") => Eq (a -> b) where - (==) = unsatisfiable - - This allows errors to be reported when users use the instance, even when - type errors are being deferred. - -- GHC is now deals "insoluble Givens" in a consistent way. For example: :: - - k :: (Int ~ Bool) => Int -> Bool - k x = x - - GHC used to accept the contradictory ``Int~Bool`` in the type signature, but reject the ``Int~Bool`` constraint that arises from typechecking the definition itself. Now it accepts both. More details in `GHC ticket #23413 `_, which gives examples of the previous inconsistency. GHC now implements the "PermissivePlan" described in that ticket. - -- The `-ddump-spec` flag has been split into `-ddump-spec` and - `-ddump-spec-constr`, allowing only output from the typeclass specialiser or - `SpecConstr` to be seen if desired. - -- The compiler may now be configured to compress the debugging information - included in :ghc-flag:`-finfo-table-map` enabled binaries. To do so, one must - build GHC from source (see - `here` for directions) - and supply the ``--enable-ipe-data-compression`` flag to the ``configure`` - script. **Note**: This feature requires that the machine building GHC has - `libzstd `_ version 1.4.0 or greater - installed. The compression library `libzstd` may optionally be statically - linked in the resulting compiler (on non-darwin machines) using the - ``--enable-static-libzstd`` configure flag. - - In a test compiling GHC itself, the size of the :ghc-flag:`-finfo-table-map` - enabled build results was reduced by over 20% when compression was enabled. - -- GHC Proposal `#134 - `_ - has been implemented. This makes it possible to deprecate certain names exported from a module, without deprecating - the name itself. You can check the full specification of the feature at :ref:`warning-deprecated-pragma`. - - For example :: - - module X ( - {-# WARNING "do not use that constructor" D(D1), - D(D2) - ) - data D = D1 | D2 - - This allows for changing the structure of a library without immediately breaking user code, - but instead being able to warn the user that a change in the library interface - will occur in the future. - -- Guard polymorphic specialisation behind the flag :ghc-flag:`-fpolymorphic-specialisation`. - This optimisation has led to a number of incorrect runtime result bugs, so we are disabling it - by default for now whilst we consider more carefully an appropriate fix. - (See :ghc-ticket:`23469`, :ghc-ticket:`23109`, :ghc-ticket:`21229`, :ghc-ticket:`23445`) - -- The warning about incompatible command line flags can now be controlled with the - :ghc-flag:`-Winconsistent-flags`. In particular this allows you to silence a warning - when using optimisation flags with :ghc-flag:`--interactive` mode. - -GHCi -~~~~ - -- The deprecated `:ctags` and `:etags` GHCi commands have been removed. See this `wiki page `_ if you want to add a macro to recover similar functionality. - -Runtime system -~~~~~~~~~~~~~~ - -- On POSIX systems that support timerfd, RTS shutdown no longer has to wait for - the next RTS 'tick' to occur before continuing the shutdown process. See :ghc-ticket:`22692`. - -``base`` library -~~~~~~~~~~~~~~~~ - -- ``Data.Tuple`` now exports ``getSolo :: Solo a -> a``. - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -- Primitive pointer comparison functions are now levity-polymorphic, e.g. :: - - sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# - - This change affects the following functions: - - - ``sameArray#``, ``sameMutableArray#``, - - ``sameSmallArray#``, ``sameSmallMutableArray#``, - - ``sameMutVar#``, ``sameTVar#``, ``sameMVar#`` - - ``sameIOPort#``, ``eqStableName#``. - -- New primops for fused multiply-add operations. These primops combine a - multiplication and an addition, compiling to a single instruction when - the ``-mfma`` flag is enabled and the architecture supports it. - - The new primops are ``fmaddFloat#, fmsubFloat#, fnmaddFloat#, fnmsubFloat# :: Float# -> Float# -> Float# -> Float#`` - and ``fmaddDouble#, fmsubDouble#, fnmaddDouble#, fnmsubDouble# :: Double# -> Double# -> Double# -> Double#``. - - These implement the following operations, while performing one single - rounding at the end, leading to a more accurate result: - - - ``fmaddFloat# x y z``, ``fmaddDouble# x y z`` compute ``x * y + z``. - - ``fmsubFloat# x y z``, ``fmsubDouble# x y z`` compute ``x * y - z``. - - ``fnmaddFloat# x y z``, ``fnmaddDouble# x y z`` compute ``- x * y + z``. - - ``fnmsubFloat# x y z``, ``fnmsubDouble# x y z`` compute ``- x * y - z``. - - Warning: on unsupported architectures, the software emulation provided by - the fallback to the C standard library is not guaranteed to be IEEE-compliant. - -``ghc`` library -~~~~~~~~~~~~~~~ - -- The ``RecordUpd`` constructor of ``HsExpr`` now takes an ``HsRecUpdFields`` - instead of ``Either [LHsRecUpdField p] [LHsRecUpdProj p]``. - Instead of ``Left ..``, use the constructor ``RegularRecUpdFields``, and instead - of ``Right ..``, use the constructor ``OverloadedRecUpdFields``. - -- The ``loadWithCache`` function now takes an extra argument which allows API users - to embed GHC diagnostics in their own diagnostic type before they are printed. - This allows how messages are rendered and explained to users to be modified. - We use this functionality in GHCi to modify how some messages are displayed. - -- The extensions fields of constructors of ``IE`` now take ``Maybe (WarningTxt p)`` - in ``GhcPs`` and ``GhcRn`` variants of the Syntax Tree. - This represents the warning assigned to a certain export item, - which is used for deprecated exports (see :ref:`warning-deprecated-pragma`). - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - -``template-haskell`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Record fields now belong to separate ``NameSpace``s, keyed by the parent of - the record field. This is the name of the first constructor of the parent type, - even if this constructor does not have the field in question. - This change enables TemplateHaskell support for ``DuplicateRecordFields``. - -Included libraries ------------------- - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,4 +4,4 @@ Release notes .. toctree:: :maxdepth: 1 - 9.10.1-notes + 9.12.1-notes View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d67f247c3e4ca3810712654e1becbf927405f6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d67f247c3e4ca3810712654e1becbf927405f6b You're receiving 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 Mar 23 22:14:57 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 23 Mar 2024 18:14:57 -0400 Subject: [Git][ghc/ghc][wip/T24251a] 10 commits: Improve toInteger @Word32 on 64-bit platforms Message-ID: <65ff546173a99_faeb61bdf8c51378@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - b9a77609 by Simon Peyton Jones at 2024-03-23T22:04:09+00:00 Rename tryCaseMerge - - - - - 2b3cb869 by Simon Peyton Jones at 2024-03-23T22:14:15+00:00 Eliinate redundant cases in CSE Addresses programs like this f xs = xs `seq` (let t = reverse $ reverse $ reverse $ reverse $ reverse $ reverse xs in case xs of [] -> (t,True) (_:_) -> (t,False)) Also including the case where t is a join point. Relates to #24251. Test in T24251a. (And see Simon's GHC Log 13 March.) - - - - - 5bb3a4d9 by Simon Peyton Jones at 2024-03-23T22:14:15+00:00 Tests for T21741 - - - - - a59e74bd by Simon Peyton Jones at 2024-03-23T22:14:15+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/OccurAnal.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/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Types/Id.hs - − docs/users_guide/9.10.1-notes.rst - + docs/users_guide/9.12.1-notes.rst - − docs/users_guide/9.6.1-notes.rst - − docs/users_guide/9.8.1-notes.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2417f3397040d302e041bc73b0a7c15a94ec79fe...a59e74bd3ca28748e678dd6858eb604c8f011a5e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2417f3397040d302e041bc73b0a7c15a94ec79fe...a59e74bd3ca28748e678dd6858eb604c8f011a5e You're receiving 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 Mar 24 22:12:06 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 24 Mar 2024 18:12:06 -0400 Subject: [Git][ghc/ghc][wip/T24251a] 2 commits: Eliminate redundant cases in CSE Message-ID: <6600a536a2809_3ef2ed2a0800015143@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 7fffd774 by Simon Peyton Jones at 2024-03-24T22:11:08+00:00 Eliminate redundant cases in CSE Addresses programs like this f xs = xs `seq` (let t = reverse $ reverse $ reverse $ reverse $ reverse $ reverse xs in case xs of [] -> (t,True) (_:_) -> (t,False)) Also including the case where t is a join point. Relates to #24251. Test in T24251a. (And see Simon's GHC Log 13 March.) Also added a perf test for #21741 - - - - - b2a487e4 by Simon Peyton Jones at 2024-03-24T22:11:46+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 14 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Id.hs - + testsuite/tests/perf/compiler/T24582.hs - testsuite/tests/perf/compiler/all.T - + testsuite/tests/perf/should_run/T21741.hs - + testsuite/tests/perf/should_run/T21741.stdout - testsuite/tests/perf/should_run/all.T - + testsuite/tests/simplCore/should_compile/T24251a.hs - + testsuite/tests/simplCore/should_compile/T24251a.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -14,13 +14,15 @@ import GHC.Types.Var.Env ( mkInScopeSet ) import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding , idInlineActivation, setInlineActivation , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) -import GHC.Core.Utils ( mkAltExpr - , exprIsTickedString + , isJoinId, idJoinPointHood, idUnfolding + , zapIdUnfolding, isDeadBinder ) +import GHC.Core.Utils ( mkAltExpr, exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) import GHC.Core.FVs ( exprFreeVars ) import GHC.Core.Type ( tyConAppArgs ) import GHC.Core +import GHC.Core.Utils ( exprIsTrivial ) +import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Utils.Outputable import GHC.Types.Basic import GHC.Types.Tickish @@ -714,25 +716,33 @@ cseExpr env (Case e bndr ty alts) = cseCase env e bndr ty alts cseCase :: CSEnv -> InExpr -> InId -> InType -> [InAlt] -> OutExpr cseCase env scrut bndr ty alts - = Case scrut1 bndr3 ty' $ - combineAlts (map cse_alt alts) + | Just body <- caseElim scrut bndr alts + , -- See Note [Eliminating redundant cases] + let zapped_bndr = zapIdUnfolding bndr -- Wrinkle (ERC1) + = cseExpr env (Let (NonRec zapped_bndr scrut) body) + + | otherwise + = Case scrut' bndr' ty' alts' + where ty' = substTyUnchecked (csEnvSubst env) ty - (cse_done, scrut1) = try_for_cse env scrut + (cse_done, scrut') = try_for_cse env scrut bndr1 = zapIdOccInfo bndr -- Zapping the OccInfo is needed because the extendCSEnv -- in cse_alt may mean that a dead case binder -- becomes alive, and Lint rejects that (env1, bndr2) = addBinder env bndr1 - (alt_env, bndr3) = extendCSEnvWithBinding env1 bndr bndr2 scrut1 cse_done + (alt_env, bndr') = extendCSEnvWithBinding env1 bndr bndr2 scrut' cse_done -- extendCSEnvWithBinding: see Note [CSE for case expressions] + alts' = combineAlts (map cse_alt alts) + con_target :: OutExpr con_target = lookupSubst alt_env bndr arg_tys :: [OutType] - arg_tys = tyConAppArgs (idType bndr3) + arg_tys = tyConAppArgs (idType bndr') -- See Note [CSE for case alternatives] cse_alt (Alt (DataAlt con) args rhs) @@ -747,6 +757,45 @@ cseCase env scrut bndr ty alts where (env', args') = addBinders alt_env args +caseElim :: InExpr -> InId -> [InAlt] -> Maybe InExpr +-- Can we eliminate the case altogether? If so return the body. +-- Note [Eliminating redundant cases] +caseElim scrut case_bndr alts + | [Alt _ bndrs rhs] <- alts + , Just (scrut_var, _) <- scrutBinderSwap_maybe scrut + , all isDeadBinder bndrs + , isEvaldSoon (scrut_var, case_bndr) rhs + = Just rhs + + | otherwise + = Nothing + +isEvaldSoon :: (OutId, OutId) -> OutExpr -> Bool +-- (isEvaldSoon (v1,v2) e) is True if either v1 or v2 is evaluated "soon" by e +isEvaldSoon (v1,v2) expr + = go expr + where + hit :: Var -> Bool + hit v = v==v1 || v==v2 + + go (Var v) = hit v + go (Let _ e) = go e + go (Tick _ e) = go e + go (Cast e _) = go e + + go (Case scrut cb _ alts) + = go scrut || + (exprIsTrivial scrut && + all go_alt alts && + not (hit cb) && -- Check for + all ok_alt alts) -- shadowing + -- ok_alt only runs if things look good + + go _ = False -- Lit, App, Lam, Coercion, Type + + go_alt (Alt _ _ rhs) = go rhs + ok_alt (Alt _ cbs _) = not (any hit cbs) + combineAlts :: [OutAlt] -> [OutAlt] -- See Note [Combine case alternatives] combineAlts alts @@ -798,6 +847,64 @@ turning K2 into 'x' increases the number of live variables. But * The next run of the simplifier will turn 'x' back into K2, so we won't permanently bloat the free-var count. +Note [Eliminating redundant cases] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + case x of x' { DEFAULT -> + case y of y' { DEFAULT -> + let v = in + case x' of { True -> e1; False -> e2 } + body }}} + +The initial `seq` of `x` is redundant. But the Simplifier is generally +careful not to drop that outer `case x` based on its demand-info: see Note +[Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration. + +Instead we peek at the body of the case, using `isEvaldSoon`, to see if `x` is +evaluated "soon" in the code path that follows. If so we transform the +`case` to a `let` + let x' = x in + case y of y' ... etc... + +The notion of "soon" is a bit squishy, and is implemented by `isEvaldSoon`. +We allow interchanging eval's (as in the `case x` vs `case y` above. But +what about + case x of x' { DEFAULT -> + case (f y) of y' { DEFAULT -> + case x' of { True -> e1; False -> e2 } +If we drop the `seq` on `x` we fall vicitm of #21741. There is nothing +wrong /semantically/ with dropping the `seq`, but the case of #21741 it causes +a big space leak. + +So the conditions in `isEvaldSoon` are quite narrow: the two evals are +separated only by lets and other evals on /variables/. + +Wrinkle (ERC1): + x' will have an (OtherCon []) unfolding on it. We want to zap that + unfolding before turning it into (let x' = x in ...). + +Wrinkle (ERC2): + You might wonder if case-merging in the Simplifer doesn't cover this. + See GHC.Core.Opt.Simplify.Utils.tryCaseMerge. and Note [Merge Nested Cases] + in that same module. But no, it is defeated by the 'let v = ` in our + example above, and I didn't want to make it more complicated. + + Mabye case-merging should be made simpler, or even moved outright here into CSE. + +Wrinkle (ERC3): + Why is this done in CSE? Becuase the "peeking" is tiresome and potentially a bit + expensive (quadratic in deep nests) so we don't want too often. CSE runs seldom, + it is a pretty simple pass, and it's easy to "drop in" this extra optimisation. + Also eliminating redundant cases is a bit like commoning up duplicated work. + +Wrinkle (ERC4): + You might wonder whether we want to do this "optimisation" /at all/. After all, as + Note [Case-to-let for strictly-used binders] point out, dropping the eval is + not a huge deal, because the inner eval should just be a multi-way jump (no + actual eval). But droppping the eval removes clutter, and I found that not dropping + made some functions look a bit bigger, and hence they didn't get inlined. + + This is small beer though: I don't think it's an /important/ transformation. Note [Combine case alternatives] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -983,7 +983,7 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine | mb_join@(JoinPoint {}) <- idJoinPointHood bndr = -- Analyse the RHS and /then/ the body let -- Analyse the rhs first, generating rhs_uds - !(rhs_uds_s, bndr', rhs') = occAnalNonRecRhs env ire mb_join bndr rhs + !(rhs_uds_s, bndr', rhs') = occAnalNonRecRhs env lvl ire mb_join bndr rhs rhs_uds = foldr1 orUDs rhs_uds_s -- NB: orUDs. See (W4) of -- Note [Occurrence analysis for join points] @@ -1009,7 +1009,7 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine -- => join arity O of Note [Join arity prediction based on joinRhsArity] (tagged_bndr, mb_join) = tagNonRecBinder lvl occ bndr - !(rhs_uds_s, final_bndr, rhs') = occAnalNonRecRhs env ire mb_join tagged_bndr rhs + !(rhs_uds_s, final_bndr, rhs') = occAnalNonRecRhs env lvl ire mb_join tagged_bndr rhs in WUD (foldr andUDs body_uds rhs_uds_s) -- Note `andUDs` (combine [NonRec final_bndr rhs'] body) @@ -1024,10 +1024,10 @@ occAnalNonRecBody env bndr thing_inside in WUD inner_uds (occ, res) ----------------- -occAnalNonRecRhs :: OccEnv -> ImpRuleEdges -> JoinPointHood - -> Id -> CoreExpr +occAnalNonRecRhs :: OccEnv -> TopLevelFlag -> ImpRuleEdges + -> JoinPointHood -> Id -> CoreExpr -> ([UsageDetails], Id, CoreExpr) -occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs +occAnalNonRecRhs !env lvl imp_rule_edges mb_join bndr rhs | null rules, null imp_rule_infos = -- Fast path for common case of no rules. This is only worth -- 0.1% perf on average, but it's also only a line or two of code @@ -1046,7 +1046,7 @@ occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs -- j will never be scrutinised. env1 | is_join_point = setTailCtxt env | otherwise = setNonTailCtxt rhs_ctxt env -- Zap occ_join_points - rhs_ctxt = mkNonRecRhsCtxt bndr unf + rhs_ctxt = mkNonRecRhsCtxt lvl bndr unf -- See Note [Sources of one-shot information] rhs_env = addOneShotsFromDmd bndr env1 @@ -1092,9 +1092,9 @@ occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs [ l `andUDs` adjustTailArity mb_join r | (_,l,r) <- rules_w_uds ] -mkNonRecRhsCtxt :: Id -> Unfolding -> OccEncl +mkNonRecRhsCtxt :: TopLevelFlag -> Id -> Unfolding -> OccEncl -- Precondition: Id is not a join point -mkNonRecRhsCtxt bndr unf +mkNonRecRhsCtxt lvl bndr unf | certainly_inline = OccVanilla -- See Note [Cascading inlines] | otherwise = OccRhs where @@ -1103,11 +1103,12 @@ mkNonRecRhsCtxt bndr unf -- has set the OccInfo for this binder before calling occAnalNonRecRhs case idOccInfo bndr of OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 } - -> active && not_stable + -> active && not stable_unf && not top_bottoming _ -> False active = isAlwaysActive (idInlineActivation bndr) - not_stable = not (isStableUnfolding unf) + stable_unf = isStableUnfolding unf + top_bottoming = isTopLevel lvl && isDeadEndId bndr ----------------- occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] @@ -2410,7 +2411,7 @@ float ==> This is worse than the slow cascade, so we only want to say "certainly_inline" if it really is certain. Look at the note with preInlineUnconditionally -for the various clauses. +for the various clauses. See #24582 for an example of the two getting out of sync. ************************************************************************ ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -17,7 +17,7 @@ module GHC.Core.Opt.Simplify.Env ( seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, - mkSimplEnv, extendIdSubst, + mkSimplEnv, extendIdSubst, extendCvIdSubst, extendTvSubst, extendCvSubst, zapSubstEnv, setSubstEnv, bumpCaseDepth, getInScope, setInScopeFromE, setInScopeFromF, @@ -550,6 +550,10 @@ extendCvSubst env@(SimplEnv {seCvSubst = csubst}) var co = assert (isCoVar var) $ env {seCvSubst = extendVarEnv csubst var co} +extendCvIdSubst :: SimplEnv -> Id -> OutExpr -> SimplEnv +extendCvIdSubst env bndr (Coercion co) = extendCvSubst env bndr co +extendCvIdSubst env bndr rhs = extendIdSubst env bndr (DoneEx rhs NotJoinPoint) + --------------------- getInScope :: SimplEnv -> InScopeSet getInScope env = seInScope env ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -412,9 +412,7 @@ simplAuxBind env bndr new_rhs -- have no NOLINE pragmas, nor RULEs | exprIsTrivial new_rhs -- Short-cut for let x = y in ... = return ( emptyFloats env - , case new_rhs of - Coercion co -> extendCvSubst env bndr co - _ -> extendIdSubst env bndr (DoneEx new_rhs NotJoinPoint) ) + , extendCvIdSubst env bndr new_rhs ) -- bndr can be a CoVar | otherwise = do { -- ANF-ise the RHS @@ -751,7 +749,7 @@ prepareRhs env top_lvl occ rhs0 | is_expandable = anfise rhs0 | otherwise = return (emptyLetFloats, rhs0) where - -- We can' use exprIsExpandable because the WHOLE POINT is that + -- We can't use exprIsExpandable because the WHOLE POINT is that -- we want to treat (K ) as expandable, because we are just -- about "anfise" the expression. exprIsExpandable would -- just say no! ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2394,6 +2394,9 @@ the outer case scrutinises the same variable as the outer case. This transformation is called Case Merging. It avoids that the same variable is scrutinised multiple times. +See also Note [Eliminating redundant cases] in GHC.Core.Opt.CSE, especially +wrinkle (ERC2). + Wrinkles (MC1) `tryCaseMerge` "looks though" an inner single-alternative case-on-variable. ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -625,7 +625,7 @@ isImplicitId id idIsFrom :: Module -> Id -> Bool idIsFrom mod id = nameIsLocalOrFrom mod (idName id) -isDeadBinder :: Id -> Bool +isDeadBinder :: Var -> Bool isDeadBinder bndr | isId bndr = isDeadOcc (idOccInfo bndr) | otherwise = False -- TyVars count as not dead ===================================== testsuite/tests/perf/compiler/T24582.hs ===================================== @@ -0,0 +1,18 @@ +{-# OPTIONS_GHC -fmax-simplifier-iterations=20 #-} +-- This module made the Simplifier iterate for ever + +module T24582(woo) where + + +foo :: String -> Int -> a +{-# NOINLINE foo #-} +foo s _ = error s + +f :: (Int->Int) -> Int +{-# NOINLINE f #-} +f g = g 3 + +x :: Int -> a +x = foo "urk" + +woo = f x ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -716,3 +716,8 @@ test ('LookupFusion', test('T24471', [req_th, collect_compiler_stats('all', 5)], multimod_compile, ['T24471', '-v0 -O']) + +test ('T24582', + [ collect_compiler_stats('bytes allocated',5) ], + compile, + ['-O']) ===================================== testsuite/tests/perf/should_run/T21741.hs ===================================== @@ -0,0 +1,25 @@ +{-# LANGUAGE BangPatterns #-} +module Main where + +import System.Environment + +f :: [Int] -> Int +f xs = g (length xs) (even $ mySum xs) +{-# NOINLINE f #-} + +g :: Int -> Bool -> Int +g 0 _ = 0 +g n !b = length xs + mySum xs + if b then 0 else 1 + where + xs = [0..n] +{-# NOINLINE g #-} + +mySum :: [Int] -> Int +mySum = go 0 + where + go acc (x:xs) = go (x+acc) xs + go acc _ = acc + +main = do + (n:_) <- map read <$> getArgs + print $ f [0..n] ===================================== testsuite/tests/perf/should_run/T21741.stdout ===================================== @@ -0,0 +1 @@ +50000025000003 ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -413,3 +413,9 @@ test('T21839r', # perf doesn't regress further, so it is not marked as such. test('T18964', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O']) test('T23021', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O2']) + +# GC bytes copied goes up a lot if the space leak returns +test('T21741', [collect_stats('copied_bytes', 2), + extra_run_opts('10000000'), + only_ways(['normal'])], + compile_and_run, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T24251a.hs ===================================== @@ -0,0 +1,9 @@ +module T24251a where + +f xs = xs `seq` + (let t = reverse (reverse (reverse (reverse xs))) in + case xs of + [] -> (t,True) + (_:_) -> (t,False)) + +-- We start with an eval of xs, but that should disappear. ===================================== testsuite/tests/simplCore/should_compile/T24251a.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 33, types: 60, coercions: 0, joins: 0/1} + +$wf + = \ @a xs -> + let { + t = reverse1 (reverse1 (reverse1 (reverse1 xs []) []) []) [] } in + case xs of { + [] -> (# t, True #); + : ds ds1 -> (# t, False #) + } + +f = \ @a xs -> case $wf xs of { (# ww, ww1 #) -> (ww, ww1) } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24251a', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-all']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a59e74bd3ca28748e678dd6858eb604c8f011a5e...b2a487e4f6c46069441eed762deae4732203e335 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a59e74bd3ca28748e678dd6858eb604c8f011a5e...b2a487e4f6c46069441eed762deae4732203e335 You're receiving 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 Mar 24 22:22:57 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 24 Mar 2024 18:22:57 -0400 Subject: [Git][ghc/ghc][wip/T24359] 167 commits: Define GHC2024 language edition (#24320) Message-ID: <6600a7c1e0027_3ef2ed312d68c15736@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 62f6f630 by Simon Peyton Jones at 2024-03-24T22:22:39+00:00 Just a start on specialising expressions Addresses #24359. Just a start, does not compile. - - - - - ee6729c5 by Simon Peyton Jones at 2024-03-24T22:22:39+00:00 More progress (Still does not compile.) - - - - - 1feb1407 by Simon Peyton Jones at 2024-03-24T22:22:39+00:00 More progress - - - - - 2ea9b6b6 by Simon Peyton Jones at 2024-03-24T22:22:39+00:00 Wibble - - - - - 089f66ab by Simon Peyton Jones at 2024-03-24T22:22:40+00:00 More progress - - - - - c3227e20 by Simon Peyton Jones at 2024-03-24T22:22:40+00:00 More progress - - - - - 98da9bc3 by Simon Peyton Jones at 2024-03-24T22:22:40+00:00 Finally runnable! - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - 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/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Graph.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e7a4ac08bda1d7ec174a5e735861c3e26325480a...98da9bc3d9850fe6ea1c9218368ac63ad61911c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e7a4ac08bda1d7ec174a5e735861c3e26325480a...98da9bc3d9850fe6ea1c9218368ac63ad61911c4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 01:48:16 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 24 Mar 2024 21:48:16 -0400 Subject: [Git][ghc/ghc][wip/T24528] 47 commits: rts/linker: Don't unload code when profiling is enabled Message-ID: <6600d7e0d8b85_3ef2ed87c951821685@gitlab.mail> Ben Gamari pushed to branch wip/T24528 at Glasgow Haskell Compiler / GHC Commits: 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - b38ffc82 by Ben Gamari at 2024-03-24T21:22:44-04:00 Bump time submodule to 1.14 As requested in #24528. - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/667daed5d41d1370a48bf79fc35c681eb958416e...b38ffc82df8b2b38439699886df7b17ece8eb534 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/667daed5d41d1370a48bf79fc35c681eb958416e...b38ffc82df8b2b38439699886df7b17ece8eb534 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 02:29:02 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 24 Mar 2024 22:29:02 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] 48 commits: Remove duplicate code normalising slashes Message-ID: <6600e16e6da6_3ef2ed9bf7c102255c@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - cf1ce2b0 by Apoorv Ingle at 2024-03-24T21:28:39-05:00 make applicative do work with expansions, possibly badly Fixes: #24406 - - - - - 76f54dff by Apoorv Ingle at 2024-03-24T21:28:39-05:00 enable the flow - - - - - c116bb94 by Apoorv Ingle at 2024-03-24T21:28:39-05:00 renaming do_or_lc to doFlavour and debugging error contexts - - - - - 63eefc73 by Apoorv Ingle at 2024-03-24T21:28:39-05:00 testcases - - - - - 6d953a6a by Apoorv Ingle at 2024-03-24T21:28:39-05:00 make sure app do expression statements location is mapped correctly - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5106889a7948f353f83f1584aa22f822e72680ed...6d953a6a91b32bf638c64b3ed4cf12208cd5f6ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5106889a7948f353f83f1584aa22f822e72680ed...6d953a6a91b32bf638c64b3ed4cf12208cd5f6ee You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 02:34:54 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 24 Mar 2024 22:34:54 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] make sure app do expression statements location is mapped correctly Message-ID: <6600e2ceaa71_3ef2ed9d54734249d8@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: 7dece5c9 by Apoorv Ingle at 2024-03-24T21:34:05-05:00 make sure app do expression statements location is mapped correctly - - - - - 5 changed files: - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Utils/Monad.hs - testsuite/tests/ado/ado004.stderr Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -797,11 +797,15 @@ addArgCtxt :: AppCtxt -> LHsExpr GhcRn addArgCtxt ctxt (L arg_loc arg) thing_inside = do { in_generated_code <- inGeneratedCode ; case ctxt of - VACall fun arg_no _ | not in_generated_code + VACall fun arg_no fun_loc + | not in_generated_code -> do setSrcSpanA arg_loc $ addErrCtxt (funAppCtxt fun arg arg_no) $ thing_inside + | XExpr{} <- arg, in_generated_code + -> thing_inside -- AppDo case for <*>'s second argument, the ctxt will be set by addHeadCtxt + VAExpansion (OrigStmt (L _ stmt@(BindStmt {}))) _ loc | isGeneratedSrcSpan (locA arg_loc) -- This arg is the second argument to generated (>>=) -> setSrcSpan loc $ @@ -817,8 +821,8 @@ addArgCtxt ctxt (L arg_loc arg) thing_inside thing_inside _ -> setSrcSpanA arg_loc $ - addExprCtxt arg $ -- Auto-suppressed if arg_loc is generated - thing_inside } + addExprCtxt arg $ -- Auto-suppressed if arg_loc is generated + thing_inside } {- ********************************************************************* * * ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -87,7 +87,10 @@ expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] | NoSyntaxExprRn <- ret_expr -- Last statement is just body if we are not in ListComp context. See Syntax.Expr.LastStmt = do traceTc "expand_do_stmts last" (ppr ret_expr) - return $ mkExpandedStmtPopAt loc stmt body + appDo <- xoptM LangExt.ApplicativeDo + if appDo + then return $ mkExpandedStmtAt loc stmt body + else return $ mkExpandedStmtPopAt loc stmt body | SyntaxExprRn ret <- ret_expr -- @@ -220,14 +223,14 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = do_arg :: ApplicativeArg GhcRn -> TcM ((LPat GhcRn, FailOperator GhcRn), LHsExpr GhcRn) do_arg (ApplicativeArgOne { xarg_app_arg_one = mb_fail_op - , app_arg_pattern = pat@(L loc _) - , arg_expr = rhs + , app_arg_pattern = pat + , arg_expr = (L rhs_loc rhs) }) = - return ((pat, mb_fail_op), mkExpandedStmtAt loc (L loc (BindStmt xbsn pat rhs)) (unLoc rhs)) + return ((pat, mb_fail_op), mkExpandedStmtAt rhs_loc (L rhs_loc (BindStmt xbsn pat (L rhs_loc rhs))) rhs) do_arg (ApplicativeArgMany _ stmts ret pat ctxt) = do { expr <- expand_do_stmts ctxt $ stmts ++ [wrapGenSpan $ mkLastStmt (wrapGenSpan ret)] ; return ((pat, Nothing) - , {- wrapGenSpan $ mkExpandedExpr (HsDo noExtField ctxt (wrapGenSpan stmts)) (unLoc expr)-} expr) } + , expr) } match_args :: (LPat GhcRn, FailOperator GhcRn) -> HsExpr GhcRn -> TcM (HsExpr GhcRn) match_args (pat, fail_op) body = unLoc <$> mk_failable_expr doFlavour pat (wrapGenSpan body) fail_op ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -897,15 +897,18 @@ tcInferAppHead_maybe fun addHeadCtxt :: AppCtxt -> TcM a -> TcM a addHeadCtxt (VAExpansion (OrigStmt (L loc stmt)) _ _) thing_inside = - do setSrcSpanA loc $ + do traceTc "addHeadCtxt stmt" (ppr stmt) + setSrcSpanA loc $ addStmtCtxt stmt thing_inside addHeadCtxt fun_ctxt thing_inside | not (isGoodSrcSpan fun_loc) -- noSrcSpan => no arguments - = thing_inside -- => context is already set + = do traceTc "addHeadCtxt notGood" empty + thing_inside -- => context is already set | otherwise = setSrcSpan fun_loc $ - do case fun_ctxt of + do traceTc "addHeadCtxt fun_loc" (ppr fun_loc) + case fun_ctxt of VAExpansion (OrigExpr orig) _ _ -> addExprCtxt orig thing_inside _ -> thing_inside where @@ -1640,6 +1643,7 @@ addExprCtxt :: HsExpr GhcRn -> TcRn a -> TcRn a addExprCtxt e thing_inside = case e of HsUnboundVar {} -> thing_inside + XExpr (ExpandedThingRn (OrigStmt stmt) _) -> addStmtCtxt (unLoc stmt) thing_inside _ -> addErrCtxt (exprCtxt e) thing_inside -- The HsUnboundVar special case addresses situations like -- f x = _ ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -1230,7 +1230,7 @@ setErrCtxt ctxt = updLclEnv (setLclEnvErrCtxt ctxt) -- do any tidying. addErrCtxt :: SDoc -> TcM a -> TcM a {-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt] -addErrCtxt msg thing_inside = dbgErrCtxt (addErrCtxtM (\env -> return (env, msg)) thing_inside) +addErrCtxt msg thing_inside = dbgErrCtxt msg (addErrCtxtM (\env -> return (env, msg)) thing_inside) -- | Add a message to the error context. This message may do tidying. addErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, SDoc)) -> TcM a -> TcM a @@ -1255,11 +1255,11 @@ pushCtxt :: ErrCtxt -> TcM a -> TcM a {-# INLINE pushCtxt #-} -- Note [Inlining addErrCtxt] pushCtxt ctxt = updLclEnv (updCtxt ctxt) -dbgErrCtxt :: TcM a -> TcM a -dbgErrCtxt thing_inside = +dbgErrCtxt :: SDoc -> TcM a -> TcM a +dbgErrCtxt msg thing_inside = do errCtxt <- getErrCtxt info <- mkErrInfo emptyTidyEnv errCtxt - traceTc "--Debug Error Context--" (ppr info) + traceTc "--Debug Error Context--" (vcat [ppr msg, text "----", ppr info, text "----"]) thing_inside updCtxt :: ErrCtxt -> TcLclEnv -> TcLclEnv @@ -1270,7 +1270,7 @@ updCtxt ctxt env | otherwise = addLclEnvErrCtxt ctxt env popErrCtxt :: TcM a -> TcM a -popErrCtxt thing_inside = dbgErrCtxt $ updLclEnv (\env -> setLclEnvErrCtxt (pop $ getLclEnvErrCtxt env) env) $ +popErrCtxt thing_inside = dbgErrCtxt (text "PopErrCtxt") $ updLclEnv (\env -> setLclEnvErrCtxt (pop $ getLclEnvErrCtxt env) env) $ thing_inside where pop [] = [] ===================================== testsuite/tests/ado/ado004.stderr ===================================== @@ -8,24 +8,24 @@ TYPE SIGNATURES test1c :: forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int test2 :: - forall {f :: * -> *} {t} {b}. - (Applicative f, Num t, Num b) => + forall {f :: * -> *} {b} {t}. + (Applicative f, Num b, Num t) => (t -> f b) -> f b test2a :: - forall {f :: * -> *} {t} {b}. - (Functor f, Num t, Num b) => + forall {f :: * -> *} {b} {t}. + (Functor f, Num b, Num t) => (t -> f b) -> f b test2b :: forall {f :: * -> *} {t} {a}. (Applicative f, Num t) => (t -> a) -> f a test2c :: - forall {f :: * -> *} {t} {b}. - (Functor f, Num t, Num b) => + forall {f :: * -> *} {b} {t}. + (Functor f, Num b, Num t) => (t -> f b) -> f b test2d :: - forall {f :: * -> *} {t} {b} {a}. - (Functor f, Num t, Num b) => + forall {f :: * -> *} {b} {t} {a}. + (Functor f, Num b, Num t) => (t -> f a) -> f b test3 :: forall {m :: * -> *} {t1} {t2} {a}. @@ -44,4 +44,4 @@ TYPE SIGNATURES (Monad m, Num (m a)) => (m a -> m (m a)) -> p -> m a Dependent modules: [] -Dependent packages: [base-4.16.0.0] +Dependent packages: [base-4.20.0.0] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7dece5c94419991f84bf886df3879e80263146f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7dece5c94419991f84bf886df3879e80263146f1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 02:55:19 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 24 Mar 2024 22:55:19 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] make sure app do expression statements location is mapped correctly Message-ID: <6600e7974f15b_3ef2eda4c46f4260c7@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: 5bda9532 by Apoorv Ingle at 2024-03-24T21:50:12-05:00 make sure app do expression statements location is mapped correctly - - - - - 5 changed files: - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Utils/Monad.hs - testsuite/tests/ado/ado004.stderr Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -797,11 +797,15 @@ addArgCtxt :: AppCtxt -> LHsExpr GhcRn addArgCtxt ctxt (L arg_loc arg) thing_inside = do { in_generated_code <- inGeneratedCode ; case ctxt of - VACall fun arg_no _ | not in_generated_code + VACall fun arg_no _ + | not in_generated_code -> do setSrcSpanA arg_loc $ addErrCtxt (funAppCtxt fun arg arg_no) $ thing_inside + | XExpr{} <- arg, in_generated_code + -> thing_inside -- AppDo case for <*>'s second argument, the ctxt will be set by addHeadCtxt + VAExpansion (OrigStmt (L _ stmt@(BindStmt {}))) _ loc | isGeneratedSrcSpan (locA arg_loc) -- This arg is the second argument to generated (>>=) -> setSrcSpan loc $ @@ -817,8 +821,8 @@ addArgCtxt ctxt (L arg_loc arg) thing_inside thing_inside _ -> setSrcSpanA arg_loc $ - addExprCtxt arg $ -- Auto-suppressed if arg_loc is generated - thing_inside } + addExprCtxt arg $ -- Auto-suppressed if arg_loc is generated + thing_inside } {- ********************************************************************* * * ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -87,7 +87,10 @@ expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] | NoSyntaxExprRn <- ret_expr -- Last statement is just body if we are not in ListComp context. See Syntax.Expr.LastStmt = do traceTc "expand_do_stmts last" (ppr ret_expr) - return $ mkExpandedStmtPopAt loc stmt body + appDo <- xoptM LangExt.ApplicativeDo + if appDo + then return $ mkExpandedStmtAt loc stmt body + else return $ mkExpandedStmtPopAt loc stmt body | SyntaxExprRn ret <- ret_expr -- @@ -220,14 +223,14 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = do_arg :: ApplicativeArg GhcRn -> TcM ((LPat GhcRn, FailOperator GhcRn), LHsExpr GhcRn) do_arg (ApplicativeArgOne { xarg_app_arg_one = mb_fail_op - , app_arg_pattern = pat@(L loc _) - , arg_expr = rhs + , app_arg_pattern = pat + , arg_expr = (L rhs_loc rhs) }) = - return ((pat, mb_fail_op), mkExpandedStmtAt loc (L loc (BindStmt xbsn pat rhs)) (unLoc rhs)) + return ((pat, mb_fail_op), mkExpandedStmtAt rhs_loc (L rhs_loc (BindStmt xbsn pat (L rhs_loc rhs))) rhs) do_arg (ApplicativeArgMany _ stmts ret pat ctxt) = do { expr <- expand_do_stmts ctxt $ stmts ++ [wrapGenSpan $ mkLastStmt (wrapGenSpan ret)] ; return ((pat, Nothing) - , {- wrapGenSpan $ mkExpandedExpr (HsDo noExtField ctxt (wrapGenSpan stmts)) (unLoc expr)-} expr) } + , expr) } match_args :: (LPat GhcRn, FailOperator GhcRn) -> HsExpr GhcRn -> TcM (HsExpr GhcRn) match_args (pat, fail_op) body = unLoc <$> mk_failable_expr doFlavour pat (wrapGenSpan body) fail_op ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -897,15 +897,18 @@ tcInferAppHead_maybe fun addHeadCtxt :: AppCtxt -> TcM a -> TcM a addHeadCtxt (VAExpansion (OrigStmt (L loc stmt)) _ _) thing_inside = - do setSrcSpanA loc $ + do traceTc "addHeadCtxt stmt" (ppr stmt) + setSrcSpanA loc $ addStmtCtxt stmt thing_inside addHeadCtxt fun_ctxt thing_inside | not (isGoodSrcSpan fun_loc) -- noSrcSpan => no arguments - = thing_inside -- => context is already set + = do traceTc "addHeadCtxt notGood" empty + thing_inside -- => context is already set | otherwise = setSrcSpan fun_loc $ - do case fun_ctxt of + do traceTc "addHeadCtxt fun_loc" (ppr fun_loc) + case fun_ctxt of VAExpansion (OrigExpr orig) _ _ -> addExprCtxt orig thing_inside _ -> thing_inside where @@ -1640,6 +1643,7 @@ addExprCtxt :: HsExpr GhcRn -> TcRn a -> TcRn a addExprCtxt e thing_inside = case e of HsUnboundVar {} -> thing_inside + XExpr (ExpandedThingRn (OrigStmt stmt) _) -> addStmtCtxt (unLoc stmt) thing_inside _ -> addErrCtxt (exprCtxt e) thing_inside -- The HsUnboundVar special case addresses situations like -- f x = _ ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -1230,7 +1230,7 @@ setErrCtxt ctxt = updLclEnv (setLclEnvErrCtxt ctxt) -- do any tidying. addErrCtxt :: SDoc -> TcM a -> TcM a {-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt] -addErrCtxt msg thing_inside = dbgErrCtxt (addErrCtxtM (\env -> return (env, msg)) thing_inside) +addErrCtxt msg thing_inside = dbgErrCtxt msg (addErrCtxtM (\env -> return (env, msg)) thing_inside) -- | Add a message to the error context. This message may do tidying. addErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, SDoc)) -> TcM a -> TcM a @@ -1255,11 +1255,11 @@ pushCtxt :: ErrCtxt -> TcM a -> TcM a {-# INLINE pushCtxt #-} -- Note [Inlining addErrCtxt] pushCtxt ctxt = updLclEnv (updCtxt ctxt) -dbgErrCtxt :: TcM a -> TcM a -dbgErrCtxt thing_inside = +dbgErrCtxt :: SDoc -> TcM a -> TcM a +dbgErrCtxt msg thing_inside = do errCtxt <- getErrCtxt info <- mkErrInfo emptyTidyEnv errCtxt - traceTc "--Debug Error Context--" (ppr info) + traceTc "--Debug Error Context--" (vcat [ppr msg, text "----", ppr info, text "----"]) thing_inside updCtxt :: ErrCtxt -> TcLclEnv -> TcLclEnv @@ -1270,7 +1270,7 @@ updCtxt ctxt env | otherwise = addLclEnvErrCtxt ctxt env popErrCtxt :: TcM a -> TcM a -popErrCtxt thing_inside = dbgErrCtxt $ updLclEnv (\env -> setLclEnvErrCtxt (pop $ getLclEnvErrCtxt env) env) $ +popErrCtxt thing_inside = dbgErrCtxt (text "PopErrCtxt") $ updLclEnv (\env -> setLclEnvErrCtxt (pop $ getLclEnvErrCtxt env) env) $ thing_inside where pop [] = [] ===================================== testsuite/tests/ado/ado004.stderr ===================================== @@ -8,24 +8,24 @@ TYPE SIGNATURES test1c :: forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int test2 :: - forall {f :: * -> *} {t} {b}. - (Applicative f, Num t, Num b) => + forall {f :: * -> *} {b} {t}. + (Applicative f, Num b, Num t) => (t -> f b) -> f b test2a :: - forall {f :: * -> *} {t} {b}. - (Functor f, Num t, Num b) => + forall {f :: * -> *} {b} {t}. + (Functor f, Num b, Num t) => (t -> f b) -> f b test2b :: forall {f :: * -> *} {t} {a}. (Applicative f, Num t) => (t -> a) -> f a test2c :: - forall {f :: * -> *} {t} {b}. - (Functor f, Num t, Num b) => + forall {f :: * -> *} {b} {t}. + (Functor f, Num b, Num t) => (t -> f b) -> f b test2d :: - forall {f :: * -> *} {t} {b} {a}. - (Functor f, Num t, Num b) => + forall {f :: * -> *} {b} {t} {a}. + (Functor f, Num b, Num t) => (t -> f a) -> f b test3 :: forall {m :: * -> *} {t1} {t2} {a}. @@ -44,4 +44,4 @@ TYPE SIGNATURES (Monad m, Num (m a)) => (m a -> m (m a)) -> p -> m a Dependent modules: [] -Dependent packages: [base-4.16.0.0] +Dependent packages: [base-4.20.0.0] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bda953219ac72c667dcbd9f9fa73c0b70238441 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bda953219ac72c667dcbd9f9fa73c0b70238441 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 11:09:20 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 07:09:20 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 4 commits: Use IORef instead of MVar for symbol cache Message-ID: <66015b60620f2_630752ec7785549d@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: a04c1215 by Rodrigo Mesquita at 2024-03-25T10:43:43+00:00 Use IORef instead of MVar for symbol cache - - - - - 4f780458 by Rodrigo Mesquita at 2024-03-25T10:43:47+00:00 Revert "Use IORef instead of MVar for symbol cache" This reverts commit a04c121534b41850f248edfabf62727ed9e38305. - - - - - cadad5fe by Rodrigo Mesquita at 2024-03-25T11:01:59+00:00 Reapply "Use IORef instead of MVar for symbol cache" This reverts commit 4f78045848b742654a420f4a488aae749002e215. - - - - - 20d8dcdf by Rodrigo Mesquita at 2024-03-25T11:09:12+00:00 Improve debug message - - - - - 4 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/Types.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -674,7 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger - lookup_cache <- liftIO $ newMVar emptyUFM + lookup_cache <- liftIO $ newIORef emptyUFM -- Interpreter interp <- if ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -180,7 +180,7 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do case mb_ptr of Just ptr -> pure (Just ptr) Nothing -> go dlls - go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id" + go [] = panic "lookupHsSymbol: symbol " ++ show (ppr nm) ++ " not found in the loaded_dlls associated with this pkg_id (" ++ show (ppr pkgs_loaded) ++ ")" go loaded_dlls ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -491,7 +491,7 @@ withSymbolCache interp str determine_addr = do -- The analysis in #23415 further showed this cache should also benefit the -- internal interpreter's loading times, and needn't be used by the external -- interpreter only. - cache <- readMVar (interpLookupSymbolCache interp) + cache <- readIORef (interpLookupSymbolCache interp) case lookupUFM cache str of Just p -> return (Just p) Nothing -> do @@ -500,12 +500,12 @@ withSymbolCache interp str determine_addr = do case maddr of Nothing -> return Nothing Just p -> do - let cache' = addToUFM cache str p - modifyMVar_ (interpLookupSymbolCache interp) (const (pure cache')) + let upd_cache cache' = addToUFM cache' str p + _ <- atomicModifyIORef (interpLookupSymbolCache interp) (pure . upd_cache) return (Just p) purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = modifyMVar_ (interpLookupSymbolCache interp) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = atomicWriteIORef (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -40,6 +40,7 @@ import GHC.StgToJS.Types import GHC.StgToJS.Linker.Types import Control.Concurrent +import Data.IORef import System.Process ( ProcessHandle, CreateProcess ) import System.IO import GHC.Unit.Finder.Types (FinderCache, FinderOpts) @@ -52,7 +53,7 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader - , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + , interpLookupSymbolCache :: !(IORef (UniqFM FastString (Ptr ()))) -- ^ LookupSymbol cache } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/10ad50a248b98dc0e1f9a2973564492d0f0db292...20d8dcdf53b6fe31ec5e58bd5574f0b4818d7f04 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/10ad50a248b98dc0e1f9a2973564492d0f0db292...20d8dcdf53b6fe31ec5e58bd5574f0b4818d7f04 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 11:23:42 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 07:23:42 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] Improve debug message Message-ID: <66015ebef27d2_63075a91fc8641bc@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: c9058139 by Rodrigo Mesquita at 2024-03-25T11:23:33+00:00 Improve debug message - - - - - 1 changed file: - compiler/GHC/ByteCode/Linker.hs Changes: ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -180,7 +180,7 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do case mb_ptr of Just ptr -> pure (Just ptr) Nothing -> go dlls - go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id" + go [] = panic $ "lookupHsSymbol: symbol " ++ show (ppr nm) ++ " not found in the loaded_dlls associated with this pkg_id (" ++ show (ppr pkgs_loaded) ++ ")" go loaded_dlls View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c905813968a4be3d5b96cb07e43a3754d073409a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c905813968a4be3d5b96cb07e43a3754d073409a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 11:44:55 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 07:44:55 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] Improve debug message Message-ID: <660163b79c683_63076230c3472173@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 36ccd99d by Rodrigo Mesquita at 2024-03-25T11:44:44+00:00 Improve debug message - - - - - 1 changed file: - compiler/GHC/ByteCode/Linker.hs Changes: ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -180,7 +180,11 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do case mb_ptr of Just ptr -> pure (Just ptr) Nothing -> go dlls - go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id" + go [] = pprPanic "GHC.ByteCode.Linker.lookupHsSymbol" $ + text "symbol" + <+> ppr nm + <+> text "not found in the loaded_dlls associated with this pkg_id" + <+> parens (ppr pkgs_loaded) go loaded_dlls View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36ccd99d51a1fe1150d4ba4dc5eef992d436fa8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36ccd99d51a1fe1150d4ba4dc5eef992d436fa8f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 12:46:06 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 25 Mar 2024 08:46:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: NCG: Fix a bug in jump shortcutting. Message-ID: <6601720ece136_63077d5796884332@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - e6c5e010 by Cheng Shao at 2024-03-25T08:45:25-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 70398925 by Sylvain Henry at 2024-03-25T08:45:36-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 19 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Parser/Lexer.x - − docs/users_guide/9.10.1-notes.rst - + docs/users_guide/9.12.1-notes.rst - − docs/users_guide/9.6.1-notes.rst - − docs/users_guide/9.8.1-notes.rst - docs/users_guide/release-notes.rst - rts/ARMOutlineAtomicsSymbols.h - + testsuite/tests/codeGen/should_run/T24507.hs - + testsuite/tests/codeGen/should_run/T24507.stdout - + testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,15 +301,20 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] -jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] -jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] -jumpDestsOfInstr _ = [] +jumpDestsOfInstr i = case i of + (CBZ _ t) -> [ mkDest t ] + (CBNZ _ t) -> [ mkDest t ] + (J t) -> [ mkDest t ] + (B t) -> [ mkDest t ] + (BL t _ _) -> [ mkDest t ] + (BCOND _ t) -> [ mkDest t ] + _ -> [] + where + mkDest (TBlock id) = Just id + mkDest TLabel{} = Nothing + mkDest TReg{} = Nothing -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [dest] <- jumpDestsOfInstr (NE.last ins) + , [Just dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpDestsOfInstr instr + , [one] <- jumpBlockDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,6 +17,8 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString +import Data.Maybe (catMaybes) + -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -73,9 +75,17 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. + -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr + :: instr -> [Maybe BlockId] + + -- | Give the possible block destinations of this jump instruction. + -- Must be defined for all jumpish instructions. + jumpBlockDestsOfInstr :: instr -> [BlockId] + jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr + -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,12 +513,15 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [BlockId] +jumpDestsOfInstr :: Instr -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [id] - BCCFAR _ id _ -> [id] - BCTR targets _ _ -> [id | Just id <- targets] + BCC _ id _ -> [Just id] + BCCFAR _ id _ -> [Just id] + BCTR targets _ _ -> targets + BCTRL{} -> [Nothing] + BL{} -> [Nothing] + JMP{} -> [Nothing] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpDestsOfInstr instr + , targets <- jumpBlockDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpDestsOfInstr instrs + getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpDestsOfInstr) + $ map (mkUniqSet . jumpBlockDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpDestsOfInstr instr -- where we go from here + targets = jumpBlockDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,13 +672,16 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [BlockId] + -> [Maybe BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [id] - JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] + JXX _ id -> [Just id] + JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] _ -> [] + where + mkDest (DestBlockId id) = Just id + mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2870,7 +2870,7 @@ alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' unsafeChr :: Int -> Char -unsafeChr (I# c) = C# (chr# c) +unsafeChr (I# c) = GHC.Exts.C# (GHC.Exts.chr# c) -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) ===================================== docs/users_guide/9.10.1-notes.rst deleted ===================================== @@ -1,379 +0,0 @@ -.. _release-9-10-1: - -Version 9.10.1 -============== - -Language -~~~~~~~~ - -- The :extension:`GHC2024` language edition is now supported. It builds on top of - :extension:`GHC2021`, adding the following extensions: - - * :extension:`DataKinds` - * :extension:`DerivingStrategies` - * :extension:`DisambiguateRecordFields` - * :extension:`ExplicitNamespaces` - * :extension:`GADTs` - * :extension:`MonoLocalBinds` - * :extension:`LambdaCase` - * :extension:`RoleAnnotations` - - At the moment, :extension:`GHC2021` remains the default langauge edition that - is used when no other language edition is explicitly loaded (e.g. when running - ``ghc`` directly). Because language editions are not necessarily backwards - compatible, and future releases of GHC may change the default, it is highly - recommended to specify the language edition explicitly. - -- GHC Proposal `#281 `_ - "Visible forall in types of terms" has been partially implemented. - The following code is now accepted by GHC:: - - {-# LANGUAGE RequiredTypeArguments #-} - - vshow :: forall a -> Show a => a -> String - vshow t x = show (x :: t) - - s1 = vshow Int 42 -- "42" - s2 = vshow Double 42 -- "42.0" - - The use of ``forall a ->`` instead of ``forall a.`` indicates a *required* type - argument. A required type argument is visually indistinguishable from a value - argument but does not exist at runtime. - - This feature is guarded behind :extension:`RequiredTypeArguments`. - -- The :extension:`ExplicitNamespaces` extension can now be used in conjunction - with :extension:`RequiredTypeArguments` to select the type namespace in a - required type argument:: - - data T = T -- the name `T` is ambiguous - f :: forall a -> ... -- `f` expects a required type argument - - x1 = f T -- refers to the /data/ constructor `T` - x2 = f (type T) -- refers to the /type/ constructor `T` - -- With :extension:`LinearTypes`, ``let`` and ``where`` bindings can - now be linear. So the following now typechecks:: - - f :: A %1 -> B - g :: B %1 -> C - - h :: A %1 -> C - h x = g y - where - y = f x - -- Due to an oversight, previous GHC releases (starting from 9.4) allowed the use - of promoted data types in kinds, even when :extension:`DataKinds` was not - enabled. That is, GHC would erroneously accept the following code: :: - - {-# LANGUAGE NoDataKinds #-} - - import Data.Kind (Type) - import GHC.TypeNats (Nat) - - -- Nat shouldn't be allowed here without DataKinds - data Vec :: Nat -> Type -> Type - - This oversight has now been fixed. If you wrote code that took advantage of - this oversight, you may need to enable :extension:`DataKinds` in your code to - allow it to compile with GHC 9.10. - - For more information on what types are allowed in kinds, see the - :ref:`promotion` section. - -- Using ``forall`` as an identifier is now a parse error, as forewarned - by :ghc-flag:`-Wforall-identifier`:: - - forall :: (Variable a, MonadQSAT s m) => m a - -- parse error on input ‘forall’ - - Library authors are advised to use a different name for their functions, - such as ``forAll``, ``for_all``, or ``forall_``. - -- GHC Proposal `#65 `_ - "Require namespacing fixity declarations for type names and WARNING/DEPRECATED pragmas" has been partially implemented. - Now, with :extension:`ExplicitNamespaces` enabled, you can specify the - namespace of a name in fixity signatures, ``DEPRECATED`` and ``WARNING`` pragmas: :: - - type f $ a = f a - f $ a = f a - - infixl 9 type $ -- type-level $ is left-associative with priority 9 - infixr 0 data $ -- term-level $ is right-associative with priority 0 - - {-# DEPRECATED type D "Use `()` instead" #-} -- this will deprecate type D, but will not touch pattern synonym - data D = MkD - - {-# DEPRECATED data D "Use `MkD` instead" #-} -- this will deprecate pattern synonym only - pattern D = MkD - - pattern Head x <- (head -> x) - {-# WARNING in "x-partial" data Head [ "This is a partial synonym," - , "it throws an error on empty lists."] #-} - -- GHC Proposal `#475 `_ - "Non-punning list and tuple syntax" has been partially implemented. - When the newly introduced extension :extension:`ListTuplePuns` is disabled, - bracket syntax for lists, tuples and sums only denotes their data - constructors, while their type constructors have been changed to use regular - prefix syntax:: - - data List a = [] | a : List a - data Tuple2 a b = (a, b) - - The extension is enabled by default, establishing the usual behavior. - -- In accordance with GHC Proposal `#448 `_, - the :extension:`TypeAbstractions` extension has been extended to support - ``@``-binders in lambdas and function equations:: - - id :: forall a. a -> a - id @t x = x :: t - -- ^^ @-binder in a function equation - - e = higherRank (\ @t -> ... ) - -- ^^ @-binder in a lambda - - This feature is an experimental alternative to :extension:`ScopedTypeVariables`, - see the :ref:`type-abstractions-in-functions` section. - -Compiler -~~~~~~~~ - -- GHC Proposal `#516 - `_ - has been implemented. It introduces a warning :ghc-flag:`-Wincomplete-record-selectors` which warns about when - an invocation of a record selector may fail due to being applied to a constructor for which it is not defined. - - For example :: - - data T = T1 | T2 { x :: Int } - f :: T -> Int - f a = x a + 1 -- emit a warning here, since `f T1` will fail - - Unlike :ghc-flag:`-Wpartial-fields` this produces a warning about incomplete selectors at use sites instead of - definition sites, so it is useful in cases when the library does intend for incomplete record selectors to be - used but only in specific circumstances (e.g. when other cases are handled by previous pattern matches). - -- The :ghc-flag:`-finfo-table-map-with-stack` and - :ghc-flag:`-finfo-table-map-with-fallback` flags have been introduced. These - flags include ``STACK`` info tables and info tables with default source - location information in the info table map, respectively. They are implied by - the :ghc-flag:`-finfo-table-map` flag. The corresponding negative flags - (:ghc-flag:`-fno-info-table-map-with-stack`, - :ghc-flag:`-fno-info-table-map-with-fallback`) are useful for omitting these - info tables from the info table map and reducing the size of executables - containing info table profiling information. In a test on the `Agda codebase - `_, the size of the build results was reduced by - about 10% when these info tables were omitted. - -- Fixed a bug where compiling with both :ghc-flag:`-ddump-timings` and :ghc-flag:`-ddump-to-file` did not - suppress printing timings to the console. See :ghc-ticket:`20316`. - -- Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting - of multi-parameter type classes. See :ghc-ticket:`23832`. - -- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples - containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` - will no longer be considered small and therefore not unboxed by default under `-O` - even when used as strict field. :ghc-ticket:`22309`. - -- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling - for a 64bit platform. Even when generating code for a 32bit platform. - This makes core optimizations more consistent between 32bit and 64bit platforms - at the cost of slightly worse 32bit performance in edge cases. - -- Type abstractions in constructor patterns that were previously admitted without enabling the :extension:`TypeAbstractions` - extension now trigger a warning, :ghc-flag:`-Wdeprecated-type-abstractions`. - This new warning is part of the :ghc-flag:`-Wcompat` warning group and will become an error in a future GHC release. - -- The :ghc-flag:`-Wforall-identifier` flag is now deprecated and removed from :ghc-flag:`-Wdefault`, - as ``forall`` is no longer parsed as an identifier. - -- Late plugins have been added. These are plugins which can access and/or modify - the core of a module after optimization and after interface creation. See :ghc-ticket:`24254`. - -- If you use :ghc-flag:`-fllvm` we now use an assembler from the LLVM toolchain rather than - the preconfigured assembler. This is typically ``clang``. The ``LLVMAS`` environment - variable can be specified at configure time to instruct GHC which ``clang`` to use. - This means that if you are using ``-fllvm`` you now need ``llc``, ``opt`` and ``clang`` - available. - -- The :ghc-flag:`-fprof-late-overloaded` flag has been introduced. It causes - cost centres to be added to *overloaded* top level bindings, unlike - :ghc-flag:`-fprof-late` which adds cost centres to all top level bindings. - -- The :ghc-flag:`-fprof-late-overloaded-calls` flag has been introduced. It - causes cost centres to be inserted at call sites including instance dictionary - arguments. This may be preferred over :ghc-flag:`-fprof-late-overloaded` since - it may reveal whether imported functions are called overloaded. - -JavaScript backend -~~~~~~~~~~~~~~~~~~ - -- The JavaScript backend now supports linking with C sources. It uses Emscripten - to compile them to WebAssembly. The resulting JS file embeds and loads these - WebAssembly files. Important note: JavaScript wrappers are required to call - into C functions and pragmas have been added to indicate which C functions are - exported (see the users guide). - -WebAssembly backend -~~~~~~~~~~~~~~~~~~~ - -- The wasm backend now implements JavaScript FFI, allowing JavaScript - to be called from Haskell and vice versa when targetting JavaScript - environments like browsers and node.js. See :ref:`JavaScript FFI in - the wasm backend ` for details. - -GHCi -~~~~ - -- GHCi now differentiates between adding, unadding, loading, unloading and reloading - in its responses to using the respective commands. The output with `-fshow-loaded-modules` - is not changed to keep backwards compatibility for tooling. - -Runtime system -~~~~~~~~~~~~~~ - -- Internal fragmentation incurred by the non-moving GC's allocator has been reduced for small objects. - In one real-world application, this has reduced resident set size by about 20% and modestly improved run-time. - See :ghc-ticket:`23340`. - :rts-flag:`--nonmoving-dense-allocator-count=⟨count⟩` has been added to fine-tune this behaviour. -- Add support for heap profiling with the non-moving GC. - See :ghc-ticket:`22221`. - -- Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on - startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``. - -- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual - memory address space reserved by the two step allocator on a 64-bit - platform. The default size is now 1T on aarch64 as well. See - :ghc-ticket:`24498`. - -``base`` library -~~~~~~~~~~~~~~~~ - -- Updated to `Unicode 15.1.0 `_. - -- The functions :base-ref:`GHC.Exts.dataToTag#` and - :base-ref:`GHC.Base.getTag` have had their types changed to the - following: - - :: - - dataToTag#, getTag - :: forall {lev :: Levity} (a :: TYPE (BoxedRep lev)) - . DataToTag a => a -> Int# - - In particular, they are now applicable only at some (not all) - lifted types. However, if ``t`` is an algebraic data type (i.e. ``t`` - matches a ``data`` or ``data instance`` declaration) with all of its - constructors in scope and the levity of ``t`` is statically known, - then the constraint ``DataToTag t`` can always be solved. - -- Exceptions can now carry arbitrary user-defined annotations via the new - :base-ref:`GHC.Exception.Type.ExceptionContext` implicit parameter of - ``SomeException``. These annotations are intended to be used to carry - context describing the provenance of an exception. - -- GHC now collects backtraces for synchronous exceptions. These are carried by - the exception via the ``ExceptionContext`` mechanism described above. - GHC supports several mechanisms by which backtraces can be collected which - can be individually enabled and disabled via - :base-ref:`GHC.Exception.Backtrace.setEnabledBacktraceMechanisms`. - - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -- ``dataToTag#`` has been moved from ``GHC.Prim``. It remains - exported by ``GHC.Exts``, but with a different type, as described in - the notes for ``base`` above. - -- New primops for unaligned ``Addr#`` access. - These primops will be emulated on platforms that don't support unaligned access. - These primops take the form - - .. code-block:: haskell - - indexWord8OffAddrAs :: Addr# -> Int# -> # - readWord8OffAddrAs :: Addr# -> Int# -> State# s -> (# State# s, # #) - writeWord8OffAddrAs :: Addr# -> Int# -> # -> State# s -> State# s - - where ```` is one of: - - - ``Word`` - - ``Word{16,32,64}`` - - ``Int`` - - ``Int{16,32,64,}`` - - ``Char`` - - ``WideChar`` - - ``Addr`` - - ``Float`` - - ``Double`` - - ``StablePtr`` - -``ghc`` library -~~~~~~~~~~~~~~~ - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - -``ghc-experimental`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- ``ghc-experimental`` is a new library for functions and data types with - weaker stability guarantees. Introduced per the HF Technical Proposal `#51 - `_. - -``template-haskell`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Extend ``Pat`` with ``TypeP`` and ``Exp`` with ``TypeE``, - introduce functions ``typeP`` and ``typeE`` (Template Haskell support for GHC Proposal `#281 - `_). - -Included libraries -~~~~~~~~~~~~~~~~~~ - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -0,0 +1,88 @@ +.. _release-9-11-1: + +Version 9.12.1 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. See the `migration guide +`_ on the GHC Wiki +for specific guidance on migrating programs to this release. + +Language +~~~~~~~~ + + +Compiler +~~~~~~~~ + + +GHCi +~~~~ + + +Runtime system +~~~~~~~~~~~~~~ + +``base`` library +~~~~~~~~~~~~~~~~ + + +``ghc-prim`` library +~~~~~~~~~~~~~~~~~~~~ + +``ghc`` library +~~~~~~~~~~~~~~~ + +``ghc-heap`` library +~~~~~~~~~~~~~~~~~~~~ + +``ghc-experimental`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``template-haskell`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Included libraries +~~~~~~~~~~~~~~~~~~ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + libraries/os-string/os-string.cabal: Dependency of ``filepath`` library ===================================== docs/users_guide/9.6.1-notes.rst deleted ===================================== @@ -1,267 +0,0 @@ -.. _release-9-6-1: - -Version 9.6.1 -============== - -Language -~~~~~~~~ - -- GHC is now more conservative when solving constraints that arise from - superclass expansion in terms of other constraints that also arise from - superclass expansion. - - For example: :: - - class C a - class C a => D a b - instance D a a => D a b - - When typechecking the instance, we need to also solve the constraints arising - from the superclasses of ``D``; in this case, we need ``C a``. We could obtain - evidence for this constraint by expanding the superclasses of the context, - as ``D a a`` also has a superclass context of ``C a``. - However, is it unsound to do so in general, as we might be assuming precisely - the predicate we want to prove! This can lead to programs that loop at runtime. - - When such potentially-loopy situations arise, GHC now emits a warning. - In future releases, this behaviour will no longer be supported, and the - typechecker will outright refuse to solve these constraints, emitting a - ``Could not deduce`` error. - - In practice, you should be able to fix these issues by adding the necessary - constraint to the context, e.g. for the above example: :: - - instance (C a, D a a) => D a b - -- Record updates for GADTs and other existential datatypes are now - fully supported. - - For example: :: - - data D b where - MkD :: { fld1 :: a -> a, fld2 :: a -> (), fld3 :: b } -> D b - - foo :: D b -> D b - foo d = d { fld1 = id, fld2 = const () } - - In this example, we have an existential variable ``a``, and we update - all fields whose type involves ``a`` at once, so the update is valid. - - A side-effect of this change is that GHC now rejects some record updates - involving fields whose types contain type families (these record updates - were previously erroneously accepted). - - Example: :: - - type family F a where - F Int = Char - F Float = Char - - data T b = MkT { x :: [Int], y :: [F b] } - - emptyT :: forall b. T b - emptyT = MkT [] [] - - bar :: T Int - bar = emptyT { x = [3] } - - In this example, we can't infer the type of ``emptyT`` in ``bar``: it could be - ``T Int``, but it could also be ``T Float`` because the type family ``F`` - is not injective and ``T Float ~ T Int``. Indeed, the following typechecks :: - - baz :: T Int - baz = case ( emptyT :: T Float ) of { MkT _ y -> MkT [3] y } - - This means that the type of ``emptyT`` is ambiguous in the definition - of ``bar`` above, and thus GHC rejects the record update: :: - - Couldn't match type `F b0' with `Char' - Expected: [F Int] - Actual: [F b0] - NB: ‘F’ is a non-injective type family - The type variable ‘b0’ is ambiguous - - To fix these issues, add a type signature to the expression that the - record update is applied to (``emptyT`` in the example above), or - add an injectivity annotation to the type family in the case that - the type family is in fact injective. - -- Error messages are now assigned unique error codes, of the form ``[GHC-12345]``. - -- GHC Proposal `#106 - `_ - has been implemented, introducing a new language extension - :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. - -- GHC proposal `#170 Unrestricted OverloadedLabels - `_ - has been implemented. - This extends the variety syntax for constructing labels under :extension:`OverloadedLabels`. - Examples of newly allowed syntax: - - Leading capital letters: `#Foo` equivalant to `getLabel @"Foo"` - - Numeric characters: `#1728` equivalent to `getLabel @"1728"` - - Arbitrary strings: `#"Hello, World!"` equivalent to `getLabel @"Hello, World!"` - -Compiler -~~~~~~~~ - -- The `WebAssembly backend - `_ - has been merged. This allows GHC to be built as a cross-compiler - that targets ``wasm32-wasi`` and compiles Haskell code to - self-contained WebAssembly modules that can be executed on a variety - of different runtimes. There are a few caveats to be aware of: - - - To use the WebAssembly backend, one would need to follow the - instructions on `ghc-wasm-meta - `_. The WebAssembly - backend is not included in the GHC release bindists for the time - being, nor is it supported by ``ghcup`` or ``stack`` yet. - - The WebAssembly backend is still under active development. It's - presented in this GHC version as a technology preview, bugs and - missing features are expected. - -- The JavaScript backend has been merged. GHC is now able to be built as a - cross-compiler targeting the JavaScript platform. The backend should be - considered a technology preview. As such it is not ready for use in - production, is not distributed in the GHC release bindists and requires the - user to manually build GHC as a cross-compiler. See the JavaScript backend - `wiki `_ page - on the GHC wiki for the current status, project roadmap, build instructions - and demos. - -- 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 ``:``). - -- The :ghc-flag:`-Wstar-is-type` warning is now enabled by default. - -- The 32bit x86 NCG backend will now generate inline assembly for most common 64bit - operations. This improves Int64/Word64 performance substantially on this platform. - -GHCi -~~~~ - -- GHCi will now accept any file-header pragmas it finds, such as - ``{-# OPTIONS_GHC ... #-}`` and ``{-# LANGUAGE ... #-}`` (see :ref:`pragmas`). For example, - instead of using :ghci-cmd:`:set` to enable :ghc-flag:`-Wmissing-signatures`, - you could instead write: - - .. code-block:: none - - ghci> {-# OPTIONS_GHC -Wmissing-signatures #-} - -This can be convenient when pasting large multi-line blocks of code into GHCi. - -Runtime system -~~~~~~~~~~~~~~ - -- The `Delimited continuation primops `_ - proposal has been implemented, adding native support for first-class, - delimited continuations to the RTS. For the reasons given in the proposal, - 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.Prim`` for more details. - -- The behaviour of the ``-M`` flag has been made more strict. It will now trigger - a heap overflow if the total amount of memory used by the Haskell heap exceeds the limit. - Previously only live blocks were taken into account. - This makes it more likely to trigger promptly when the heap is highly fragmented. - -- Fixed a bug that sometimes caused live sparks to be GC'ed too early either during - minor GC or major GC with workstealing disabled. See #22528. - - -``base`` library -~~~~~~~~~~~~~~~~ - -- Exceptions thrown by weak pointer finalizers can now be reported by setting - a global exception handler, using ``GHC.Weak.Finalize.setFinalizerExceptionHandler``. - The default behaviour is unchanged (exceptions are ignored and not reported). - -- GHC now provides a set of operations for introspecting on the threads of a - program, ``GHC.Conc.listThreads``, as well as operations for querying a thread's - label (:base-ref:`GHC.Conc.Sync.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 - -- Updated to `Unicode 15.0.0 `_. - -- Add standard Unicode case predicates :base-ref:`Data.Char.isUpperCase` and - :base-ref:`Data.Char.isLowerCase`. These predicates use the standard Unicode - case properties and are more intuitive than :base-ref:`Data.Char.isUpper` and - :base-ref:`Data.Char.isLower`. - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -``ghc`` library -~~~~~~~~~~~~~~~ - -- Add `Foreign.C.Types.ConstPtr` was added to encode ``const``-qualified pointer return - types in foreign declarations when using ``CApiFFI`` extension. - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - - -Included libraries ------------------- - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/9.8.1-notes.rst deleted ===================================== @@ -1,334 +0,0 @@ -.. _release-9-8-1: - -Version 9.8.1 -============= - -Language -~~~~~~~~ - -- There is a new extension :extension:`ExtendedLiterals`, which enables - sized primitive literals, e.g. ``123#Int8`` is a literal of type ``Int8#``. - See the GHC proposal `#451 `_. - Derived ``Show`` instances for datatypes containing sized literals (``Int8#``, ``Word8#``, ``Int16#`` etc.) - now use the extended literal syntax, per GHC proposal `#596 `_. - Furthermore, it is now possible to derive ``Show`` for datatypes containing - fields of types ``Int64#`` and ``Word64#``. - -- GHC Proposal `#425 - `_ - has been partially implemented. Namely, the ``@k``-binders in type declarations are now permitted:: - - type T :: forall k. k -> forall j. j -> Type - data T @k (a :: k) @(j :: Type) (b :: j) - - This feature is guarded behind :extension:`TypeAbstractions`. - -- In accordance with GHC proposal `#425 - `_ - GHC no longer implicitly quantifies over type variables that appear only in the RHS of type and - data family instances. This code will no longer work: :: - - type family F1 a :: k - type instance F1 Int = Any :: j -> j - - Instead you should write:: - - type instance F1 @(j -> j) Int = Any :: j -> j - - Or:: - - type instance forall j . F1 Int = Any :: j -> j - -- GHC proposal `#475 `_ - has been partially implemented. Namely, tuple data types, which were previously represented using a brackets-with-commas - syntax form ((), (,), (,,), and so on) have been renamed to common names of the form ``Unit``, ``Tuple2``, ``Tuple3``, - and so on, where the number after ``Tuple`` indicates its arity: :: - - data Unit = () - - data Tuple2 a b = (a,b) - data Tuple3 a b c = (a, b, c) - -- and so on, up to Tuple64 - - For consistency, we also introduce type aliases: :: - - type Tuple0 = Unit - type Tuple1 = Solo - - The renamed tuple data types and the new type aliases can be found in the ``GHC.Tuple`` module. This renaming - does not break existing code that directly uses tuple data types, but it does affect tools and libraries - that have access to the data type names, such as ``Generic`` and Template Haskell. - -Compiler -~~~~~~~~ - -- Added a new warning :ghc-flag:`-Wterm-variable-capture` that helps to make code compatible with - the future extension ``RequiredTypeArguments``. - -- Rewrite rules now support a limited form of higher order matching when a - pattern variable is applied to distinct locally bound variables. For example: :: - - forall f. foo (\x -> f x) - - Now matches: :: - - foo (\x -> x*2 + x) - -- GHC Proposal `#496 - `_ - has been implemented, allowing ``{..}`` syntax for constructors without fields, for consistency. - This is convenient for TH code generation, as you can now uniformly use record wildcards - regardless of number of fields. - -- Incoherent instance applications are no longer specialised. The previous implementation of - specialisation resulted in nondeterministic instance resolution in certain cases, breaking - the specification described in the documentation of the `INCOHERENT` pragma. See :ghc-ticket:`22448` for further details. - -- Fix a bug in TH causing excessive calls to ``setNumCapabilities`` when ``-j`` is greater than ``-N``. - See :ghc-ticket:`23049`. - -- The ``-Wno-⟨wflag⟩``, ``-Werror=⟨wflag⟩`` and ``-Wwarn=⟨wflag⟩`` options are - now defined systematically for all warning groups (for example, - ``-Wno-default``, ``-Werror=unused-binds`` and ``-Wwarn=all`` are now - accepted). See :ref:`options-sanity`. - -- ``WARNING`` pragmas may now be annotated with a category, following - `GHC proposal #541 `_, in which case they are controlled with new - ``-Wx-⟨category⟩`` flags rather than :ghc-flag:`-Wdeprecations`. - A new warning group :ghc-flag:`-Wextended-warnings` includes all such warnings - regardless of category. See :ref:`warning-deprecated-pragma`. - -- GHC is now better at disambiguating record updates in the presence of duplicate - record fields. The following program is now accepted :: - - {-# LANGUAGE DuplicateRecordFields #-} - - data R = MkR1 { foo :: Int } - | MkR2 { bar :: Int } - - data S = MkS { foo :: Int, bar :: Int } - - blah x = x { foo = 5, bar = 6 } - - The point is that only the type S has a constructor with both fields "foo" - and "bar", so this record update is unambiguous. - -- Data types with ``deriving`` clauses now reject inferred instance contexts - that mention ``TypeError`` constraints (see :ref:`custom-errors`), such as - this one: :: - - newtype Foo = Foo Int - - class Bar a where - bar :: a - - instance (TypeError (Text "Boo")) => Bar Foo where - bar = undefined - - newtype Baz = Baz Foo - deriving Bar - - Here, the derived ``Bar`` instance for ``Baz`` would look like this: :: - - instance TypeError (Text "Boo") => Bar Baz - - While GHC would accept this before, GHC 9.8 now rejects it, emitting "``Boo``" - in the resulting error message. If you really want to derive this instance and - defer the error to sites where the instance is used, you must do so manually - with :extension:`StandaloneDeriving`, e.g. :: - - deriving instance TypeError (Text "Boo") => Bar Baz - -- GHC Proposal `#540 `_ has been implemented. - This adds the `-jsem`:ghc-flag: flag, which instructs GHC to act as a jobserver client. - This enables multiple GHC processes running at once to share system resources - with each other, communicating via the system semaphore specified by - the flag argument. - -- GHC Proposal `#433 - `_ - has been implemented. This adds the class ``Unsatisfiable :: ErrorMessage -> Constraint`` - to the ``GHC.TypeError`` module. Constraints of the form ``Unsatisfiable msg`` - provide a mechanism for custom type errors that reports the errors in a more - predictable behaviour than ``TypeError``, as these constraints are - handled purely during constraint solving. - - For example: :: - - instance Unsatisfiable (Text "There is no Eq instance for functions") => Eq (a -> b) where - (==) = unsatisfiable - - This allows errors to be reported when users use the instance, even when - type errors are being deferred. - -- GHC is now deals "insoluble Givens" in a consistent way. For example: :: - - k :: (Int ~ Bool) => Int -> Bool - k x = x - - GHC used to accept the contradictory ``Int~Bool`` in the type signature, but reject the ``Int~Bool`` constraint that arises from typechecking the definition itself. Now it accepts both. More details in `GHC ticket #23413 `_, which gives examples of the previous inconsistency. GHC now implements the "PermissivePlan" described in that ticket. - -- The `-ddump-spec` flag has been split into `-ddump-spec` and - `-ddump-spec-constr`, allowing only output from the typeclass specialiser or - `SpecConstr` to be seen if desired. - -- The compiler may now be configured to compress the debugging information - included in :ghc-flag:`-finfo-table-map` enabled binaries. To do so, one must - build GHC from source (see - `here` for directions) - and supply the ``--enable-ipe-data-compression`` flag to the ``configure`` - script. **Note**: This feature requires that the machine building GHC has - `libzstd `_ version 1.4.0 or greater - installed. The compression library `libzstd` may optionally be statically - linked in the resulting compiler (on non-darwin machines) using the - ``--enable-static-libzstd`` configure flag. - - In a test compiling GHC itself, the size of the :ghc-flag:`-finfo-table-map` - enabled build results was reduced by over 20% when compression was enabled. - -- GHC Proposal `#134 - `_ - has been implemented. This makes it possible to deprecate certain names exported from a module, without deprecating - the name itself. You can check the full specification of the feature at :ref:`warning-deprecated-pragma`. - - For example :: - - module X ( - {-# WARNING "do not use that constructor" D(D1), - D(D2) - ) - data D = D1 | D2 - - This allows for changing the structure of a library without immediately breaking user code, - but instead being able to warn the user that a change in the library interface - will occur in the future. - -- Guard polymorphic specialisation behind the flag :ghc-flag:`-fpolymorphic-specialisation`. - This optimisation has led to a number of incorrect runtime result bugs, so we are disabling it - by default for now whilst we consider more carefully an appropriate fix. - (See :ghc-ticket:`23469`, :ghc-ticket:`23109`, :ghc-ticket:`21229`, :ghc-ticket:`23445`) - -- The warning about incompatible command line flags can now be controlled with the - :ghc-flag:`-Winconsistent-flags`. In particular this allows you to silence a warning - when using optimisation flags with :ghc-flag:`--interactive` mode. - -GHCi -~~~~ - -- The deprecated `:ctags` and `:etags` GHCi commands have been removed. See this `wiki page `_ if you want to add a macro to recover similar functionality. - -Runtime system -~~~~~~~~~~~~~~ - -- On POSIX systems that support timerfd, RTS shutdown no longer has to wait for - the next RTS 'tick' to occur before continuing the shutdown process. See :ghc-ticket:`22692`. - -``base`` library -~~~~~~~~~~~~~~~~ - -- ``Data.Tuple`` now exports ``getSolo :: Solo a -> a``. - -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ - -- Primitive pointer comparison functions are now levity-polymorphic, e.g. :: - - sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# - - This change affects the following functions: - - - ``sameArray#``, ``sameMutableArray#``, - - ``sameSmallArray#``, ``sameSmallMutableArray#``, - - ``sameMutVar#``, ``sameTVar#``, ``sameMVar#`` - - ``sameIOPort#``, ``eqStableName#``. - -- New primops for fused multiply-add operations. These primops combine a - multiplication and an addition, compiling to a single instruction when - the ``-mfma`` flag is enabled and the architecture supports it. - - The new primops are ``fmaddFloat#, fmsubFloat#, fnmaddFloat#, fnmsubFloat# :: Float# -> Float# -> Float# -> Float#`` - and ``fmaddDouble#, fmsubDouble#, fnmaddDouble#, fnmsubDouble# :: Double# -> Double# -> Double# -> Double#``. - - These implement the following operations, while performing one single - rounding at the end, leading to a more accurate result: - - - ``fmaddFloat# x y z``, ``fmaddDouble# x y z`` compute ``x * y + z``. - - ``fmsubFloat# x y z``, ``fmsubDouble# x y z`` compute ``x * y - z``. - - ``fnmaddFloat# x y z``, ``fnmaddDouble# x y z`` compute ``- x * y + z``. - - ``fnmsubFloat# x y z``, ``fnmsubDouble# x y z`` compute ``- x * y - z``. - - Warning: on unsupported architectures, the software emulation provided by - the fallback to the C standard library is not guaranteed to be IEEE-compliant. - -``ghc`` library -~~~~~~~~~~~~~~~ - -- The ``RecordUpd`` constructor of ``HsExpr`` now takes an ``HsRecUpdFields`` - instead of ``Either [LHsRecUpdField p] [LHsRecUpdProj p]``. - Instead of ``Left ..``, use the constructor ``RegularRecUpdFields``, and instead - of ``Right ..``, use the constructor ``OverloadedRecUpdFields``. - -- The ``loadWithCache`` function now takes an extra argument which allows API users - to embed GHC diagnostics in their own diagnostic type before they are printed. - This allows how messages are rendered and explained to users to be modified. - We use this functionality in GHCi to modify how some messages are displayed. - -- The extensions fields of constructors of ``IE`` now take ``Maybe (WarningTxt p)`` - in ``GhcPs`` and ``GhcRn`` variants of the Syntax Tree. - This represents the warning assigned to a certain export item, - which is used for deprecated exports (see :ref:`warning-deprecated-pragma`). - -``ghc-heap`` library -~~~~~~~~~~~~~~~~~~~~ - -``template-haskell`` library -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Record fields now belong to separate ``NameSpace``s, keyed by the parent of - the record field. This is the name of the first constructor of the parent type, - even if this constructor does not have the field in question. - This change enables TemplateHaskell support for ``DuplicateRecordFields``. - -Included libraries ------------------- - -The package database provided with this distribution also contains a number of -packages other than GHC itself. See the changelogs provided with these packages -for further change information. - -.. ghc-package-list:: - - libraries/array/array.cabal: Dependency of ``ghc`` library - libraries/base/base.cabal: Core library - libraries/binary/binary.cabal: Dependency of ``ghc`` library - libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library - libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility - libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility - libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library - libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library - libraries/directory/directory.cabal: Dependency of ``ghc`` library - libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library - libraries/filepath/filepath.cabal: Dependency of ``ghc`` library - compiler/ghc.cabal: The compiler itself - libraries/ghci/ghci.cabal: The REPL interface - libraries/ghc-boot/ghc-boot.cabal: Internal compiler library - libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library - libraries/ghc-compact/ghc-compact.cabal: Core library - libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library - libraries/ghc-prim/ghc-prim.cabal: Core library - libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable - libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable - libraries/integer-gmp/integer-gmp.cabal: Core library - libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library - libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library - libraries/pretty/pretty.cabal: Dependency of ``ghc`` library - libraries/process/process.cabal: Dependency of ``ghc`` library - libraries/stm/stm.cabal: Dependency of ``haskeline`` library - libraries/template-haskell/template-haskell.cabal: Core library - libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library - libraries/text/text.cabal: Dependency of ``Cabal`` library - libraries/time/time.cabal: Dependency of ``ghc`` library - libraries/transformers/transformers.cabal: Dependency of ``ghc`` library - libraries/unix/unix.cabal: Dependency of ``ghc`` library - libraries/Win32/Win32.cabal: Dependency of ``ghc`` library - libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,4 +4,4 @@ Release notes .. toctree:: :maxdepth: 1 - 9.10.1-notes + 9.12.1-notes ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } ===================================== testsuite/tests/codeGen/should_run/T24507.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module Main where + +import GHC.Exts + +foreign import prim "foo" foo :: Int# -> Int# + +main = do + + let f x = case x of I# x' -> case foo x' of x -> print (I# x) + mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout ===================================== @@ -0,0 +1,7 @@ +1 +2 +2 +2 +2 +2 +2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm ===================================== @@ -0,0 +1,35 @@ +#include "Cmm.h" + +bar() { + return (2); +} + +foo(W_ x) { + + switch(x) { + case 1: goto a; + case 2: goto b; + case 3: goto c; + case 4: goto d; + case 5: goto e; + case 6: goto f; + case 7: goto g; + } + return (1); + + a: + return (1); + b: + jump bar(); + c: + jump bar(); + d: + jump bar(); + e: + jump bar(); + f: + jump bar(); + g: + jump bar(); + +} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) + +test('T24507', [req_cmm], multi_compile_and_run, + ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/646d254a2a64f26db6638ea2c4ef78a434b7e967...70398925624c2fc615db98eab4ba337e7099d01f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/646d254a2a64f26db6638ea2c4ef78a434b7e967...70398925624c2fc615db98eab4ba337e7099d01f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 14:09:36 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 10:09:36 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 48 commits: Fix sharing of 'IfaceTyConInfo' during core to iface type translation Message-ID: <660185a0dc6b1_6307a5a85989822d@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 5675db20 by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - 504a423c by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 Start writing test - - - - - c15d4e02 by Alexis King at 2024-03-25T12:02:49+00:00 wip: avoid linear search when looking up Haskell symbols via dlsym - - - - - 5aaba681 by Alexis King at 2024-03-25T12:02:49+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - 87c04936 by Alexis King at 2024-03-25T12:02:49+00:00 wip: use loadNativeObj to implement addDLL - - - - - c3611746 by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - 8781b2c2 by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 Fail if no symbol is found in the relevant DLLs - - - - - b352a3f7 by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - b68654ae by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 Use lookupHsSymbol for PrimOps too - - - - - 20a9eb0a by Rodrigo Mesquita at 2024-03-25T12:02:49+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - 5752e9e3 by Rodrigo Mesquita at 2024-03-25T14:09:26+00:00 Improve debug message - - - - - 21c547e2 by Rodrigo Mesquita at 2024-03-25T14:09:27+00:00 WIP - - - - - 4be79c71 by Rodrigo Mesquita at 2024-03-25T14:09:27+00:00 Simplify MVar operations used - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - + T23415/Makefile - + T23415/main.hs - + T23415/make_shared_libs.sh - + T23415/new-main.hs - + T23415/run_test.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/Unify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36ccd99d51a1fe1150d4ba4dc5eef992d436fa8f...4be79c71e5819015de9332c704f5f4d7cc7380b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36ccd99d51a1fe1150d4ba4dc5eef992d436fa8f...4be79c71e5819015de9332c704f5f4d7cc7380b2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 14:27:20 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 10:27:20 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 3 commits: Improve debug message Message-ID: <660189c89e76b_6307ab874b41039b5@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 5c11c646 by Rodrigo Mesquita at 2024-03-25T14:27:10+00:00 Improve debug message - - - - - dbf4ae7e by Rodrigo Mesquita at 2024-03-25T14:27:10+00:00 WIP - - - - - bdc1bc89 by Rodrigo Mesquita at 2024-03-25T14:27:10+00:00 Simplify MVar operations used - - - - - 4 changed files: - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Interpreter.hs Changes: ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -180,7 +180,13 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do case mb_ptr of Just ptr -> pure (Just ptr) Nothing -> go dlls - go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id" + go [] = pprPanic "GHC.ByteCode.Linker.lookupHsSymbol" $ + text "name" + <+> ppr nm + <+> parens (text "symbol" <+> ppr sym_to_find) + <+> text "not found in the loaded_dlls associated with this pkg_id" + <+> parens (ppr pkg_id) <> text ":" + $$ ppr (lookupUDFM pkgs_loaded pkg_id) go loaded_dlls ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -223,6 +223,7 @@ loadDependencies -> [Module] -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required loadDependencies interp hsc_env pls span needed_mods = do + putStrLn "Start loading dependencies" -- initLoaderState (hsc_dflags hsc_env) dl let opts = initLinkDepsOpts hsc_env @@ -240,6 +241,7 @@ loadDependencies interp hsc_env pls span needed_mods = do | pkg_id <- uniqDSetToList this_pkgs_needed , Just pkg <- [lookupUDFM all_pkgs_loaded pkg_id] ]) + putStrLn "Finished loading dependencies" return (pls2, succ, ldAllLinkables deps, this_pkgs_loaded) ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -148,7 +148,7 @@ data LoadedPkgInfo , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] - -- ^ TODO: write Note + -- ^ See Note [Dynamically Loading Symbols] , loaded_pkg_trans_deps :: UniqDSet UnitId } ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -500,12 +500,12 @@ withSymbolCache interp str determine_addr = do case maddr of Nothing -> return Nothing Just p -> do - let cache' = addToUFM cache str p - modifyMVar_ (interpLookupSymbolCache interp) (const (pure cache')) + let upd_cache cache' = addToUFM cache' str p + modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache) return (Just p) purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = modifyMVar_ (interpLookupSymbolCache interp) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4be79c71e5819015de9332c704f5f4d7cc7380b2...bdc1bc89f31e87ff201e9d8825202b4a7eb43727 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4be79c71e5819015de9332c704f5f4d7cc7380b2...bdc1bc89f31e87ff201e9d8825202b4a7eb43727 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 14:37:38 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 25 Mar 2024 10:37:38 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] add flavour into OrigStmt to guide better error messages about qualified do. Message-ID: <66018c3299503_6307b107ccc1042a9@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: 0047f94e by Apoorv Ingle at 2024-03-25T09:37:28-05:00 add flavour into OrigStmt to guide better error messages about qualified do. - - - - - 8 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Types/Origin.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -476,7 +476,7 @@ type instance XXExpr GhcTc = XXExprGhcTc -- | The different source constructs that we use to instantiate the "original" field -- in an `XXExprGhcRn original expansion` data HsThingRn = OrigExpr (HsExpr GhcRn) - | OrigStmt (ExprLStmt GhcRn) + | OrigStmt (ExprLStmt GhcRn) HsDoFlavour | OrigPat (LPat GhcRn) isHsThingRnExpr, isHsThingRnStmt, isHsThingRnPat :: HsThingRn -> Bool @@ -522,9 +522,10 @@ mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (OrigExpr oExpr) eExpr) -- expanded expression mkExpandedStmt :: ExprLStmt GhcRn -- ^ source statement + -> HsDoFlavour -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn' -mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (OrigStmt oStmt) eExpr) +mkExpandedStmt oStmt flav eExpr = XExpr (ExpandedThingRn (OrigStmt oStmt flav) eExpr) mkExpandedPatRn :: LPat GhcRn -- ^ source pattern @@ -538,17 +539,19 @@ mkExpandedPatRn oPat eExpr = XExpr (ExpandedThingRn (OrigPat oPat) eExpr) mkExpandedStmtAt :: SrcSpanAnnA -- ^ Location for the expansion expression -> ExprLStmt GhcRn -- ^ source statement + -> HsDoFlavour -> HsExpr GhcRn -- ^ expanded expression -> LHsExpr GhcRn -- ^ suitably wrapped located 'XXExprGhcRn' -mkExpandedStmtAt loc oStmt eExpr = L loc $ mkExpandedStmt oStmt eExpr +mkExpandedStmtAt loc oStmt flav eExpr = L loc $ mkExpandedStmt oStmt flav eExpr -- | Wrap the expanded version of the expression with a pop. mkExpandedStmtPopAt :: SrcSpanAnnA -- ^ Location for the expansion statement -> ExprLStmt GhcRn -- ^ source statement + -> HsDoFlavour -> HsExpr GhcRn -- ^ expanded expression -> LHsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn' -mkExpandedStmtPopAt loc oStmt eExpr = mkPopErrCtxtExprAt loc $ mkExpandedStmtAt loc oStmt eExpr +mkExpandedStmtPopAt loc oStmt flav eExpr = mkPopErrCtxtExprAt loc $ mkExpandedStmtAt loc oStmt flav eExpr data XXExprGhcTc @@ -593,9 +596,10 @@ mkExpandedExprTc oExpr eExpr = XExpr (ExpandedThingTc (OrigExpr oExpr) eExpr) -- expanded typechecked expression. mkExpandedStmtTc :: ExprLStmt GhcRn -- ^ source do statement + -> HsDoFlavour -> HsExpr GhcTc -- ^ expanded typechecked expression -> HsExpr GhcTc -- ^ suitably wrapped 'XXExprGhcRn' -mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (OrigStmt oStmt) eExpr) +mkExpandedStmtTc oStmt flav eExpr = XExpr (ExpandedThingTc (OrigStmt oStmt flav) eExpr) {- ********************************************************************* * * @@ -836,7 +840,7 @@ instance Outputable HsThingRn where ppr thing = case thing of OrigExpr x -> ppr_builder ":" x - OrigStmt x -> ppr_builder ":" x + OrigStmt x _ -> ppr_builder ":" x OrigPat x -> ppr_builder ":" x where ppr_builder prefix x = ifPprDebug (braces (text prefix <+> parens (ppr x))) (ppr x) ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -315,7 +315,7 @@ dsExpr (HsOverLit _ lit) dsExpr e@(XExpr ext_expr_tc) = case ext_expr_tc of ExpandedThingTc o e - | OrigStmt (L loc _) <- o + | OrigStmt (L loc _) _ <- o -> putSrcSpanDsA loc $ dsExpr e | otherwise -> dsExpr e WrapExpr {} -> dsHsWrapped e ===================================== compiler/GHC/HsToCore/Ticks.hs ===================================== @@ -611,7 +611,7 @@ addTickHsExpr (HsDo srcloc cxt (L l stmts)) _ -> Nothing addTickHsExpanded :: HsThingRn -> HsExpr GhcTc -> TM (HsExpr GhcTc) -addTickHsExpanded o@(OrigStmt (L pos LastStmt{})) e +addTickHsExpanded o@(OrigStmt (L pos LastStmt{}) _) e -- LastStmt always gets a tick for breakpoint and hpc coverage = do d <- getDensity case d of ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -806,18 +806,18 @@ addArgCtxt ctxt (L arg_loc arg) thing_inside | XExpr{} <- arg, in_generated_code -> thing_inside -- AppDo case for <*>'s second argument, the ctxt will be set by addHeadCtxt - VAExpansion (OrigStmt (L _ stmt@(BindStmt {}))) _ loc + VAExpansion (OrigStmt (L _ stmt@(BindStmt {})) flav) _ loc | isGeneratedSrcSpan (locA arg_loc) -- This arg is the second argument to generated (>>=) -> setSrcSpan loc $ - addStmtCtxt stmt $ + addStmtCtxt stmt flav $ thing_inside | otherwise -- This arg is the first argument to generated (>>=) -> setSrcSpanA arg_loc $ - addStmtCtxt stmt $ + addStmtCtxt stmt flav $ thing_inside - VAExpansion (OrigStmt (L loc stmt)) _ _ + VAExpansion (OrigStmt (L loc stmt) flav) _ _ -> setSrcSpanA loc $ - addStmtCtxt stmt $ + addStmtCtxt stmt flav $ thing_inside _ -> setSrcSpanA arg_loc $ ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -80,7 +80,7 @@ expand_do_stmts _ (stmt@(L _ (ParStmt {})):_) = pprPanic "expand_do_stmts: ParStmt" $ ppr stmt -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` -expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] +expand_do_stmts flav [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] -- See Note [Expanding HsDo with XXExprGhcRn] Equation (5) below -- last statement of a list comprehension, needs to explicitly return it -- See `checkLastStmt` and `Syntax.Expr.StmtLR.LastStmt` @@ -89,8 +89,8 @@ expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] = do traceTc "expand_do_stmts last" (ppr ret_expr) appDo <- xoptM LangExt.ApplicativeDo if appDo - then return $ mkExpandedStmtAt loc stmt body - else return $ mkExpandedStmtPopAt loc stmt body + then return $ mkExpandedStmtAt loc stmt flav body + else return $ mkExpandedStmtPopAt loc stmt flav body | SyntaxExprRn ret <- ret_expr -- @@ -99,7 +99,7 @@ expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] -- to make T18324 work = do traceTc "expand_do_stmts last" (ppr ret_expr) let expansion = genHsApp ret (L body_loc body) - return $ mkExpandedStmtPopAt loc stmt expansion + return $ mkExpandedStmtPopAt loc stmt flav expansion expand_do_stmts doFlavour (stmt@(L loc (LetStmt _ bs)) : lstmts) = -- See Note [Expanding HsDo with XXExprGhcRn] Equation (3) below @@ -108,7 +108,7 @@ expand_do_stmts doFlavour (stmt@(L loc (LetStmt _ bs)) : lstmts) = -- let x = e ; stmts ~~> let x = e in stmts' do expand_stmts <- expand_do_stmts doFlavour lstmts let expansion = genHsLet bs expand_stmts - return $ mkExpandedStmtPopAt loc stmt expansion + return $ mkExpandedStmtPopAt loc stmt doFlavour expansion expand_do_stmts doFlavour (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) | SyntaxExprRn bind_op <- xbsrn_bindOp xbsrn @@ -124,7 +124,7 @@ expand_do_stmts doFlavour (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) let expansion = genHsExpApps bind_op -- (>>=) [ e , failable_expr ] - return $ mkExpandedStmtPopAt loc stmt expansion + return $ mkExpandedStmtPopAt loc stmt doFlavour expansion | otherwise = pprPanic "expand_do_stmts: The impossible happened, missing bind operator from renamer" (text "stmt" <+> ppr stmt) @@ -139,7 +139,7 @@ expand_do_stmts doFlavour (stmt@(L loc (BodyStmt _ e (SyntaxExprRn then_op) _)) let expansion = genHsExpApps then_op -- (>>) [ e , expand_stmts_expr ] - return $ mkExpandedStmtPopAt loc stmt expansion + return $ mkExpandedStmtPopAt loc stmt doFlavour expansion expand_do_stmts doFlavour ((L loc (RecStmt { recS_stmts = L stmts_loc rec_stmts @@ -226,7 +226,8 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = , app_arg_pattern = pat , arg_expr = (L rhs_loc rhs) }) = - return ((pat, mb_fail_op), mkExpandedStmtAt rhs_loc (L rhs_loc (BindStmt xbsn pat (L rhs_loc rhs))) rhs) + return ((pat, mb_fail_op) + , mkExpandedStmtAt rhs_loc (L rhs_loc (BindStmt xbsn pat (L rhs_loc rhs))) doFlavour rhs) do_arg (ApplicativeArgMany _ stmts ret pat ctxt) = do { expr <- expand_do_stmts ctxt $ stmts ++ [wrapGenSpan $ mkLastStmt (wrapGenSpan ret)] ; return ((pat, Nothing) ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -711,26 +711,26 @@ tcXExpr (PopErrCtxt (L loc e)) res_ty tcExpr e res_ty tcXExpr xe@(ExpandedThingRn o e') res_ty - | OrigStmt ls@(L loc s at LetStmt{}) <- o + | OrigStmt ls@(L loc s at LetStmt{}) flav <- o , HsLet x binds e <- e' = do { (binds', wrapper, e') <- setSrcSpanA loc $ - addStmtCtxt s $ + addStmtCtxt s flav $ tcLocalBinds binds $ tcMonoExprNC e res_ty -- NB: Do not call tcMonoExpr here as it adds -- a duplicate error context - ; return $ mkExpandedStmtTc ls (HsLet x binds' (mkLHsWrap wrapper e')) + ; return $ mkExpandedStmtTc ls flav (HsLet x binds' (mkLHsWrap wrapper e')) } - | OrigStmt ls@(L loc s at LastStmt{}) <- o + | OrigStmt ls@(L loc s at LastStmt{}) flav <- o = setSrcSpanA loc $ - addStmtCtxt s $ - mkExpandedStmtTc ls <$> tcExpr e' res_ty + addStmtCtxt s flav $ + mkExpandedStmtTc ls flav <$> tcExpr e' res_ty -- It is important that we call tcExpr (and not tcApp) here as -- `e` is the last statement's body expression -- and not a HsApp of a generated (>>) or (>>=) -- This improves error messages e.g. tests: DoExpansion1, DoExpansion2, DoExpansion3 - | OrigStmt ls@(L loc _) <- o + | OrigStmt ls@(L loc _) flav <- o = setSrcSpanA loc $ - mkExpandedStmtTc ls <$> tcApp (XExpr xe) res_ty + mkExpandedStmtTc ls flav <$> tcApp (XExpr xe) res_ty tcXExpr xe res_ty = tcApp (XExpr xe) res_ty ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -325,7 +325,7 @@ splitHsApps e = go e (top_ctxt 0 e) [] = go e (VAExpansion o (appCtxtLoc ctxt) (appCtxtLoc ctxt)) (EWrap (EExpand o) : args) - | OrigStmt (L _ stmt) <- o -- so that we set `(>>)` as generated + | OrigStmt (L _ stmt) _ <- o -- so that we set `(>>)` as generated , BodyStmt{} <- stmt -- and get the right unused bind warnings = go e (VAExpansion o generatedSrcSpan generatedSrcSpan) -- See Part 3. in Note [Expanding HsDo with XXExprGhcRn] @@ -896,10 +896,10 @@ tcInferAppHead_maybe fun _ -> return Nothing addHeadCtxt :: AppCtxt -> TcM a -> TcM a -addHeadCtxt (VAExpansion (OrigStmt (L loc stmt)) _ _) thing_inside = +addHeadCtxt (VAExpansion (OrigStmt (L loc stmt) flav) _ _) thing_inside = do traceTc "addHeadCtxt stmt" (ppr stmt) setSrcSpanA loc $ - addStmtCtxt stmt + addStmtCtxt stmt flav $ thing_inside addHeadCtxt fun_ctxt thing_inside | not (isGoodSrcSpan fun_loc) -- noSrcSpan => no arguments @@ -1628,9 +1628,9 @@ mis-match in the number of value arguments. * * ********************************************************************* -} -addStmtCtxt :: ExprStmt GhcRn -> TcRn a -> TcRn a -addStmtCtxt stmt thing_inside - = do let err_doc = pprStmtInCtxt (HsDoStmt (DoExpr Nothing)) stmt +addStmtCtxt :: ExprStmt GhcRn -> HsDoFlavour -> TcRn a -> TcRn a +addStmtCtxt stmt flav thing_inside + = do let err_doc = pprStmtInCtxt (HsDoStmt flav) stmt addErrCtxt err_doc thing_inside where pprStmtInCtxt :: HsStmtContextRn -> StmtLR GhcRn GhcRn (LHsExpr GhcRn) -> SDoc @@ -1643,7 +1643,7 @@ addExprCtxt :: HsExpr GhcRn -> TcRn a -> TcRn a addExprCtxt e thing_inside = case e of HsUnboundVar {} -> thing_inside - XExpr (ExpandedThingRn (OrigStmt stmt) _) -> addStmtCtxt (unLoc stmt) thing_inside + XExpr (ExpandedThingRn (OrigStmt stmt flav) _) -> addStmtCtxt (unLoc stmt) flav thing_inside _ -> addErrCtxt (exprCtxt e) thing_inside -- The HsUnboundVar special case addresses situations like -- f x = _ ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -751,7 +751,7 @@ exprCtOrigin (HsProc {}) = Shouldn'tHappenOrigin "proc" exprCtOrigin (HsStatic {}) = Shouldn'tHappenOrigin "static expression" exprCtOrigin (HsEmbTy {}) = Shouldn'tHappenOrigin "type expression" exprCtOrigin (XExpr (ExpandedThingRn thing _)) | OrigExpr a <- thing = exprCtOrigin a - | OrigStmt _ <- thing = DoOrigin + | OrigStmt _ _ <- thing = DoOrigin | OrigPat p <- thing = DoPatOrigin p exprCtOrigin (XExpr (PopErrCtxt {})) = Shouldn'tHappenOrigin "PopErrCtxt" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0047f94e045a074de02ea1fe61552492d5618153 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0047f94e045a074de02ea1fe61552492d5618153 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 15:43:32 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 11:43:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24585 Message-ID: <66019ba47e21d_370dac513c7c350eb@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24585 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24585 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 15:47:31 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 11:47:31 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/revert-5bd8e Message-ID: <66019c93bb7be_370dac5eb67c352ba@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/revert-5bd8e at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/revert-5bd8e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 15:59:21 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 11:59:21 -0400 Subject: [Git][ghc/ghc][wip/romes/revert-5bd8e] Revert "NCG: Fix a bug in jump shortcutting." Message-ID: <66019f58f3b36_370dacc31374440e7@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/revert-5bd8e at Glasgow Haskell Compiler / GHC Commits: 91b3e1ce by Rodrigo Mesquita at 2024-03-25T15:58:57+00:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 12 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91b3e1ce10c342172c019948f2efe9975d6eac14 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91b3e1ce10c342172c019948f2efe9975d6eac14 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 17:23:25 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Mon, 25 Mar 2024 13:23:25 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 5 commits: Simplify MVar operations used Message-ID: <6601b30d8a80c_84636143a19c887d4@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 8f8cb6da by Rodrigo Mesquita at 2024-03-25T14:49:51+00:00 Simplify MVar operations used - - - - - 2986b01d by Rodrigo Mesquita at 2024-03-25T14:49:51+00:00 Improve debug message - - - - - e8320e18 by Rodrigo Mesquita at 2024-03-25T16:26:53+00:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. - - - - - fe89edb1 by Rodrigo Mesquita at 2024-03-25T16:26:53+00:00 fix: Qualify problematic names in lexer With alex 3.5.1.0, the commit 7dfdf3d9fbc216653fe2cf95cc52c35900bdc8b4 makes GHC fail to build. Fixes #24585 - - - - - ba972f7d by Rodrigo Mesquita at 2024-03-25T17:23:06+00:00 Write Note [Looking up symbols in the relevant objects] - - - - - 16 changed files: - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Interpreter.hs - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -180,7 +180,13 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do case mb_ptr of Just ptr -> pure (Just ptr) Nothing -> go dlls - go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id" + go [] = pprPanic "GHC.ByteCode.Linker.lookupHsSymbol" $ + text "name" + <+> ppr nm + <+> parens (text "symbol" <+> ppr sym_to_find) + <+> text "not found in the loaded_dlls associated with this pkg_id" + <+> parens (ppr pkg_id) <> text ":" + $$ ppr (lookupUDFM pkgs_loaded pkg_id) go loaded_dlls ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -76,6 +76,29 @@ initialised. The LinkerEnv maps Names to actual closures (for interpreted code only), for use during linking. + +Note [Looking up symbols in the relevant objects] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #23415, we determined that a lot of time (>10s, or even up to >35s!) was +being spent on dynamically loading symbols before actually interpreting code +when `:main` was run in GHCi. The root cause was that for each symbol we wanted +to lookup, we would traverse the list of loaded objects and try find the symbol +in each of them with dlsym (i.e. looking up a symbol was, worst case, linear in +the amount of loaded objects). + +To drastically improve load time (XXX(TODO:get better measure against 10s +baseline rather than 35second one) to <3s), we now: + +1. For every of the native objects loaded for a given unit, store the handles returned by `dlopen`. + - In `pkgs_loaded` of the `LoaderState`, which maps `UnitId`s to + `LoadedPkgInfo`s, where the handles live in its field `loaded_pkg_hs_dlls`. + +2. When looking up a Name (e.g. `lookupHsSymbol`), find that name's `UnitId` in + the `pkgs_loaded` mapping, + +3. And only look for the symbol (with `dlsym`) on the /handles relevant to that + unit/, rather than in every loaded object. + -} newtype Loader = Loader { loader_state :: MVar (Maybe LoaderState) } @@ -148,7 +171,7 @@ data LoadedPkgInfo , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] - -- ^ TODO: write Note + -- ^ See Note [Looking up symbols in the relevant objects] , loaded_pkg_trans_deps :: UniqDSet UnitId } ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2870,7 +2870,7 @@ alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' unsafeChr :: Int -> Char -unsafeChr (I# c) = C# (chr# c) +unsafeChr (I# c) = GHC.Exts.C# (GHC.Exts.chr# c) -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -500,12 +500,12 @@ withSymbolCache interp str determine_addr = do case maddr of Nothing -> return Nothing Just p -> do - let cache' = addToUFM cache str p - modifyMVar_ (interpLookupSymbolCache interp) (const (pure cache')) + let upd_cache cache' = addToUFM cache' str p + modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache) return (Just p) purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = modifyMVar_ (interpLookupSymbolCache interp) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdc1bc89f31e87ff201e9d8825202b4a7eb43727...ba972f7d77b75941b19d44ad7c505c28d14dc8ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdc1bc89f31e87ff201e9d8825202b4a7eb43727...ba972f7d77b75941b19d44ad7c505c28d14dc8ac You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 17:41:51 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Mon, 25 Mar 2024 13:41:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T23536-teo Message-ID: <6601b75feb293_846361c010c49202a@gitlab.mail> Teo Camarasu pushed new branch wip/T23536-teo at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T23536-teo You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 17:46:20 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 25 Mar 2024 13:46:20 -0400 Subject: [Git][ghc/ghc][master] rts: fix clang compilation on aarch64 Message-ID: <6601b86c5b02c_846361f3f2cc953e3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 1 changed file: - rts/ARMOutlineAtomicsSymbols.h Changes: ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7db8c9927fae3369fc4ecff68f80c4cb32eea757 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7db8c9927fae3369fc4ecff68f80c4cb32eea757 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 17:46:59 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 25 Mar 2024 13:46:59 -0400 Subject: [Git][ghc/ghc][master] Lexer: fix imports for Alex 3.5.1 (#24583) Message-ID: <6601b89375cc4_8463620b9ad0100050@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 1 changed file: - compiler/GHC/Parser/Lexer.x Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2870,7 +2870,7 @@ alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' unsafeChr :: Int -> Char -unsafeChr (I# c) = C# (chr# c) +unsafeChr (I# c) = GHC.Exts.C# (GHC.Exts.chr# c) -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/237194ceb4f227e9f69e8e6f913afa0496d2a583 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/237194ceb4f227e9f69e8e6f913afa0496d2a583 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 19:13:23 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 25 Mar 2024 15:13:23 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 10 commits: Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" Message-ID: <6601ccd3e8458_846364d07c4011567c@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: b09cbad8 by Zubin Duggal at 2024-03-25T12:21:37-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- (cherry picked from commit 576f8b7ec292382aaa47fceab504b5abf4cc1f8a) - - - - - 0d4ee209 by Andrei Borzenkov at 2024-03-25T12:27:07-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) (cherry picked from commit 7ea971d314c4eba59e12e94bf3eb8edb95fbfac5) - - - - - 688cb2ff by Cheng Shao at 2024-03-25T12:28:00-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. (cherry picked from commit 39f3ac3e1b47e9fdac8fcf2d1edcc300a37deb82) - - - - - c5c19c14 by Cheng Shao at 2024-03-25T12:28:01-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. (cherry picked from commit e6bfb85c842edca36754bb8914e725fbaa1a83a6) - - - - - 67defa84 by Alan Zimmerman at 2024-03-25T12:28:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 (cherry picked from commit 7da7f8f643f1bfc4aa034a731f2f85cda007b286) - - - - - 97afcca5 by Alan Zimmerman at 2024-03-25T12:28:31-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time (cherry picked from commit bd8209eb8e447a5ae1d736f034f4a3986e0727f7) - - - - - 850fc30e by Alan Zimmerman at 2024-03-25T12:28:48-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework (cherry picked from commit 5f27517687c711593a23f1c9e5bd09ad9ec22fa4) - - - - - 01a6a717 by Vladislav Zavialov at 2024-03-25T12:29:02-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. (cherry picked from commit da2a10ceab7498fbbd5723dee0393ce75f2bb562) - - - - - e5b111e9 by Simon Peyton Jones at 2024-03-25T12:29:15-04:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 (cherry picked from commit 97a2bb1cdfa4b244a58374658aec6d48ce23a54a) - - - - - 222a5240 by Andrei Borzenkov at 2024-03-25T12:29:27-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () (cherry picked from commit 6fafc51e9206abd62881131c282ec3b9e1584c5b) - - - - - 30 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c - m4/fp_settings.m4 - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24533.hs - + testsuite/tests/printer/Test24533.stdout - testsuite/tests/printer/all.T - + testsuite/tests/th/T24559.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T - + testsuite/tests/vdq-rta/should_compile/T24570.hs - testsuite/tests/vdq-rta/should_compile/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cf814fe982f42483c672802ce905350d99a85a35...222a5240df423c22c63f720cffb06a202f271021 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cf814fe982f42483c672802ce905350d99a85a35...222a5240df423c22c63f720cffb06a202f271021 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 19:30:30 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Mon, 25 Mar 2024 15:30:30 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-duplicate-sig-comments Message-ID: <6601d0d681bc3_846365556eb4122891@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-duplicate-sig-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-duplicate-sig-comments You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 20:25:26 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 25 Mar 2024 16:25:26 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] Bump haddock submodule Message-ID: <6601ddb6b2451_84636715dd6013307f@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: ff41910e by Ben Gamari at 2024-03-25T16:24:24-04:00 Bump haddock submodule Fixes #24485 by fixing the default hyperlinked sources URL pattern. - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 243fefaa40ddcc7c657a95e92f30cb79ec4ecb45 +Subproject commit 8bc6f2a733ca7a1ba17fa8d13e0acdcde370c1f1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff41910e707639165e33767447ac97456765f056 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff41910e707639165e33767447ac97456765f056 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Mar 25 22:49:21 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 25 Mar 2024 18:49:21 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: fix clang compilation on aarch64 Message-ID: <6601ff71c0841_84636ab49e9815118b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 1a9056ea by Cheng Shao at 2024-03-25T18:49:09-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - 0a5150fe by Alan Zimmerman at 2024-03-25T18:49:09-04:00 EPA: do not duplicate comments in signature RHS - - - - - 4 changed files: - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser/Lexer.x - libffi-tarballs - rts/ARMOutlineAtomicsSymbols.h Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -736,12 +736,12 @@ mkBigLHsPatTup = mkChunkified mkLHsPatTup -- | Convert an 'LHsType' to an 'LHsSigType'. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -hsTypeToHsSigType lty@(L loc ty) = L loc $ case ty of +hsTypeToHsSigType lty@(L loc ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an , hsf_invis_bndrs = bndrs } , hst_body = body } - -> mkHsExplicitSigType an bndrs body - _ -> mkHsImplicitSigType lty + -> L loc $ mkHsExplicitSigType an bndrs body + _ -> L (l2l loc) $ mkHsImplicitSigType lty -- The annotations are in lty, erase them from loc -- | Convert an 'LHsType' to an 'LHsSigWcType'. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2870,7 +2870,7 @@ alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' unsafeChr :: Int -> Char -unsafeChr (I# c) = C# (chr# c) +unsafeChr (I# c) = GHC.Exts.C# (GHC.Exts.chr# c) -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/70398925624c2fc615db98eab4ba337e7099d01f...0a5150feba5dbc75f32aac8b934314d33060df6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/70398925624c2fc615db98eab4ba337e7099d01f...0a5150feba5dbc75f32aac8b934314d33060df6b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 02:19:38 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 25 Mar 2024 22:19:38 -0400 Subject: [Git][ghc/ghc][master] libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 Message-ID: <660230ba75fd4_175f6b3d41568696f1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - 1 changed file: - libffi-tarballs Changes: ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/810660b780e1111b36c91326bcd0041e1f62706b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/810660b780e1111b36c91326bcd0041e1f62706b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 02:20:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 25 Mar 2024 22:20:34 -0400 Subject: [Git][ghc/ghc][master] EPA: do not duplicate comments in signature RHS Message-ID: <660230f28ec1_175f6b3e8f2a8729a2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 1 changed file: - compiler/GHC/Hs/Utils.hs Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -736,12 +736,12 @@ mkBigLHsPatTup = mkChunkified mkLHsPatTup -- | Convert an 'LHsType' to an 'LHsSigType'. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -hsTypeToHsSigType lty@(L loc ty) = L loc $ case ty of +hsTypeToHsSigType lty@(L loc ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an , hsf_invis_bndrs = bndrs } , hst_body = body } - -> mkHsExplicitSigType an bndrs body - _ -> mkHsImplicitSigType lty + -> L loc $ mkHsExplicitSigType an bndrs body + _ -> L (l2l loc) $ mkHsImplicitSigType lty -- The annotations are in lty, erase them from loc -- | Convert an 'LHsType' to an 'LHsSigWcType'. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2ba41e8c3e71d70a0f80dcc3f588ecbdc5ce4b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2ba41e8c3e71d70a0f80dcc3f588ecbdc5ce4b2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 07:47:18 2024 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 26 Mar 2024 03:47:18 -0400 Subject: [Git][ghc/ghc][wip/home-unit-closure-fast] driver: Make `checkHomeUnitsClosed` faster Message-ID: <66027d861b102_175f6bd1d6df48435c@gitlab.mail> Zubin pushed to branch wip/home-unit-closure-fast at Glasgow Haskell Compiler / GHC Commits: 36f089ab by Zubin Duggal at 2024-03-26T13:17:02+05:30 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 6 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,69 +1714,77 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +-- +-- See Note [Multiple Home Units], section 'Closure Property'. +checkHomeUnitsClosed :: UnitEnv -> [DriverMessages] +checkHomeUnitsClosed ue + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + home_id_set = unitEnv_keys $ ue_home_unit_graph ue + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,9 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + js_broken(22349), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36f089ab5777d4f6577ee40f7302f436181a6241 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36f089ab5777d4f6577ee40f7302f436181a6241 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 10:09:39 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 06:09:39 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <66029ee3665a9_2edda54230b0658f3@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: 860a0a1b by Teo Camarasu at 2024-03-26T10:09:15+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. Resolves #23536 - - - - - 15 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,12 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1208,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1328,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2118,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2434,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2463,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2600,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2613,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2625,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2636,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2694,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2757,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2771,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1514,10 +1514,11 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + -- TODO: factor out toEnum/fromEnum stuff + qIsExtEnabled = xoptM . toEnum . fromEnum qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map (toEnum . fromEnum) . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Nothing +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/CabalReinstall.hs ===================================== @@ -25,7 +25,7 @@ The libdir of the reinstalled GHC points to the libdir of the stage 2 compiler ( -- | We don't support reinstalling these cabalExcludedPackages :: [Package] -cabalExcludedPackages = [array, base, deepseq, filepath, ghcBignum, ghcBootTh, ghcPrim, integerGmp, integerSimple, pretty, templateHaskell] +cabalExcludedPackages = [array, base, deepseq, filepath, ghcBignum, ghcPrim, integerGmp, integerSimple, pretty, templateHaskell] cabalBuildRules :: Rules () ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -158,7 +158,7 @@ toolTargets = [ binary -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot - , ghcBootTh + --, ghcBootTh , ghcPlatform , ghcToolchain , ghcToolchainBin ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,154 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +module GHC.LanguageExtensions ( Extension(..) ) where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary +import GHC.Generics +#if MIN_VERSION_ghc_boot_th(9,11,0) import GHC.LanguageExtensions.Type +#else +data Extension +-- See Note [Updating flag description in the User's Guide] in +-- GHC.Driver.Session + = Cpp + | OverlappingInstances + | UndecidableInstances + | IncoherentInstances + | UndecidableSuperClasses + | MonomorphismRestriction + | MonoLocalBinds + | DeepSubsumption + | RelaxedPolyRec -- Deprecated + | ExtendedDefaultRules -- Use GHC's extended rules for defaulting + | ForeignFunctionInterface + | UnliftedFFITypes + | InterruptibleFFI + | CApiFFI + | GHCForeignImportPrim + | JavaScriptFFI + | ParallelArrays -- Syntactic support for parallel arrays + | Arrows -- Arrow-notation syntax + | TemplateHaskell + | TemplateHaskellQuotes -- subset of TH supported by stage1, no splice + | QualifiedDo + | QuasiQuotes + | ImplicitParams + | ImplicitPrelude + | ScopedTypeVariables + | AllowAmbiguousTypes + | UnboxedTuples + | UnboxedSums + | UnliftedNewtypes + | UnliftedDatatypes + | BangPatterns + | TypeFamilies + | TypeFamilyDependencies + | TypeInType -- Deprecated + | OverloadedStrings + | OverloadedLists + | NumDecimals + | DisambiguateRecordFields + | RecordWildCards + | NamedFieldPuns + | ViewPatterns + | GADTs + | GADTSyntax + | NPlusKPatterns + | DoAndIfThenElse + | BlockArguments + | RebindableSyntax + | ConstraintKinds + | PolyKinds -- Kind polymorphism + | DataKinds -- Datatype promotion + | TypeData -- allow @type data@ definitions + | InstanceSigs + | ApplicativeDo + | LinearTypes + | RequiredTypeArguments -- Visible forall (VDQ) in types of terms + + | StandaloneDeriving + | DeriveDataTypeable + | AutoDeriveTypeable -- Automatic derivation of Typeable + | DeriveFunctor + | DeriveTraversable + | DeriveFoldable + | DeriveGeneric -- Allow deriving Generic/1 + | DefaultSignatures -- Allow extra signatures for defmeths + | DeriveAnyClass -- Allow deriving any class + | DeriveLift -- Allow deriving Lift + | DerivingStrategies + | DerivingVia -- Derive through equal representation + + | TypeSynonymInstances + | FlexibleContexts + | FlexibleInstances + | ConstrainedClassMethods + | MultiParamTypeClasses + | NullaryTypeClasses + | FunctionalDependencies + | UnicodeSyntax + | ExistentialQuantification + | MagicHash + | EmptyDataDecls + | KindSignatures + | RoleAnnotations + | ParallelListComp + | TransformListComp + | MonadComprehensions + | GeneralizedNewtypeDeriving + | RecursiveDo + | PostfixOperators + | TupleSections + | PatternGuards + | LiberalTypeSynonyms + | RankNTypes + | ImpredicativeTypes + | TypeOperators + | ExplicitNamespaces + | PackageImports + | ExplicitForAll + | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional + | DatatypeContexts + | NondecreasingIndentation + | RelaxedLayout + | TraditionalRecordSyntax + | LambdaCase + | MultiWayIf + | BinaryLiterals + | NegativeLiterals + | HexFloatLiterals + | DuplicateRecordFields + | OverloadedLabels + | EmptyCase + | PatternSynonyms + | PartialTypeSignatures + | NamedWildCards + | StaticPointers + | TypeApplications + | Strict + | StrictData + | EmptyDataDeriving + | NumericUnderscores + | QuantifiedConstraints + | StarIsType + | ImportQualifiedPost + | CUSKs + | StandaloneKindSignatures + | LexicalNegation + | FieldSelectors + | OverloadedRecordDot + | OverloadedRecordUpdate + | TypeAbstractions + | ExtendedLiterals + | ListTuplePuns + deriving (Eq, Enum, Show, Generic, Bounded) +-- 'Ord' and 'Bounded' are provided for GHC API users (see discussions +-- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and +-- https://gitlab.haskell.org/ghc/ghc/merge_requests/826). +instance Ord Extension where compare a b = compare (fromEnum a) (fromEnum b) +#endif instance Binary Extension ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -81,7 +81,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,7 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +58,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot , ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/860a0a1b777ab8b827350505b962c3fdfa6cb962 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/860a0a1b777ab8b827350505b962c3fdfa6cb962 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 10:21:18 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 06:21:18 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <6602a19edcdb2_2edda5af7b4866092@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: ebec0964 by Teo Camarasu at 2024-03-26T10:21:02+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. Resolves #23536 - - - - - 14 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,12 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1208,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1328,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2118,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2434,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2463,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2600,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2613,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2625,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2636,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2694,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2757,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2771,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1514,10 +1514,11 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + -- TODO: factor out toEnum/fromEnum stuff + qIsExtEnabled = xoptM . toEnum . fromEnum qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map (toEnum . fromEnum) . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Nothing +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/CabalReinstall.hs ===================================== @@ -25,7 +25,7 @@ The libdir of the reinstalled GHC points to the libdir of the stage 2 compiler ( -- | We don't support reinstalling these cabalExcludedPackages :: [Package] -cabalExcludedPackages = [array, base, deepseq, filepath, ghcBignum, ghcBootTh, ghcPrim, integerGmp, integerSimple, pretty, templateHaskell] +cabalExcludedPackages = [array, base, deepseq, filepath, ghcBignum, ghcPrim, integerGmp, integerSimple, pretty, templateHaskell] cabalBuildRules :: Rules () ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,161 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + ) + where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary +import GHC.Generics +#if MIN_VERSION_ghc_boot_th(9,11,0) import GHC.LanguageExtensions.Type +#else + +data Extension +-- See Note [Updating flag description in the User's Guide] in +-- GHC.Driver.Session + = Cpp + | OverlappingInstances + | UndecidableInstances + | IncoherentInstances + | UndecidableSuperClasses + | MonomorphismRestriction + | MonoLocalBinds + | DeepSubsumption + | RelaxedPolyRec -- Deprecated + | ExtendedDefaultRules -- Use GHC's extended rules for defaulting + | ForeignFunctionInterface + | UnliftedFFITypes + | InterruptibleFFI + | CApiFFI + | GHCForeignImportPrim + | JavaScriptFFI + | ParallelArrays -- Syntactic support for parallel arrays + | Arrows -- Arrow-notation syntax + | TemplateHaskell + | TemplateHaskellQuotes -- subset of TH supported by stage1, no splice + | QualifiedDo + | QuasiQuotes + | ImplicitParams + | ImplicitPrelude + | ScopedTypeVariables + | AllowAmbiguousTypes + | UnboxedTuples + | UnboxedSums + | UnliftedNewtypes + | UnliftedDatatypes + | BangPatterns + | TypeFamilies + | TypeFamilyDependencies + | TypeInType -- Deprecated + | OverloadedStrings + | OverloadedLists + | NumDecimals + | DisambiguateRecordFields + | RecordWildCards + | NamedFieldPuns + | ViewPatterns + | GADTs + | GADTSyntax + | NPlusKPatterns + | DoAndIfThenElse + | BlockArguments + | RebindableSyntax + | ConstraintKinds + | PolyKinds -- Kind polymorphism + | DataKinds -- Datatype promotion + | TypeData -- allow @type data@ definitions + | InstanceSigs + | ApplicativeDo + | LinearTypes + | RequiredTypeArguments -- Visible forall (VDQ) in types of terms + + | StandaloneDeriving + | DeriveDataTypeable + | AutoDeriveTypeable -- Automatic derivation of Typeable + | DeriveFunctor + | DeriveTraversable + | DeriveFoldable + | DeriveGeneric -- Allow deriving Generic/1 + | DefaultSignatures -- Allow extra signatures for defmeths + | DeriveAnyClass -- Allow deriving any class + | DeriveLift -- Allow deriving Lift + | DerivingStrategies + | DerivingVia -- Derive through equal representation + + | TypeSynonymInstances + | FlexibleContexts + | FlexibleInstances + | ConstrainedClassMethods + | MultiParamTypeClasses + | NullaryTypeClasses + | FunctionalDependencies + | UnicodeSyntax + | ExistentialQuantification + | MagicHash + | EmptyDataDecls + | KindSignatures + | RoleAnnotations + | ParallelListComp + | TransformListComp + | MonadComprehensions + | GeneralizedNewtypeDeriving + | RecursiveDo + | PostfixOperators + | TupleSections + | PatternGuards + | LiberalTypeSynonyms + | RankNTypes + | ImpredicativeTypes + | TypeOperators + | ExplicitNamespaces + | PackageImports + | ExplicitForAll + | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional + | DatatypeContexts + | NondecreasingIndentation + | RelaxedLayout + | TraditionalRecordSyntax + | LambdaCase + | MultiWayIf + | BinaryLiterals + | NegativeLiterals + | HexFloatLiterals + | DuplicateRecordFields + | OverloadedLabels + | EmptyCase + | PatternSynonyms + | PartialTypeSignatures + | NamedWildCards + | StaticPointers + | TypeApplications + | Strict + | StrictData + | EmptyDataDeriving + | NumericUnderscores + | QuantifiedConstraints + | StarIsType + | ImportQualifiedPost + | CUSKs + | StandaloneKindSignatures + | LexicalNegation + | FieldSelectors + | OverloadedRecordDot + | OverloadedRecordUpdate + | TypeAbstractions + | ExtendedLiterals + | ListTuplePuns + deriving (Eq, Enum, Show, Generic, Bounded) +-- 'Ord' and 'Bounded' are provided for GHC API users (see discussions +-- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and +-- https://gitlab.haskell.org/ghc/ghc/merge_requests/826). +instance Ord Extension where compare a b = compare (fromEnum a) (fromEnum b) +#endif instance Binary Extension ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -81,7 +81,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot , ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebec09643c6d6aa5dbcc7a1d1fcd292d2d635807 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebec09643c6d6aa5dbcc7a1d1fcd292d2d635807 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 10:28:15 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 06:28:15 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <6602a33f72ced_2edda5fcbcb472469@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: e6edfa0d by Teo Camarasu at 2024-03-26T10:27:59+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. Resolves #23536 - - - - - 13 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,12 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1208,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1328,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2118,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2434,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2463,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2600,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2613,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2625,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2636,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2694,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2757,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2771,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1514,10 +1514,11 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + -- TODO: factor out toEnum/fromEnum stuff + qIsExtEnabled = xoptM . toEnum . fromEnum qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map (toEnum . fromEnum) . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Nothing +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,161 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + ) + where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary +import GHC.Generics +#if MIN_VERSION_ghc_boot_th(9,11,0) import GHC.LanguageExtensions.Type +#else + +data Extension +-- See Note [Updating flag description in the User's Guide] in +-- GHC.Driver.Session + = Cpp + | OverlappingInstances + | UndecidableInstances + | IncoherentInstances + | UndecidableSuperClasses + | MonomorphismRestriction + | MonoLocalBinds + | DeepSubsumption + | RelaxedPolyRec -- Deprecated + | ExtendedDefaultRules -- Use GHC's extended rules for defaulting + | ForeignFunctionInterface + | UnliftedFFITypes + | InterruptibleFFI + | CApiFFI + | GHCForeignImportPrim + | JavaScriptFFI + | ParallelArrays -- Syntactic support for parallel arrays + | Arrows -- Arrow-notation syntax + | TemplateHaskell + | TemplateHaskellQuotes -- subset of TH supported by stage1, no splice + | QualifiedDo + | QuasiQuotes + | ImplicitParams + | ImplicitPrelude + | ScopedTypeVariables + | AllowAmbiguousTypes + | UnboxedTuples + | UnboxedSums + | UnliftedNewtypes + | UnliftedDatatypes + | BangPatterns + | TypeFamilies + | TypeFamilyDependencies + | TypeInType -- Deprecated + | OverloadedStrings + | OverloadedLists + | NumDecimals + | DisambiguateRecordFields + | RecordWildCards + | NamedFieldPuns + | ViewPatterns + | GADTs + | GADTSyntax + | NPlusKPatterns + | DoAndIfThenElse + | BlockArguments + | RebindableSyntax + | ConstraintKinds + | PolyKinds -- Kind polymorphism + | DataKinds -- Datatype promotion + | TypeData -- allow @type data@ definitions + | InstanceSigs + | ApplicativeDo + | LinearTypes + | RequiredTypeArguments -- Visible forall (VDQ) in types of terms + + | StandaloneDeriving + | DeriveDataTypeable + | AutoDeriveTypeable -- Automatic derivation of Typeable + | DeriveFunctor + | DeriveTraversable + | DeriveFoldable + | DeriveGeneric -- Allow deriving Generic/1 + | DefaultSignatures -- Allow extra signatures for defmeths + | DeriveAnyClass -- Allow deriving any class + | DeriveLift -- Allow deriving Lift + | DerivingStrategies + | DerivingVia -- Derive through equal representation + + | TypeSynonymInstances + | FlexibleContexts + | FlexibleInstances + | ConstrainedClassMethods + | MultiParamTypeClasses + | NullaryTypeClasses + | FunctionalDependencies + | UnicodeSyntax + | ExistentialQuantification + | MagicHash + | EmptyDataDecls + | KindSignatures + | RoleAnnotations + | ParallelListComp + | TransformListComp + | MonadComprehensions + | GeneralizedNewtypeDeriving + | RecursiveDo + | PostfixOperators + | TupleSections + | PatternGuards + | LiberalTypeSynonyms + | RankNTypes + | ImpredicativeTypes + | TypeOperators + | ExplicitNamespaces + | PackageImports + | ExplicitForAll + | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional + | DatatypeContexts + | NondecreasingIndentation + | RelaxedLayout + | TraditionalRecordSyntax + | LambdaCase + | MultiWayIf + | BinaryLiterals + | NegativeLiterals + | HexFloatLiterals + | DuplicateRecordFields + | OverloadedLabels + | EmptyCase + | PatternSynonyms + | PartialTypeSignatures + | NamedWildCards + | StaticPointers + | TypeApplications + | Strict + | StrictData + | EmptyDataDeriving + | NumericUnderscores + | QuantifiedConstraints + | StarIsType + | ImportQualifiedPost + | CUSKs + | StandaloneKindSignatures + | LexicalNegation + | FieldSelectors + | OverloadedRecordDot + | OverloadedRecordUpdate + | TypeAbstractions + | ExtendedLiterals + | ListTuplePuns + deriving (Eq, Enum, Show, Generic, Bounded) +-- 'Ord' and 'Bounded' are provided for GHC API users (see discussions +-- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and +-- https://gitlab.haskell.org/ghc/ghc/merge_requests/826). +instance Ord Extension where compare a b = compare (fromEnum a) (fromEnum b) +#endif instance Binary Extension ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -81,7 +81,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot , ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e6edfa0de43451cd27d5d3ea976a65f012dabc54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e6edfa0de43451cd27d5d3ea976a65f012dabc54 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 10:56:46 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 06:56:46 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <6602a9ee9f9a3_2edda51ba2330729f5@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: 986509bb by Teo Camarasu at 2024-03-26T10:56:27+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. Resolves #23536 - - - - - 14 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,12 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1208,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1328,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2118,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2434,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2463,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2600,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2613,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2625,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2636,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2694,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2757,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2771,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1514,10 +1514,11 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + -- TODO: factor out toEnum/fromEnum stuff + qIsExtEnabled = xoptM . toEnum . fromEnum qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map (toEnum . fromEnum) . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Nothing +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -158,7 +158,6 @@ toolTargets = [ binary -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot - , ghcBootTh , ghcPlatform , ghcToolchain , ghcToolchainBin @@ -172,7 +171,6 @@ toolTargets = [ binary , mtl , parsec , time - , templateHaskell , text , transformers , semaphoreCompat ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,161 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + ) + where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary +import GHC.Generics +#if MIN_VERSION_ghc_boot_th(9,11,0) import GHC.LanguageExtensions.Type +#else + +data Extension +-- See Note [Updating flag description in the User's Guide] in +-- GHC.Driver.Session + = Cpp + | OverlappingInstances + | UndecidableInstances + | IncoherentInstances + | UndecidableSuperClasses + | MonomorphismRestriction + | MonoLocalBinds + | DeepSubsumption + | RelaxedPolyRec -- Deprecated + | ExtendedDefaultRules -- Use GHC's extended rules for defaulting + | ForeignFunctionInterface + | UnliftedFFITypes + | InterruptibleFFI + | CApiFFI + | GHCForeignImportPrim + | JavaScriptFFI + | ParallelArrays -- Syntactic support for parallel arrays + | Arrows -- Arrow-notation syntax + | TemplateHaskell + | TemplateHaskellQuotes -- subset of TH supported by stage1, no splice + | QualifiedDo + | QuasiQuotes + | ImplicitParams + | ImplicitPrelude + | ScopedTypeVariables + | AllowAmbiguousTypes + | UnboxedTuples + | UnboxedSums + | UnliftedNewtypes + | UnliftedDatatypes + | BangPatterns + | TypeFamilies + | TypeFamilyDependencies + | TypeInType -- Deprecated + | OverloadedStrings + | OverloadedLists + | NumDecimals + | DisambiguateRecordFields + | RecordWildCards + | NamedFieldPuns + | ViewPatterns + | GADTs + | GADTSyntax + | NPlusKPatterns + | DoAndIfThenElse + | BlockArguments + | RebindableSyntax + | ConstraintKinds + | PolyKinds -- Kind polymorphism + | DataKinds -- Datatype promotion + | TypeData -- allow @type data@ definitions + | InstanceSigs + | ApplicativeDo + | LinearTypes + | RequiredTypeArguments -- Visible forall (VDQ) in types of terms + + | StandaloneDeriving + | DeriveDataTypeable + | AutoDeriveTypeable -- Automatic derivation of Typeable + | DeriveFunctor + | DeriveTraversable + | DeriveFoldable + | DeriveGeneric -- Allow deriving Generic/1 + | DefaultSignatures -- Allow extra signatures for defmeths + | DeriveAnyClass -- Allow deriving any class + | DeriveLift -- Allow deriving Lift + | DerivingStrategies + | DerivingVia -- Derive through equal representation + + | TypeSynonymInstances + | FlexibleContexts + | FlexibleInstances + | ConstrainedClassMethods + | MultiParamTypeClasses + | NullaryTypeClasses + | FunctionalDependencies + | UnicodeSyntax + | ExistentialQuantification + | MagicHash + | EmptyDataDecls + | KindSignatures + | RoleAnnotations + | ParallelListComp + | TransformListComp + | MonadComprehensions + | GeneralizedNewtypeDeriving + | RecursiveDo + | PostfixOperators + | TupleSections + | PatternGuards + | LiberalTypeSynonyms + | RankNTypes + | ImpredicativeTypes + | TypeOperators + | ExplicitNamespaces + | PackageImports + | ExplicitForAll + | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional + | DatatypeContexts + | NondecreasingIndentation + | RelaxedLayout + | TraditionalRecordSyntax + | LambdaCase + | MultiWayIf + | BinaryLiterals + | NegativeLiterals + | HexFloatLiterals + | DuplicateRecordFields + | OverloadedLabels + | EmptyCase + | PatternSynonyms + | PartialTypeSignatures + | NamedWildCards + | StaticPointers + | TypeApplications + | Strict + | StrictData + | EmptyDataDeriving + | NumericUnderscores + | QuantifiedConstraints + | StarIsType + | ImportQualifiedPost + | CUSKs + | StandaloneKindSignatures + | LexicalNegation + | FieldSelectors + | OverloadedRecordDot + | OverloadedRecordUpdate + | TypeAbstractions + | ExtendedLiterals + | ListTuplePuns + deriving (Eq, Enum, Show, Generic, Bounded) +-- 'Ord' and 'Bounded' are provided for GHC API users (see discussions +-- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and +-- https://gitlab.haskell.org/ghc/ghc/merge_requests/826). +instance Ord Extension where compare a b = compare (fromEnum a) (fromEnum b) +#endif instance Binary Extension ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -81,7 +81,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@ if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@, ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/986509bbcf24a09a16679c843ee04ed4a8cf7d48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/986509bbcf24a09a16679c843ee04ed4a8cf7d48 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 11:00:32 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 07:00:32 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <6602aad0db9ba_2edda51ea57307336a@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: 8da93468 by Teo Camarasu at 2024-03-26T11:00:17+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. Resolves #23536 - - - - - 14 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,12 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1208,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1328,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2118,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2434,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2463,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2600,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2613,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2625,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2636,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2694,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2757,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2771,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1514,10 +1514,11 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + -- TODO: factor out toEnum/fromEnum stuff + qIsExtEnabled = xoptM . toEnum . fromEnum qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map (toEnum . fromEnum) . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Nothing +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -158,7 +158,6 @@ toolTargets = [ binary -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot - , ghcBootTh , ghcPlatform , ghcToolchain , ghcToolchainBin @@ -172,7 +171,6 @@ toolTargets = [ binary , mtl , parsec , time - , templateHaskell , text , transformers , semaphoreCompat ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,161 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + ) + where import Data.Binary +#if MIN_VERSION_ghc_boot_th(9,11,0) import GHC.LanguageExtensions.Type +#else +import Prelude -- See note [Why do we import Prelude here?] +import GHC.Generics + +data Extension +-- See Note [Updating flag description in the User's Guide] in +-- GHC.Driver.Session + = Cpp + | OverlappingInstances + | UndecidableInstances + | IncoherentInstances + | UndecidableSuperClasses + | MonomorphismRestriction + | MonoLocalBinds + | DeepSubsumption + | RelaxedPolyRec -- Deprecated + | ExtendedDefaultRules -- Use GHC's extended rules for defaulting + | ForeignFunctionInterface + | UnliftedFFITypes + | InterruptibleFFI + | CApiFFI + | GHCForeignImportPrim + | JavaScriptFFI + | ParallelArrays -- Syntactic support for parallel arrays + | Arrows -- Arrow-notation syntax + | TemplateHaskell + | TemplateHaskellQuotes -- subset of TH supported by stage1, no splice + | QualifiedDo + | QuasiQuotes + | ImplicitParams + | ImplicitPrelude + | ScopedTypeVariables + | AllowAmbiguousTypes + | UnboxedTuples + | UnboxedSums + | UnliftedNewtypes + | UnliftedDatatypes + | BangPatterns + | TypeFamilies + | TypeFamilyDependencies + | TypeInType -- Deprecated + | OverloadedStrings + | OverloadedLists + | NumDecimals + | DisambiguateRecordFields + | RecordWildCards + | NamedFieldPuns + | ViewPatterns + | GADTs + | GADTSyntax + | NPlusKPatterns + | DoAndIfThenElse + | BlockArguments + | RebindableSyntax + | ConstraintKinds + | PolyKinds -- Kind polymorphism + | DataKinds -- Datatype promotion + | TypeData -- allow @type data@ definitions + | InstanceSigs + | ApplicativeDo + | LinearTypes + | RequiredTypeArguments -- Visible forall (VDQ) in types of terms + + | StandaloneDeriving + | DeriveDataTypeable + | AutoDeriveTypeable -- Automatic derivation of Typeable + | DeriveFunctor + | DeriveTraversable + | DeriveFoldable + | DeriveGeneric -- Allow deriving Generic/1 + | DefaultSignatures -- Allow extra signatures for defmeths + | DeriveAnyClass -- Allow deriving any class + | DeriveLift -- Allow deriving Lift + | DerivingStrategies + | DerivingVia -- Derive through equal representation + + | TypeSynonymInstances + | FlexibleContexts + | FlexibleInstances + | ConstrainedClassMethods + | MultiParamTypeClasses + | NullaryTypeClasses + | FunctionalDependencies + | UnicodeSyntax + | ExistentialQuantification + | MagicHash + | EmptyDataDecls + | KindSignatures + | RoleAnnotations + | ParallelListComp + | TransformListComp + | MonadComprehensions + | GeneralizedNewtypeDeriving + | RecursiveDo + | PostfixOperators + | TupleSections + | PatternGuards + | LiberalTypeSynonyms + | RankNTypes + | ImpredicativeTypes + | TypeOperators + | ExplicitNamespaces + | PackageImports + | ExplicitForAll + | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional + | DatatypeContexts + | NondecreasingIndentation + | RelaxedLayout + | TraditionalRecordSyntax + | LambdaCase + | MultiWayIf + | BinaryLiterals + | NegativeLiterals + | HexFloatLiterals + | DuplicateRecordFields + | OverloadedLabels + | EmptyCase + | PatternSynonyms + | PartialTypeSignatures + | NamedWildCards + | StaticPointers + | TypeApplications + | Strict + | StrictData + | EmptyDataDeriving + | NumericUnderscores + | QuantifiedConstraints + | StarIsType + | ImportQualifiedPost + | CUSKs + | StandaloneKindSignatures + | LexicalNegation + | FieldSelectors + | OverloadedRecordDot + | OverloadedRecordUpdate + | TypeAbstractions + | ExtendedLiterals + | ListTuplePuns + deriving (Eq, Enum, Show, Generic, Bounded) +-- 'Ord' and 'Bounded' are provided for GHC API users (see discussions +-- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and +-- https://gitlab.haskell.org/ghc/ghc/merge_requests/826). +instance Ord Extension where compare a b = compare (fromEnum a) (fromEnum b) +#endif instance Binary Extension ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -81,7 +81,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@ if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@, ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8da934689408397d09d122aac7142976d908dcad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8da934689408397d09d122aac7142976d908dcad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 11:14:57 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 07:14:57 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <6602ae31ef48_2edda524018c8739a1@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: d5c5016c by Teo Camarasu at 2024-03-26T11:14:15+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. Resolves #23536 - - - - - 14 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,13 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; void $ return ns_spec -- to avoid CPP incurred unused variable warning + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1209,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1329,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2119,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2435,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2464,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2601,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2614,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2626,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2637,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2695,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2758,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2772,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1514,10 +1514,11 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + -- TODO: factor out toEnum/fromEnum stuff + qIsExtEnabled = xoptM . toEnum . fromEnum qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map (toEnum . fromEnum) . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Nothing +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -158,7 +158,6 @@ toolTargets = [ binary -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot - , ghcBootTh , ghcPlatform , ghcToolchain , ghcToolchainBin @@ -172,7 +171,6 @@ toolTargets = [ binary , mtl , parsec , time - , templateHaskell , text , transformers , semaphoreCompat ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,161 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + ) + where import Data.Binary +#if MIN_VERSION_ghc_boot_th(9,11,0) import GHC.LanguageExtensions.Type +#else +import Prelude -- See note [Why do we import Prelude here?] +import GHC.Generics + +data Extension +-- See Note [Updating flag description in the User's Guide] in +-- GHC.Driver.Session + = Cpp + | OverlappingInstances + | UndecidableInstances + | IncoherentInstances + | UndecidableSuperClasses + | MonomorphismRestriction + | MonoLocalBinds + | DeepSubsumption + | RelaxedPolyRec -- Deprecated + | ExtendedDefaultRules -- Use GHC's extended rules for defaulting + | ForeignFunctionInterface + | UnliftedFFITypes + | InterruptibleFFI + | CApiFFI + | GHCForeignImportPrim + | JavaScriptFFI + | ParallelArrays -- Syntactic support for parallel arrays + | Arrows -- Arrow-notation syntax + | TemplateHaskell + | TemplateHaskellQuotes -- subset of TH supported by stage1, no splice + | QualifiedDo + | QuasiQuotes + | ImplicitParams + | ImplicitPrelude + | ScopedTypeVariables + | AllowAmbiguousTypes + | UnboxedTuples + | UnboxedSums + | UnliftedNewtypes + | UnliftedDatatypes + | BangPatterns + | TypeFamilies + | TypeFamilyDependencies + | TypeInType -- Deprecated + | OverloadedStrings + | OverloadedLists + | NumDecimals + | DisambiguateRecordFields + | RecordWildCards + | NamedFieldPuns + | ViewPatterns + | GADTs + | GADTSyntax + | NPlusKPatterns + | DoAndIfThenElse + | BlockArguments + | RebindableSyntax + | ConstraintKinds + | PolyKinds -- Kind polymorphism + | DataKinds -- Datatype promotion + | TypeData -- allow @type data@ definitions + | InstanceSigs + | ApplicativeDo + | LinearTypes + | RequiredTypeArguments -- Visible forall (VDQ) in types of terms + + | StandaloneDeriving + | DeriveDataTypeable + | AutoDeriveTypeable -- Automatic derivation of Typeable + | DeriveFunctor + | DeriveTraversable + | DeriveFoldable + | DeriveGeneric -- Allow deriving Generic/1 + | DefaultSignatures -- Allow extra signatures for defmeths + | DeriveAnyClass -- Allow deriving any class + | DeriveLift -- Allow deriving Lift + | DerivingStrategies + | DerivingVia -- Derive through equal representation + + | TypeSynonymInstances + | FlexibleContexts + | FlexibleInstances + | ConstrainedClassMethods + | MultiParamTypeClasses + | NullaryTypeClasses + | FunctionalDependencies + | UnicodeSyntax + | ExistentialQuantification + | MagicHash + | EmptyDataDecls + | KindSignatures + | RoleAnnotations + | ParallelListComp + | TransformListComp + | MonadComprehensions + | GeneralizedNewtypeDeriving + | RecursiveDo + | PostfixOperators + | TupleSections + | PatternGuards + | LiberalTypeSynonyms + | RankNTypes + | ImpredicativeTypes + | TypeOperators + | ExplicitNamespaces + | PackageImports + | ExplicitForAll + | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional + | DatatypeContexts + | NondecreasingIndentation + | RelaxedLayout + | TraditionalRecordSyntax + | LambdaCase + | MultiWayIf + | BinaryLiterals + | NegativeLiterals + | HexFloatLiterals + | DuplicateRecordFields + | OverloadedLabels + | EmptyCase + | PatternSynonyms + | PartialTypeSignatures + | NamedWildCards + | StaticPointers + | TypeApplications + | Strict + | StrictData + | EmptyDataDeriving + | NumericUnderscores + | QuantifiedConstraints + | StarIsType + | ImportQualifiedPost + | CUSKs + | StandaloneKindSignatures + | LexicalNegation + | FieldSelectors + | OverloadedRecordDot + | OverloadedRecordUpdate + | TypeAbstractions + | ExtendedLiterals + | ListTuplePuns + deriving (Eq, Enum, Show, Generic, Bounded) +-- 'Ord' and 'Bounded' are provided for GHC API users (see discussions +-- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and +-- https://gitlab.haskell.org/ghc/ghc/merge_requests/826). +instance Ord Extension where compare a b = compare (fromEnum a) (fromEnum b) +#endif instance Binary Extension ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -81,7 +81,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@ if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@, ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5c5016ce2f0ba935ead334d4ede9ddb60a720ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5c5016ce2f0ba935ead334d4ede9ddb60a720ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 11:29:24 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 26 Mar 2024 07:29:24 -0400 Subject: [Git][ghc/ghc][wip/T23923-mikolaj-take-2] Fix the horrid perf bug in coVarsOfType Message-ID: <6602b194df387_2edda52ce10c4743bb@gitlab.mail> Simon Peyton Jones pushed to branch wip/T23923-mikolaj-take-2 at Glasgow Haskell Compiler / GHC Commits: 10f2d937 by Simon Peyton Jones at 2024-03-26T11:28:25+00:00 Fix the horrid perf bug in coVarsOfType See #24591 - - - - - 1 changed file: - compiler/GHC/Core/TyCo/Rep.hs Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1826,6 +1826,38 @@ Here deep_fvs and deep_tcf are mutually recursive, unlike fvs and tcf. But, amazingly, we get good code here too. GHC is careful not to mark TyCoFolder data constructor for deep_tcf as a loop breaker, so the record selections still cancel. And eta expansion still happens too. + +Note [Use explicit recursion in foldTyCo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In foldTyCo you'll see things like: + go_tys _ [] = mempty + go_tys env (t:ts) = go_ty env t `mappend` go_tys env ts +where we use /explicit recursion/. You might wonder about using foldr instead: + go_tys env = foldl (\t acc -> go_ty env t `mappend` acc) mempty +Or maybe or foldl', or foldr. + +But don't do that for two reasons (see #24591) + +* We sometimes instantiate `a` to (Endo VarSet). Remembering + newtype Endo a = Endo (a->a) + after inlining `foldTyCo` bodily, the explicit recursion looks like + go_tys _ [] = \acc -> acc + go_tys env (t:ts) = \acc -> go_ty env t (go_tys env ts acc) + The strictness analyser has no problem spotting that this function is + strict in `acc`, provided `go_ty` is. + + But in the foldl form that is /much/ less obvious, and the strictness + analyser fails utterly. Result: lots and lots of thunks get built. In + !12037, Mikolaj found that GHC allocated allocated /six times/ as much heap + on test perf/compiler/T9198 as a result of this single problem! + +* Second, while I think that using `foldr` would be fine (simple experiments in + #24591 suggest as much), it builds a local loop (with env free) and I'm not 100% + confident it'll be lambda lifted in the end. It seems more direct just to write + the code we want. + + On the other hand in `go_cvs` we might hope that the `foldr` will fuse with the + `dVarSetElems` so I have used `foldr`. -} data TyCoFolder env a @@ -1864,12 +1896,11 @@ foldTyCo (TyCoFolder { tcf_view = view = let !env' = tycobinder env tv vis -- Avoid building a thunk here in go_ty env (varType tv) `mappend` go_ty env' inner - -- Explicit recursion because using foldr builds a local - -- loop (with env free) and I'm not confident it'll be - -- lambda lifted in the end + -- See Note [Use explicit recursion in foldTyCo] go_tys _ [] = mempty go_tys env (t:ts) = go_ty env t `mappend` go_tys env ts + -- See Note [Use explicit recursion in foldTyCo] go_cos _ [] = mempty go_cos env (c:cs) = go_co env c `mappend` go_cos env cs @@ -1905,7 +1936,9 @@ foldTyCo (TyCoFolder { tcf_view = view go_prov env (ProofIrrelProv co) = go_co env co go_prov _ (PluginProv _ cvs) = go_cvs env cvs - go_cvs env cvs = foldl' (\ !acc cv -> acc `mappend` covar env cv) mempty (dVarSetElems cvs) + -- See Note [Use explicit recursion in foldTyCo] + go_cvs env cvs = foldr (add_one env) mempty (dVarSetElems cvs) + add_one env cv acc = covar env cv `mappend` acc -- | A view function that looks through nothing. noView :: Type -> Maybe Type View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/10f2d937bcb3f44a5fd5d258a8d46270ace6b29c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/10f2d937bcb3f44a5fd5d258a8d46270ace6b29c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 13:59:46 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 26 Mar 2024 09:59:46 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 23 commits: Improve toInteger @Word32 on 64-bit platforms Message-ID: <6602d4d24f5fa_2edda569b1300908cb@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - d1371219 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1eebfb65 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - ccf34222 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 1c4a2e14 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Spelling, layout, pretty-printing only - - - - - e5e487da by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 42fd4071 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - 5e37b4d5 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - d4c04c9f by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - f330f0ab by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Remove a long-commented-out line Pure refactoring - - - - - 0edce85a by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. - - - - - cfd5e4a1 by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Testsuite message changes from simplifier improvements - - - - - 2ee2620f by Simon Peyton Jones at 2024-03-26T11:39:22+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 2cf3c6e7 by Simon Peyton Jones at 2024-03-26T13:59:29+00:00 Move mergeCaseAlts to prepareAlts This makes it happen on InAlts, which reduces the number of Simplifier iterations by one. - - - - - 23 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/FloatOut.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d66a7c832871a7cb537f4f03d555a469ffcb6a31...2cf3c6e74d31c4635d5d47276042ada323523403 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d66a7c832871a7cb537f4f03d555a469ffcb6a31...2cf3c6e74d31c4635d5d47276042ada323523403 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 14:18:28 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 26 Mar 2024 10:18:28 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] Move mergeCaseAlts to prepareAlts Message-ID: <6602d93428a43_2edda57289cac93821@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 7ac340e0 by Simon Peyton Jones at 2024-03-26T14:17:37+00:00 Move mergeCaseAlts to prepareAlts This makes it happen on InAlts, which reduces the number of Simplifier iterations by one. See Note [Merging nested cases] in GHC.Core.Opt.Simplify.Utils - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -3342,7 +3342,7 @@ simplAlts env0 scrut case_bndr alts cont' ; (alt_env', scrut', case_bndr') <- improveSeq fam_envs env2 scrut case_bndr case_bndr2 alts - ; (imposs_deflt_cons, in_alts) <- prepareAlts scrut' case_bndr alts + ; (imposs_deflt_cons, in_alts) <- prepareAlts (seMode env0) scrut' case_bndr alts -- NB: it's possible that the returned in_alts is empty: this is handled -- by the caller (rebuildCase) in the missingAlt function -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -74,7 +74,6 @@ import GHC.Types.Demand import GHC.Types.Var.Set import GHC.Types.Basic -import GHC.Data.Maybe ( orElse ) import GHC.Data.OrdList ( isNilOL ) import GHC.Data.FastString ( fsLit ) @@ -2403,24 +2402,28 @@ OutId. Test simplCore/should_compile/simpl013 apparently shows this up, although I'm not sure exactly how.. -} -prepareAlts :: OutExpr -> InId -> [InAlt] -> SimplM ([AltCon], [InAlt]) +prepareAlts :: SimplMode -> OutExpr -> InId -> [InAlt] -> SimplM ([AltCon], [InAlt]) -- The returned alternatives can be empty, none are possible -- -- Note that case_bndr is an InId; see Note [Shadowing in prepareAlts] -prepareAlts scrut case_bndr alts +prepareAlts mode scrut case_bndr alts | Just (tc, tys) <- splitTyConApp_maybe (idType case_bndr) = do { us <- getUniquesM - ; let (idcs1, alts1) = filterAlts tc tys imposs_cons alts - (yes2, alts2) = refineDefaultAlt us (idMult case_bndr) tc tys idcs1 alts1 + ; let (yes1, alts1) | sm_case_merge mode = mergeCaseAlts case_bndr alts + | otherwise = (False, alts) + -- See Note [Merging nested cases] + (idcs2, alts2) = filterAlts tc tys imposs_cons alts1 + (yes3, alts3) = refineDefaultAlt us (idMult case_bndr) tc tys idcs2 alts2 -- The multiplicity on case_bndr's is the multiplicity of the -- case expression The newly introduced patterns in -- refineDefaultAlt must be scaled by this multiplicity - (yes3, idcs3, alts3) = combineIdenticalAlts idcs1 alts2 + (yes4, idcs4, alts4) = combineIdenticalAlts idcs2 alts3 -- "idcs" stands for "impossible default data constructors" -- i.e. the constructors that can't match the default case - ; when yes2 $ tick (FillInCaseDefault case_bndr) - ; when yes3 $ tick (AltMerge case_bndr) - ; return (idcs3, alts3) } + ; when yes1 $ tick (CaseMerge case_bndr) + ; when yes3 $ tick (FillInCaseDefault case_bndr) + ; when yes4 $ tick (AltMerge case_bndr) + ; return (idcs4, alts4) } | otherwise -- Not a data type, so nothing interesting happens = return ([], alts) @@ -2429,6 +2432,24 @@ prepareAlts scrut case_bndr alts Var v -> otherCons (idUnfolding v) _ -> [] +{- Note [Merging nested cases] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The basic case-merge stuff is described in Note [Merge Nested Cases] in GHC.Core.Utils + +We do it here in `prepareAlts` (on InAlts) rather than after (on OutAlts) for two reasons: + +* It "belongs" here with `filterAlts`, `refineDefaultAlt` and `combineIdenticalAlts`. + +* In test perf/compiler/T22428 I found that I was getting extra Simplifer iterations: + 1. Create a join point + 2. That join point gets inlined at all call sites, so it is now dead. + 3. Case-merge happened, but left behind some trivial bindings (see `mergeCaseAlts`) + 4. Get rid of the trivial bindings + The first two seem reasonable. It's imaginable that we could do better on + (3), by making case-merge join-point-aware, but it's not trivial. But the + fourth is just stupid. Rather than always do an extra iteration, it's better + to do the transformation on the input-end of teh Simplifier. +-} {- ************************************************************************ @@ -2439,74 +2460,9 @@ prepareAlts scrut case_bndr alts mkCase tries these things -* Note [Merge Nested Cases] * Note [Eliminate Identity Case] * Note [Scrutinee Constant Folding] -Note [Merge Nested Cases] -~~~~~~~~~~~~~~~~~~~~~~~~~ - case e of b { ==> case e of b { - p1 -> rhs1 p1 -> rhs1 - ... ... - pm -> rhsm pm -> rhsm - _ -> case b of b' { pn -> let b'=b in rhsn - pn -> rhsn ... - ... po -> let b'=b in rhso - po -> rhso _ -> let b'=b in rhsd - _ -> rhsd - } - -which merges two cases in one case when -- the default alternative of -the outer case scrutinises the same variable as the outer case. This -transformation is called Case Merging. It avoids that the same -variable is scrutinised multiple times. - -Wrinkles - -(MC1) `tryMergeCase` "looks though" an inner single-alternative case-on-variable. - For example - case x of { - ...outer-alts... - DEFAULT -> case y of (a,b) -> - case x of { A -> rhs1; B -> rhs2 } - ===> - case x of - ...outer-alts... - a -> case y of (a,b) -> rhs1 - B -> case y of (a,b) -> rhs2 - - This duplicates the `case y` but it removes the case x; so it is a win - in terms of execution time (combining the cases on x) at the cost of - perhaps duplicating the `case y`. A case in point is integerEq, which - is defined thus - integerEq :: Integer -> Integer -> Bool - integerEq !x !y = isTrue# (integerEq# x y) - which becomes - integerEq - = \ (x :: Integer) (y_aAL :: Integer) -> - case x of x1 { __DEFAULT -> - case y of y1 { __DEFAULT -> - case x1 of { - IS x2 -> case y1 of { - __DEFAULT -> GHC.Types.False; - IS y2 -> tagToEnum# @Bool (==# x2 y2) }; - IP x2 -> ... - IN x2 -> ... - We want to merge the outer `case x` with the inner `case x1`. - - This story is not fully robust; it will be defeated by a let-binding, - whih we don't want to duplicate. But accounting for single-alternative - case-on-variable is easy to do, and seems useful in common cases so - `tryMergeCase` does it. - -(MC2) The auxiliary bindings b'=b are annoying, because they force another - simplifier pass, but there seems no easy way to avoid them. See - Note [Which transformations are innocuous] in GHC.Core.Opt.Stats. - -See also -* Note [Example of case-merging and caseRules] -* Note [Cascading case merge] - Note [Eliminate Identity Case] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ case e of ===> e @@ -2675,7 +2631,7 @@ and now we can do case-merge again, getting the desired -} -mkCase, mkCase1, mkCase2, mkCase3 +mkCase, mkCase2, mkCase3 :: SimplMode -> OutExpr -> OutId -> OutType -> [OutAlt] -- Alternatives in standard (increasing) order @@ -2688,76 +2644,12 @@ mkCase, mkCase1, mkCase2, mkCase3 -- Note [Cascading case merge] -------------------------------------------------- -mkCase mode scrut outer_bndr alts_ty alts - | sm_case_merge mode - , Just alts' <- tryMergeCase outer_bndr alts - = do { tick (CaseMerge outer_bndr) - ; mkCase1 mode scrut outer_bndr alts_ty alts' } - -- Warning: don't call mkCase recursively! - -- Firstly, there's no point, because inner alts have already had - -- mkCase applied to them, so they won't have a case in their default - -- Secondly, if you do, you get an infinite loop, because the bindCaseBndr - -- in munge_rhs may put a case into the DEFAULT branch! - | otherwise - = mkCase1 mode scrut outer_bndr alts_ty alts - -tryMergeCase :: OutId -> [OutAlt] -> Maybe [OutAlt] --- See Note [Merge Nested Cases] -tryMergeCase outer_bndr (Alt DEFAULT _ deflt_rhs : outer_alts) - = case go 5 (\e -> e) emptyVarSet deflt_rhs of - Nothing -> Nothing - Just inner_alts -> Just (mergeAlts outer_alts inner_alts) - -- NB: mergeAlts gives priority to the left - -- case x of - -- A -> e1 - -- DEFAULT -> case x of - -- A -> e2 - -- B -> e3 - -- When we merge, we must ensure that e1 takes - -- precedence over e2 as the value for A! - where - go :: Int -> (OutExpr -> OutExpr) -> VarSet -> OutExpr -> Maybe [OutAlt] - -- In the call (go wrap free_bndrs rhs), the `wrap` function has free `free_bndrs`; - -- so do not push `wrap` under any binders that would shadow `free_bndrs` - -- - -- The 'n' is just a depth-bound to avoid pathalogical quadratic behaviour with - -- case x1 of DEFAULT -> case x2 of DEFAULT -> case x3 of DEFAULT -> ... - -- when for each `case` we'll look down the whole chain to see if there is - -- another `case` on that same variable. Also all of these (case xi) evals - -- get duplicated in each branch of the outer case, so 'n' controls how much - -- duplication we are prepared to put up with. - go 0 _ _ _ = Nothing - - go n wrap free_bndrs (Tick t rhs) - = go n (wrap . Tick t) free_bndrs rhs - go _ wrap free_bndrs (Case (Var inner_scrut_var) inner_bndr _ inner_alts) - | inner_scrut_var == outer_bndr - , let wrap_let rhs' | isDeadBinder inner_bndr = rhs' - | otherwise = Let (NonRec inner_bndr (Var outer_bndr)) rhs' - -- The let is OK even for unboxed binders, - free_bndrs' = extendVarSet free_bndrs outer_bndr - = Just [ assert (not (any (`elemVarSet` free_bndrs') bndrs)) $ - Alt con bndrs (wrap (wrap_let rhs)) - | Alt con bndrs rhs <- inner_alts ] - go n wrap free_bndrs (Case (Var inner_scrut) inner_bndr ty inner_alts) - | [Alt con bndrs rhs] <- inner_alts -- Wrinkle (MC1) - , let wrap_case rhs' = Case (Var inner_scrut) inner_bndr ty $ - tryMergeCase inner_bndr alts `orElse` alts - where - alts = [Alt con bndrs rhs'] - = assert (not (outer_bndr `elem` (inner_bndr : bndrs))) $ - go (n-1) (wrap . wrap_case) (free_bndrs `extendVarSet` inner_scrut) rhs - - go _ _ _ _ = Nothing - -tryMergeCase _ _ = Nothing - -------------------------------------------------- -- 2. Eliminate Identity Case -- See Note [Eliminate Identity Case] -------------------------------------------------- -mkCase1 _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity case +mkCase _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity case | all identity_alt alts = do { tick (CaseIdentity case_bndr) ; return (mkTicks ticks $ re_cast scrut rhs1) } @@ -2796,7 +2688,7 @@ mkCase1 _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity cas re_cast scrut (Cast rhs co) = Cast (re_cast scrut rhs) co re_cast scrut _ = scrut -mkCase1 mode scrut bndr alts_ty alts = mkCase2 mode scrut bndr alts_ty alts +mkCase mode scrut bndr alts_ty alts = mkCase2 mode scrut bndr alts_ty alts -------------------------------------------------- -- 2. Scrutinee Constant Folding @@ -2919,64 +2811,4 @@ Note [Dead binders] Note that dead-ness is maintained by the simplifier, so that it is accurate after simplification as well as before. - -Note [Cascading case merge] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Case merging should cascade in one sweep, because it -happens bottom-up - - case e of a { - DEFAULT -> case a of b - DEFAULT -> case b of c { - DEFAULT -> e - A -> ea - B -> eb - C -> ec -==> - case e of a { - DEFAULT -> case a of b - DEFAULT -> let c = b in e - A -> let c = b in ea - B -> eb - C -> ec -==> - case e of a { - DEFAULT -> let b = a in let c = b in e - A -> let b = a in let c = b in ea - B -> let b = a in eb - C -> ec - - -However here's a tricky case that we still don't catch, and I don't -see how to catch it in one pass: - - case x of c1 { I# a1 -> - case a1 of c2 -> - 0 -> ... - DEFAULT -> case x of c3 { I# a2 -> - case a2 of ... - -After occurrence analysis (and its binder-swap) we get this - - case x of c1 { I# a1 -> - let x = c1 in -- Binder-swap addition - case a1 of c2 -> - 0 -> ... - DEFAULT -> case x of c3 { I# a2 -> - case a2 of ... - -When we simplify the inner case x, we'll see that -x=c1=I# a1. So we'll bind a2 to a1, and get - - case x of c1 { I# a1 -> - case a1 of c2 -> - 0 -> ... - DEFAULT -> case a1 of ... - -This is correct, but we can't do a case merge in this sweep -because c2 /= a1. Reason: the binding c1=I# a1 went inwards -without getting changed to c1=I# c2. - -I don't think this is worth fixing, even if I knew how. It'll -all come out in the next pass anyway. -} ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -16,7 +16,7 @@ module GHC.Core.Utils ( -- * Taking expressions apart findDefault, addDefault, findAlt, isDefaultAlt, - mergeAlts, trimConArgs, + mergeAlts, mergeCaseAlts, trimConArgs, filterAlts, combineIdenticalAlts, refineDefaultAlt, scaleAltsBy, @@ -642,6 +642,61 @@ Similar things can happen (augmented by GADTs) when the Simplifier filters down the matching alternatives in GHC.Core.Opt.Simplify.rebuildCase. -} +--------------------------------- +mergeCaseAlts :: Id -> [CoreAlt] -> (Bool, [CoreAlt]) +-- Result: (yes, alts'); if 'yes' then something actually happened +-- See Note [Merge Nested Cases] +mergeCaseAlts outer_bndr alts + | (Alt DEFAULT _ deflt_rhs : outer_alts) <- alts + , Just inner_alts <- go 5 (\e -> e) emptyVarSet deflt_rhs + = (True, mergeAlts outer_alts inner_alts) + -- NB: mergeAlts gives priority to the left + -- case x of + -- A -> e1 + -- DEFAULT -> case x of + -- A -> e2 + -- B -> e3 + -- When we merge, we must ensure that e1 takes + -- precedence over e2 as the value for A! + + | otherwise + = (False, alts) + where + go :: Int -> (OutExpr -> OutExpr) -> VarSet -> OutExpr -> Maybe [OutAlt] + -- In the call (go wrap free_bndrs rhs), the `wrap` function has free `free_bndrs`; + -- so do not push `wrap` under any binders that would shadow `free_bndrs` + -- + -- The 'n' is just a depth-bound to avoid pathalogical quadratic behaviour with + -- case x1 of DEFAULT -> case x2 of DEFAULT -> case x3 of DEFAULT -> ... + -- when for each `case` we'll look down the whole chain to see if there is + -- another `case` on that same variable. Also all of these (case xi) evals + -- get duplicated in each branch of the outer case, so 'n' controls how much + -- duplication we are prepared to put up with. + go 0 _ _ _ = Nothing + + go n wrap free_bndrs (Tick t rhs) + = go n (wrap . Tick t) free_bndrs rhs + go _ wrap free_bndrs (Case (Var inner_scrut_var) inner_bndr _ inner_alts) + | inner_scrut_var == outer_bndr + , let wrap_let rhs' = Let (NonRec inner_bndr (Var outer_bndr)) rhs' + -- inner_bndr is never dead! It's the scrutinee! + -- The let is OK even for unboxed binders, + free_bndrs' = extendVarSet free_bndrs outer_bndr + do_one (Alt con bndrs rhs) + | any (`elemVarSet` free_bndrs') bndrs = Nothing + | otherwise = Just (Alt con bndrs (wrap (wrap_let rhs))) + = mapM do_one inner_alts + go n wrap free_bndrs (Case (Var inner_scrut) inner_bndr ty inner_alts) + | [Alt con bndrs rhs] <- inner_alts -- Wrinkle (MC1) + , not (outer_bndr `elem` (inner_bndr : bndrs)) + , let wrap_case rhs' = Case (Var inner_scrut) inner_bndr ty $ + snd (mergeCaseAlts inner_bndr [Alt con bndrs rhs']) + -- Recursive call: see Note [Cascading case merge] + = go (n-1) (wrap . wrap_case) (free_bndrs `extendVarSet` inner_scrut) rhs + + go _ _ _ _ = Nothing + + --------------------------------- mergeAlts :: [Alt a] -> [Alt a] -> [Alt a] -- ^ Merge alternatives preserving order; alternatives in @@ -757,7 +812,132 @@ refineDefaultAlt us mult tycon tys imposs_deflt_cons all_alts | otherwise -- The common case = (False, all_alts) -{- Note [Refine DEFAULT case alternatives] +{- Note [Merge Nested Cases] +~~~~~~~~~~~~~~~~~~~~~~~~~ + case e of b { ==> case e of b { + p1 -> rhs1 p1 -> rhs1 + ... ... + pm -> rhsm pm -> rhsm + _ -> case b of b' { pn -> let b'=b in rhsn + pn -> rhsn ... + ... po -> let b'=b in rhso + po -> rhso _ -> let b'=b in rhsd + _ -> rhsd + } + +which merges two cases in one case when -- the default alternative of +the outer case scrutinises the same variable as the outer case. This +transformation is called Case Merging. It avoids that the same +variable is scrutinised multiple times. + +Wrinkles + +(MC1) `tryMergeCase` "looks though" an inner single-alternative case-on-variable. + For example + case x of { + ...outer-alts... + DEFAULT -> case y of (a,b) -> + case x of { A -> rhs1; B -> rhs2 } + ===> + case x of + ...outer-alts... + a -> case y of (a,b) -> rhs1 + B -> case y of (a,b) -> rhs2 + + This duplicates the `case y` but it removes the case x; so it is a win + in terms of execution time (combining the cases on x) at the cost of + perhaps duplicating the `case y`. A case in point is integerEq, which + is defined thus + integerEq :: Integer -> Integer -> Bool + integerEq !x !y = isTrue# (integerEq# x y) + which becomes + integerEq + = \ (x :: Integer) (y_aAL :: Integer) -> + case x of x1 { __DEFAULT -> + case y of y1 { __DEFAULT -> + case x1 of { + IS x2 -> case y1 of { + __DEFAULT -> GHC.Types.False; + IS y2 -> tagToEnum# @Bool (==# x2 y2) }; + IP x2 -> ... + IN x2 -> ... + We want to merge the outer `case x` with thea inner `case x1`. + + This story is not fully robust; it will be defeated by a let-binding, + whih we don't want to duplicate. But accounting for single-alternative + case-on-variable is easy to do, and seems useful in common cases so + `tryMergeCase` does it. + +(MC2) The auxiliary bindings b'=b are annoying, because they force another + simplifier pass, but there seems no easy way to avoid them. See + Note [Which transformations are innocuous] in GHC.Core.Opt.Stats. + +See also +* Note [Example of case-merging and caseRules] in GHC.Core.Opt.Simplify.Utils +* Note [Cascading case merge] + +Note [Cascading case merge] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Case merging should cascade in one sweep, because it +happens bottom-up + + case e of a { + DEFAULT -> case a of b + DEFAULT -> case b of c { + DEFAULT -> e + A -> ea + B -> eb + C -> ec +==> + case e of a { + DEFAULT -> case a of b + DEFAULT -> let c = b in e + A -> let c = b in ea + B -> eb + C -> ec +==> + case e of a { + DEFAULT -> let b = a in let c = b in e + A -> let b = a in let c = b in ea + B -> let b = a in eb + C -> ec + + +However here's a tricky case that we still don't catch, and I don't +see how to catch it in one pass: + + case x of c1 { I# a1 -> + case a1 of c2 -> + 0 -> ... + DEFAULT -> case x of c3 { I# a2 -> + case a2 of ... + +After occurrence analysis (and its binder-swap) we get this + + case x of c1 { I# a1 -> + let x = c1 in -- Binder-swap addition + case a1 of c2 -> + 0 -> ... + DEFAULT -> case x of c3 { I# a2 -> + case a2 of ... + +When we simplify the inner case x, we'll see that +x=c1=I# a1. So we'll bind a2 to a1, and get + + case x of c1 { I# a1 -> + case a1 of c2 -> + 0 -> ... + DEFAULT -> case a1 of ... + +This is correct, but we can't do a case merge in this sweep +because c2 /= a1. Reason: the binding c1=I# a1 went inwards +without getting changed to c1=I# c2. + +I don't think this is worth fixing, even if I knew how. It'll +all come out in the next pass anyway. + + +Note [Refine DEFAULT case alternatives] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ refineDefaultAlt replaces the DEFAULT alt with a constructor if there is one possible value it could be. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ac340e06d2f6f05672cb5f69fc9a5ab5409ac1b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ac340e06d2f6f05672cb5f69fc9a5ab5409ac1b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 14:28:43 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 10:28:43 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] 274 commits: Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. Message-ID: <6602db9bd6251_2edda578a1324970a2@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 11d6f7b0 by Jade at 2024-03-26T15:33:03+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 21 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aac5d52ab7fd496a31c0fc78b6daa79c4df120b0...11d6f7b0ccae28e2c6dcebe01cea62caf8a15490 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aac5d52ab7fd496a31c0fc78b6daa79c4df120b0...11d6f7b0ccae28e2c6dcebe01cea62caf8a15490 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 14:57:49 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 26 Mar 2024 10:57:49 -0400 Subject: [Git][ghc/ghc][wip/T24359] Progress Message-ID: <6602e26d3e3a8_2edda5876aa2c10754@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: f5e3041e by Simon Peyton Jones at 2024-03-26T14:57:30+00:00 Progress - - - - - 2 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/Tc/Gen/Sig.hs Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -805,11 +805,19 @@ data TcSpecPrag -- ^ The Id to be specialised, a wrapper that specialises the -- polymorphic function, and inlining spec for the specialised function - | SpecPragE { spe_bndrs :: [Var] - , spe_lhs_binds :: TcEvBinds - , spe_call :: LHsExpr GhcTc - , spe_rhs_binds :: TcEvBinds - , spe_inl :: InlinePragma } + | SpecPragE { spe_tv_bndrs :: [TyVar] + , spe_id_bndrs :: [Id] + + , spe_lhs_ev_bndrs :: [EvVar] + , spe_lhs_binds :: TcEvBinds -- Closes spe_call using variables in + -- tv_bndrs, lhs_ev_bndrs, id_bndrs + + , spe_rhs_ev_bndrs :: [EvVar] + , spe_rhs_binds :: TcEvBinds -- Closes spe_call using variables in + -- tv_bndrs, rhs_ev_bndrs, id_bndrs + + , spe_call :: LHsExpr GhcTc + , spe_inl :: InlinePragma } noSpecPrags :: TcSpecPrags noSpecPrags = SpecPrags [] @@ -952,9 +960,10 @@ pprTcSpecPrags (SpecPrags ps) = vcat (map (ppr . unLoc) ps) instance Outputable TcSpecPrag where ppr (SpecPrag var _ inl) = text (extractSpecPragName $ inl_src inl) <+> pprSpec var (text "") inl - ppr (SpecPragE { spe_bndrs = bndrs, spe_call = spec_e, spe_inl = inl }) + ppr (SpecPragE { spe_tv_bndrs = tv_bndrs, spe_id_bndrs = id_bndrs + , spe_call = spec_e, spe_inl = inl }) = text (extractSpecPragName $ inl_src inl) - <+> hang (ppr bndrs) 2 (pprLExpr spec_e) + <+> hang (ppr (tv_bndrs ++ id_bndrs) 2 (pprLExpr spec_e) pprMinimalSig :: (OutputableBndr name) => LBooleanFormula (GenLocated l name) -> SDoc ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -872,13 +872,15 @@ tcSpecPrag _poly_id (SpecSigE nm bndrs spec_e inl) ; qtkvs <- quantifyTyVars skol_info DefaultNonStandardTyVars weeded_dvs -- Left hand side of the RULE - ; rule_evs <- mk_quant_evs quant_cts + ; lhs_evs <- mk_quant_evs quant_cts ; (implic1, lhs_binds) <- buildImplicationFor tc_lvl skol_info_anon - qtkvs rule_evs residual_wanted + qtkvs lhs_evs residual_wanted - -- rhs_binds uses rule_evs to build `wanted` (NB not just `residual_wanted`) + -- rhs_binds uses rhs_evs to build `wanted` (NB not just `residual_wanted`) + ; let rhs_preds = mkMinimalBySCs id quant_preds + ; rhs_evs <- mapM newEvVar rhs_preds ; (implic2, rhs_binds) <- buildImplicationFor tc_lvl skol_info_anon - qtkvs rule_evs wanted + qtkvs rhs_evs wanted ; emitImplications (implic1 `unionBags` implic2) @@ -887,11 +889,15 @@ tcSpecPrag _poly_id (SpecSigE nm bndrs spec_e inl) vcat [ text "all_bndrs:" <+> ppr all_bndrs , text "spec_e:" <+> ppr spec_e' , text "inl:" <+> ppr inl ] - ; return [SpecPragE { spe_bndrs = all_bndrs - , spe_lhs_binds = lhs_binds - , spe_call = spec_e' - , spe_rhs_binds = rhs_binds - , spe_inl = inl }] } + ; return [SpecPragE { spe_tv_bndrs = qtkvs + , spe_id_bndrs = id_bndrs + , spe_lhs_ev_bndrs = rule_evs + , spe_lhs_binds = lhs_binds + , spe_rhs_ev_bndrs = rhs_evs + , spe_rhs_binds = rhs_binds + + , spe_call = spec_e' + , spe_inl = inl }] } tcSpecPrag _ prag = pprPanic "tcSpecPrag" (ppr prag) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5e3041ef9426801993a592bdcaf67eced9e5dbf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5e3041ef9426801993a592bdcaf67eced9e5dbf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:04:48 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 11:04:48 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6602e41041dc1_2edda58bb945c11443a@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: 31761c59 by Jade at 2024-03-26T16:09:00+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -29,156 +29,148 @@ module System.IO -- descriptors when they have run out, it is your responsibility to -- ensure that this doesn't happen. - -- ** Standard handles - -- | Three handles are allocated during program initialisation, - -- and are initially open. - stdin, - stdout, - stderr, - -- * Opening and closing files - -- ** Opening files - withFile, - openFile, - IOMode(ReadMode, WriteMode, AppendMode, ReadWriteMode), - -- ** Closing files - hClose, - -- ** Special cases - -- | These functions are also exported by the "Prelude". - readFile, - readFile', - writeFile, - appendFile, - -- ** File locking - -- $locking - -- * Operations on handles - -- ** Determining and changing the size of a file - hFileSize, - hSetFileSize, - -- ** Detecting the end of input - hIsEOF, - isEOF, - -- ** Buffering operations - BufferMode(NoBuffering, LineBuffering, BlockBuffering), - hSetBuffering, - hGetBuffering, - hFlush, - -- ** Repositioning handles - hGetPosn, - hSetPosn, - HandlePosn, - hSeek, - SeekMode(AbsoluteSeek, RelativeSeek, SeekFromEnd), - hTell, - -- ** Handle properties - hIsOpen, - hIsClosed, - hIsReadable, - hIsWritable, - hIsSeekable, - -- ** Terminal operations (not portable: GHC only) - hIsTerminalDevice, - hSetEcho, - hGetEcho, - -- ** Showing handle state (not portable: GHC only) - hShow, - -- * Text input and output - -- ** Text input - hWaitForInput, - hReady, - hGetChar, - hGetLine, - hLookAhead, - hGetContents, - hGetContents', - -- ** Text output - hPutChar, - hPutStr, - hPutStrLn, - hPrint, - -- ** Special cases for standard input and output - -- | These functions are also exported by the "Prelude". - interact, - putChar, - putStr, - putStrLn, - print, - getChar, - getLine, - getContents, - getContents', - readIO, - readLn, - -- * Binary input and output - withBinaryFile, - openBinaryFile, - hSetBinaryMode, - hPutBuf, - hGetBuf, - hGetBufSome, - hPutBufNonBlocking, - hGetBufNonBlocking, - -- * Temporary files - openTempFile, - openBinaryTempFile, - openTempFileWithDefaultPermissions, - openBinaryTempFileWithDefaultPermissions, - -- * Unicode encoding\/decoding - -- | A text-mode 'Handle' has an associated 'TextEncoding', which - -- is used to decode bytes into Unicode characters when reading, - -- and encode Unicode characters into bytes when writing. - -- - -- The default 'TextEncoding' is the same as the default encoding - -- on your system, which is also available as 'localeEncoding'. - -- (GHC note: on Windows, we currently do not support double-byte - -- encodings; if the console\'s code page is unsupported, then - -- 'localeEncoding' will be 'latin1'.) - -- - -- Encoding and decoding errors are always detected and reported, - -- except during lazy I/O ('hGetContents', 'getContents', and - -- 'readFile'), where a decoding error merely results in - -- termination of the character stream, as with other I/O errors. - hSetEncoding, - hGetEncoding, - -- ** Unicode encodings - TextEncoding, - latin1, - utf8, - utf8_bom, - utf16, - utf16le, - utf16be, - utf32, - utf32le, - utf32be, - localeEncoding, - char8, - mkTextEncoding, - -- * Newline conversion - -- | In Haskell, a newline is always represented by the character - -- @\'\\n\'@. However, in files and external character streams, a - -- newline may be represented by another character sequence, such - -- as @\'\\r\\n\'@. - -- - -- A text-mode 'Handle' has an associated 'NewlineMode' that - -- specifies how to translate newline characters. The - -- 'NewlineMode' specifies the input and output translation - -- separately, so that for instance you can translate @\'\\r\\n\'@ - -- to @\'\\n\'@ on input, but leave newlines as @\'\\n\'@ on output. - -- - -- The default 'NewlineMode' for a 'Handle' is - -- 'nativeNewlineMode', which does no translation on Unix systems, - -- but translates @\'\\r\\n\'@ to @\'\\n\'@ and back on Windows. - -- - -- Binary-mode 'Handle's do no newline translation at all. - - hSetNewlineMode, - Newline(..), - nativeNewline, - NewlineMode(..), - noNewlineTranslation, - universalNewlineMode, - nativeNewlineMode - ) where + -- ** Standard handles + -- | Three handles are allocated during program initialisation, + -- and are initially open. + stdin, + stdout, + stderr, + -- * Opening and closing files + -- ** Opening files + withFile, + openFile, + IOMode(ReadMode,WriteMode,AppendMode,ReadWriteMode), + -- ** Closing files + hClose, + -- ** Special cases + -- | These functions are also exported by the "Prelude". + readFile, + readFile', + writeFile, + appendFile, + -- ** File locking + -- $locking + -- * Operations on handles + -- ** Determining and changing the size of a file + hFileSize, + hSetFileSize, + -- ** Detecting the end of input + hIsEOF, + isEOF, + -- ** Buffering operations + BufferMode(NoBuffering,LineBuffering,BlockBuffering), + hSetBuffering, + hGetBuffering, + hFlush, + -- ** Repositioning handles + hGetPosn, + hSetPosn, + HandlePosn, + hSeek, + SeekMode(AbsoluteSeek,RelativeSeek,SeekFromEnd), + hTell, + -- ** Handle properties + hIsOpen, + hIsClosed, + hIsReadable, + hIsWritable, + hIsSeekable, + -- ** Terminal operations (not portable: GHC only) + hIsTerminalDevice, + hSetEcho, + hGetEcho, + -- ** Showing handle state (not portable: GHC only) + hShow, + -- * Text input and output + -- ** Text input + hWaitForInput, + hReady, + hGetChar, + hGetLine, + hLookAhead, + hGetContents, + hGetContents', + -- ** Text output + hPutChar, + hPutStr, + hPutStrLn, + hPrint, + -- ** Special cases for standard input and output + -- | These functions are also exported by the "Prelude". + interact, + putChar, + putStr, + putStrLn, + print, + getChar, + getLine, + getContents, + getContents', + readIO, + readLn, + -- * Binary input and output + withBinaryFile, + openBinaryFile, + hSetBinaryMode, + hPutBuf, + hGetBuf, + hGetBufSome, + hPutBufNonBlocking, + hGetBufNonBlocking, + -- * Temporary files + openTempFile, + openBinaryTempFile, + openTempFileWithDefaultPermissions, + openBinaryTempFileWithDefaultPermissions, + -- * Unicode encoding\/decoding + -- | A text-mode 'Handle' has an associated 'TextEncoding', which + -- is used to decode bytes into Unicode characters when reading, + -- and encode Unicode characters into bytes when writing. + -- + -- The default 'TextEncoding' is the same as the default encoding + -- on your system, which is also available as 'localeEncoding'. + -- (GHC note: on Windows, we currently do not support double-byte + -- encodings; if the console\'s code page is unsupported, then + -- 'localeEncoding' will be 'latin1'.) + -- + -- Encoding and decoding errors are always detected and reported, + -- except during lazy I/O ('hGetContents', 'getContents', and + -- 'readFile'), where a decoding error merely results in + -- termination of the character stream, as with other I/O errors. + hSetEncoding, + hGetEncoding, + -- ** Unicode encodings + TextEncoding, + latin1, + utf8, utf8_bom, + utf16, utf16le, utf16be, + utf32, utf32le, utf32be, + localeEncoding, + char8, + mkTextEncoding, + -- * Newline conversion + -- | In Haskell, a newline is always represented by the character + -- @\'\\n\'@. However, in files and external character streams, a + -- newline may be represented by another character sequence, such + -- as @\'\\r\\n\'@. + -- + -- A text-mode 'Handle' has an associated 'NewlineMode' that + -- specifies how to translate newline characters. The + -- 'NewlineMode' specifies the input and output translation + -- separately, so that for instance you can translate @\'\\r\\n\'@ + -- to @\'\\n\'@ on input, but leave newlines as @\'\\n\'@ on output. + -- + -- The default 'NewlineMode' for a 'Handle' is + -- 'nativeNewlineMode', which does no translation on Unix systems, + -- but translates @\'\\r\\n\'@ to @\'\\n\'@ and back on Windows. + -- + -- Binary-mode 'Handle's do no newline translation at all. + -- + hSetNewlineMode, + Newline(..), nativeNewline, + NewlineMode(..), + noNewlineTranslation, universalNewlineMode, nativeNewlineMode, + ) where import GHC.Internal.System.IO @@ -199,3 +191,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -172,7 +173,7 @@ isEOF = hIsEOF stdin -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hLookAhead :: Handle -> IO Char hLookAhead handle = @@ -182,7 +183,7 @@ hLookAhead handle = -- Buffering Operations -- Three kinds of buffering are supported: line-buffering, --- block-buffering or no-buffering. See GHC.Internal.IO.Handle for definition and +-- block-buffering or no-buffering. See GHC.IO.Handle for definition and -- further explanation of what the type represent. -- | Computation 'hSetBuffering' @hdl mode@ sets the mode of buffering for @@ -197,7 +198,7 @@ hLookAhead handle = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if the handle has already been used +-- * 'System.IO.Error.isPermissionError' if the handle has already been used -- for reading or writing and the implementation does not allow the -- buffering mode to be changed. @@ -209,7 +210,7 @@ hSetBuffering handle mode = _ -> do if mode == haBufferMode then return handle_ else do - -- See [note Buffer Sizing] in GHC.Internal.IO.Handle.Types + -- See [note Buffer Sizing] in GHC.IO.Handle.Types -- check for errors: case mode of @@ -241,7 +242,7 @@ hSetBuffering handle mode = -- | The action 'hSetEncoding' @hdl@ @encoding@ changes the text encoding -- for the handle @hdl@ to @encoding at . The default encoding when a 'Handle' is --- created is 'GHC.Internal.System.IO.localeEncoding', namely the default encoding for the +-- created is 'System.IO.localeEncoding', namely the default encoding for the -- current locale. -- -- To create a 'Handle' with no encoding at all, use 'openBinaryFile'. To @@ -285,9 +286,9 @@ hGetEncoding hdl = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; +-- * 'System.IO.Error.isFullError' if the device is full; -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. It is unspecified whether the characters in the buffer are -- discarded or retained under these circumstances. @@ -302,13 +303,13 @@ hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; +-- * 'System.IO.Error.isFullError' if the device is full; -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. It is unspecified whether the characters in the buffer are -- discarded or retained under these circumstances; -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and +-- * 'System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and -- is not seekable. hFlushAll :: Handle -> IO () @@ -319,11 +320,11 @@ hFlushAll handle = withHandle_ "hFlushAll" handle flushBuffer data HandlePosn = HandlePosn Handle HandlePosition --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Eq HandlePosn where (HandlePosn h1 p1) == (HandlePosn h2 p2) = p1==p2 && h1==h2 --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show HandlePosn where showsPrec p (HandlePosn h pos) = showsPrec p h . showString " at position " . shows pos @@ -348,7 +349,7 @@ hGetPosn handle = do -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. hSetPosn :: HandlePosn -> IO () @@ -382,10 +383,10 @@ hSetPosn (HandlePosn h i) = hSeek h AbsoluteSeek i -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperationError' if the Handle is not seekable, +-- * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable, -- or does not support the requested seek mode. -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. hSeek :: Handle -> SeekMode -> Integer -> IO () @@ -431,7 +432,7 @@ hSeek handle mode offset = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperationError' if the Handle is not seekable. +-- * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable. -- hTell :: Handle -> IO Integer hTell handle = @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the type of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the type of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -141,7 +141,7 @@ hGetChar handle = -- buffering mode makes no difference: we just read whatever is available -- from the device (blocking only if there is nothing available), and then -- return the first character. - -- See [note Buffered Reading] in GHC.Internal.IO.Handle.Types + -- See [note Buffered Reading] in GHC.IO.Handle.Types buf0 <- readIORef haCharBuffer buf1 <- if isEmptyBuffer buf0 @@ -184,7 +184,7 @@ hGetChar handle = -- 'hGetLine' does not return the newline as part of the result. -- -- A line is separated by the newline --- set with 'GHC.Internal.System.IO.hSetNewlineMode' or 'nativeNewline' by default. +-- set with 'System.IO.hSetNewlineMode' or 'nativeNewline' by default. -- The read newline character(s) are not returned as part of the result. -- -- If 'hGetLine' encounters end-of-file at any point while reading @@ -272,7 +272,7 @@ maybeFillReadBuffer handle_ buf then return Nothing else ioError e) --- See GHC.Internal.IO.Buffer +-- See GHC.IO.Buffer #define CHARBUF_UTF32 -- #define CHARBUF_UTF16 @@ -372,9 +372,9 @@ unpack_nl !buf !r !w acc0 -- -- Any operation that fails because a handle is closed, -- also fails if a handle is semi-closed. The only exception is --- 'GHC.Internal.System.IO.hClose'. A semi-closed handle becomes closed: +-- 'System.IO.hClose'. A semi-closed handle becomes closed: -- --- * if 'GHC.Internal.System.IO.hClose' is applied to it; +-- * if 'System.IO.hClose' is applied to it; -- -- * if an I\/O error occurs when reading an item from the handle; -- @@ -461,7 +461,7 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- shuffle the '\r' to the beginning. This is only safe -- if we're about to call readTextDevice, otherwise it -- would mess up flushCharBuffer. - -- See [note Buffer Flushing], GHC.Internal.IO.Handle.Types + -- See [note Buffer Flushing], GHC.IO.Handle.Types _ <- writeCharBuf bufRaw 0 '\r' let buf' = buf{ bufL=0, bufR=1 } readTextDevice handle_ buf' @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- --- @since base-4.15.0.0 - +-- This is a strict version of 'hGetContents' +-- +-- @since 4.15.0.0 hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -890,7 +893,7 @@ bufferChunk h_ at Handle__{..} old_buf at Buffer{ bufRaw=raw, bufR=w, bufSize=size } p let copied_buf = old_buf{ bufR = w + count } -- If the write filled the buffer completely, we need to flush, -- to maintain the "INVARIANTS on Buffers" from - -- GHC.Internal.IO.Buffer.checkBuffer: "a write buffer is never full". + -- GHC.IO.Buffer.checkBuffer: "a write buffer is never full". if isFullBuffer copied_buf then do -- TODO: we should do a non-blocking flush here @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -118,7 +118,7 @@ data Handle -- * A 'FileHandle' is seekable. A 'DuplexHandle' may or may not be -- seekable. --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Eq Handle where (FileHandle _ h1) == (FileHandle _ h2) = h1 == h2 (DuplexHandle _ h1 _) == (DuplexHandle _ h2 _) = h1 == h2 @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- hdlType is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- hdlType is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -218,10 +226,10 @@ checkHandleInvariants _ = return () -- -- * /line-buffering/: the entire output buffer is flushed -- whenever a newline is output, the buffer overflows, --- a 'GHC.Internal.System.IO.hFlush' is issued, or the handle is closed. +-- a 'System.IO.hFlush' is issued, or the handle is closed. -- -- * /block-buffering/: the entire buffer is written out whenever it --- overflows, a 'GHC.Internal.System.IO.hFlush' is issued, or the handle is closed. +-- overflows, a 'System.IO.hFlush' is issued, or the handle is closed. -- -- * /no-buffering/: output is written immediately, and never stored -- in the buffer. @@ -242,7 +250,7 @@ checkHandleInvariants _ = return () -- the next block of data is read into the buffer. -- -- * /no-buffering/: the next input item is read and returned. --- The 'GHC.Internal.System.IO.hLookAhead' operation implies that even a no-buffered +-- The 'System.IO.hLookAhead' operation implies that even a no-buffered -- handle may require a one-character buffer. -- -- The default buffering mode when a handle is opened is @@ -259,10 +267,10 @@ data BufferMode -- ^ block-buffering should be enabled if possible. -- The size of the buffer is @n@ items if the argument -- is 'Just' @n@ and is otherwise implementation-dependent. - deriving ( Eq -- ^ @since base-4.2.0.0 - , Ord -- ^ @since base-4.2.0.0 - , Read -- ^ @since base-4.2.0.0 - , Show -- ^ @since base-4.2.0.0 + deriving ( Eq -- ^ @since 4.2.0.0 + , Ord -- ^ @since 4.2.0.0 + , Read -- ^ @since 4.2.0.0 + , Show -- ^ @since 4.2.0.0 ) {- @@ -275,7 +283,7 @@ Note [Buffered Reading] ~~~~~~~~~~~~~~~~~~~~~~~ For read Handles, bytes are read into the byte buffer, and immediately decoded into the Char buffer (see -GHC.Internal.IO.Handle.Internals.readTextDevice). The only way there might be +GHC.IO.Handle.Internals.readTextDevice). The only way there might be some data left in the byte buffer is if there is a partial multi-byte character sequence that cannot be decoded into a full character. @@ -365,10 +373,10 @@ and hence it is only possible on a seekable Handle. -- | The representation of a newline in the external file or stream. data Newline = LF -- ^ @\'\\n\'@ | CRLF -- ^ @\'\\r\\n\'@ - deriving ( Eq -- ^ @since base-4.2.0.0 - , Ord -- ^ @since base-4.3.0.0 - , Read -- ^ @since base-4.3.0.0 - , Show -- ^ @since base-4.3.0.0 + deriving ( Eq -- ^ @since 4.2.0.0 + , Ord -- ^ @since 4.3.0.0 + , Read -- ^ @since 4.3.0.0 + , Show -- ^ @since 4.3.0.0 ) -- | Specifies the translation, if any, of newline characters between @@ -382,10 +390,10 @@ data NewlineMode outputNL :: Newline -- ^ the representation of newlines on output } - deriving ( Eq -- ^ @since base-4.2.0.0 - , Ord -- ^ @since base-4.3.0.0 - , Read -- ^ @since base-4.3.0.0 - , Show -- ^ @since base-4.3.0.0 + deriving ( Eq -- ^ @since 4.2.0.0 + , Ord -- ^ @since 4.3.0.0 + , Read -- ^ @since 4.3.0.0 + , Show -- ^ @since 4.3.0.0 ) -- | The native newline representation for the current platform: 'LF' @@ -432,7 +440,7 @@ noNewlineTranslation = NewlineMode { inputNL = LF, outputNL = LF } -- we provide a more user-friendly Show instance for it -- than the derived one. --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show HandleType where showsPrec _ t = case t of @@ -443,11 +451,10 @@ instance Show HandleType where AppendHandle -> showString "writable (append)" ReadWriteHandle -> showString "read-writable" --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show Handle where showsPrec _ (FileHandle file _) = showHandle file showsPrec _ (DuplexHandle file _ _) = showHandle file showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing input from the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,244 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will cause the quotation marks to be printed as well. +-- +-- >>> print "Hello" +-- "Hello" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). -- --- @since base-4.15.0.0 - +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 +-- +-- @since 4.15.0.0 getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- In the following example, because of laziness, no more than three characters are read +-- from the file. +-- +-- >>> fmap (take 3) (readFile "~/hello_world") +-- "Gre" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. -- --- @since base-4.15.0.0 - +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. +-- +-- @since 4.15.0.0 readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'System.IO.Error.isUserError' if there is no unabiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,10 +554,10 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The Unicode encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by --- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. +-- 'GHC.IO.Encoding.setLocaleEncoding' this value will not reflect that change. localeEncoding :: TextEncoding localeEncoding = initLocaleEncoding @@ -392,22 +566,23 @@ localeEncoding = initLocaleEncoding -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +642,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +692,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31761c59700ac7ceead5e60212f85a5fc3a0c075 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31761c59700ac7ceead5e60212f85a5fc3a0c075 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:26:02 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 26 Mar 2024 11:26:02 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 Message-ID: <6602e90a725d0_2edda594d8a60140059@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 72b3ec62 by Zubin Duggal at 2024-03-26T11:25:38-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 0fcc5b84 by Rodrigo Mesquita at 2024-03-26T11:25:38-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 20 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Hs/Utils.hs - libffi-tarballs - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU - + testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1565,8 +1565,8 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots (root_errs, rootSummariesOk) <- partitionWithM getRootSummary roots -- #17549 let root_map = mkRootMap rootSummariesOk checkDuplicates root_map - (deps, pkg_deps, map0) <- loopSummaries rootSummariesOk (M.empty, Set.empty, root_map) - let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) (hsc_all_home_unit_ids hsc_env) (Set.toList pkg_deps) + (deps, map0) <- loopSummaries rootSummariesOk (M.empty, root_map) + let closure_errs = checkHomeUnitsClosed (hsc_unit_env hsc_env) let unit_env = hsc_unit_env hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -1660,19 +1660,19 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- This loops over all the mod summaries in the dependency graph, accumulates the actual dependencies for each module/unit loopSummaries :: [ModSummary] - -> (M.Map NodeKey ModuleGraphNode, Set.Set (UnitId, UnitId), + -> (M.Map NodeKey ModuleGraphNode, DownsweepCache) - -> IO ((M.Map NodeKey ModuleGraphNode), Set.Set (UnitId, UnitId), DownsweepCache) + -> IO ((M.Map NodeKey ModuleGraphNode), DownsweepCache) loopSummaries [] done = return done - loopSummaries (ms:next) (done, pkgs, summarised) + loopSummaries (ms:next) (done, summarised) | Just {} <- M.lookup k done - = loopSummaries next (done, pkgs, summarised) + = loopSummaries next (done, summarised) -- Didn't work out what the imports mean yet, now do that. | otherwise = do - (final_deps, pkgs1, done', summarised') <- loopImports (calcDeps ms) done summarised + (final_deps, done', summarised') <- loopImports (calcDeps ms) done summarised -- This has the effect of finding a .hs file if we are looking at the .hs-boot file. - (_, _, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' - loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', pkgs1 `Set.union` pkgs, summarised'') + (_, done'', summarised'') <- loopImports (maybeToList hs_file_for_boot) done' summarised' + loopSummaries next (M.insert k (ModuleNode final_deps ms) done'', summarised'') where k = NodeKey_Module (msKey ms) @@ -1692,18 +1692,17 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- Visited set; the range is a list because -- the roots can have the same module names -- if allow_dup_roots is True - -> IO ([NodeKey], Set.Set (UnitId, UnitId), - + -> IO ([NodeKey], M.Map NodeKey ModuleGraphNode, DownsweepCache) -- The result is the completed NodeMap - loopImports [] done summarised = return ([], Set.empty, done, summarised) + loopImports [] done summarised = return ([], done, summarised) loopImports ((home_uid,mb_pkg, gwib) : ss) done summarised | Just summs <- M.lookup cache_key summarised = case summs of [Right ms] -> do let nk = NodeKey_Module (msKey ms) - (rest, pkgs, summarised', done') <- loopImports ss done summarised - return (nk: rest, pkgs, summarised', done') + (rest, summarised', done') <- loopImports ss done summarised + return (nk: rest, summarised', done') [Left _err] -> loopImports ss done summarised _errs -> do @@ -1715,69 +1714,77 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots Nothing excl_mods case mb_s of NotThere -> loopImports ss done summarised - External uid -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (other_deps, Set.insert (homeUnitId home_unit, uid) pkgs, done', summarised') + External _ -> do + (other_deps, done', summarised') <- loopImports ss done summarised + return (other_deps, done', summarised') FoundInstantiation iud -> do - (other_deps, pkgs, done', summarised') <- loopImports ss done summarised - return (NodeKey_Unit iud : other_deps, pkgs, done', summarised') + (other_deps, done', summarised') <- loopImports ss done summarised + return (NodeKey_Unit iud : other_deps, done', summarised') FoundHomeWithError (_uid, e) -> loopImports ss done (Map.insert cache_key [(Left e)] summarised) FoundHome s -> do - (done', pkgs1, summarised') <- - loopSummaries [s] (done, Set.empty, Map.insert cache_key [Right s] summarised) - (other_deps, pkgs2, final_done, final_summarised) <- loopImports ss done' summarised' + (done', summarised') <- + loopSummaries [s] (done, Map.insert cache_key [Right s] summarised) + (other_deps, final_done, final_summarised) <- loopImports ss done' summarised' -- MP: This assumes that we can only instantiate non home units, which is probably fair enough for now. - return (NodeKey_Module (msKey s) : other_deps, pkgs1 `Set.union` pkgs2, final_done, final_summarised) + return (NodeKey_Module (msKey s) : other_deps, final_done, final_summarised) where cache_key = (home_uid, mb_pkg, unLoc <$> gwib) home_unit = ue_unitHomeUnit home_uid (hsc_unit_env hsc_env) GWIB { gwib_mod = L loc mod, gwib_isBoot = is_boot } = gwib wanted_mod = L loc mod --- This function checks then important property that if both p and q are home units +-- | This function checks then important property that if both p and q are home units -- then any dependency of p, which transitively depends on q is also a home unit. -checkHomeUnitsClosed :: UnitEnv -> Set.Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] --- Fast path, trivially closed. -checkHomeUnitsClosed ue home_id_set home_imp_ids - | Set.size home_id_set == 1 = [] - | otherwise = - let res = foldMap loop home_imp_ids - -- Now check whether everything which transitively depends on a home_unit is actually a home_unit - -- These units are the ones which we need to load as home packages but failed to do for some reason, - -- it's a bug in the tool invoking GHC. - bad_unit_ids = Set.difference res home_id_set - in if Set.null bad_unit_ids - then [] - else [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] - +-- +-- See Note [Multiple Home Units], section 'Closure Property'. +checkHomeUnitsClosed :: UnitEnv -> [DriverMessages] +checkHomeUnitsClosed ue + | Set.null bad_unit_ids = [] + | otherwise = [singleMessage $ mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (Set.toList bad_unit_ids)] where + home_id_set = unitEnv_keys $ ue_home_unit_graph ue + bad_unit_ids = upwards_closure Set.\\ home_id_set rootLoc = mkGeneralSrcSpan (fsLit "") - -- TODO: This could repeat quite a bit of work but I struggled to write this function. - -- Which units transitively depend on a home unit - loop :: (UnitId, UnitId) -> Set.Set UnitId -- The units which transitively depend on a home unit - loop (from_uid, uid) = - let us = ue_findHomeUnitEnv from_uid ue in - let um = unitInfoMap (homeUnitEnv_units us) in - case lookupUniqMap um uid of - Nothing -> pprPanic "uid not found" (ppr uid) - Just ui -> - let depends = unitDepends ui - home_depends = Set.fromList depends `Set.intersection` home_id_set - other_depends = Set.fromList depends `Set.difference` home_id_set - in - -- Case 1: The unit directly depends on a home_id - if not (null home_depends) - then - let res = foldMap (loop . (from_uid,)) other_depends - in Set.insert uid res - -- Case 2: Check the rest of the dependencies, and then see if any of them depended on - else - let res = foldMap (loop . (from_uid,)) other_depends - in - if not (Set.null res) - then Set.insert uid res - else res + + graph :: Graph (Node UnitId UnitId) + graph = graphFromEdgedVerticesUniq graphNodes + + -- downwards closure of graph + downwards_closure + = graphFromEdgedVerticesUniq [ DigraphNode uid uid (Set.toList deps) + | (uid, deps) <- M.toList (allReachable graph node_key)] + + inverse_closure = transposeG downwards_closure + + upwards_closure = Set.fromList $ map node_key $ reachablesG inverse_closure [DigraphNode uid uid [] | uid <- Set.toList home_id_set] + + all_unit_direct_deps :: UniqMap UnitId (Set.Set UnitId) + all_unit_direct_deps + = unitEnv_foldWithKey go emptyUniqMap $ ue_home_unit_graph ue + where + go rest this this_uis = + plusUniqMap_C Set.union + (addToUniqMap_C Set.union external_depends this (Set.fromList $ this_deps)) + rest + where + external_depends = mapUniqMap (Set.fromList . unitDepends) (unitInfoMap this_units) + this_units = homeUnitEnv_units this_uis + this_deps = [ toUnitId unit | (unit,Just _) <- explicitUnits this_units] + + graphNodes :: [Node UnitId UnitId] + graphNodes = go Set.empty home_id_set + where + go done todo + = case Set.minView todo of + Nothing -> [] + Just (uid, todo') + | Set.member uid done -> go done todo' + | otherwise -> case lookupUniqMap all_unit_direct_deps uid of + Nothing -> pprPanic "uid not found" (ppr (uid, all_unit_direct_deps)) + Just depends -> + let todo'' = (depends Set.\\ done) `Set.union` todo' + in DigraphNode uid uid (Set.toList depends) : go (Set.insert uid done) todo'' -- | Update the every ModSummary that is depended on -- by a module that needs template haskell. We enable codegen to ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -736,12 +736,12 @@ mkBigLHsPatTup = mkChunkified mkLHsPatTup -- | Convert an 'LHsType' to an 'LHsSigType'. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -hsTypeToHsSigType lty@(L loc ty) = L loc $ case ty of +hsTypeToHsSigType lty@(L loc ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an , hsf_invis_bndrs = bndrs } , hst_body = body } - -> mkHsExplicitSigType an bndrs body - _ -> mkHsImplicitSigType lty + -> L loc $ mkHsExplicitSigType an bndrs body + _ -> L (l2l loc) $ mkHsImplicitSigType lty -- The annotations are in lty, erase them from loc -- | Convert an 'LHsType' to an 'LHsSigWcType'. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Makefile ===================================== @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +mhu-perf: clean + $(MAKE) -s --no-print-directory clean + ./genLargeHMU + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + for dir in unit-p*; do \ + cd $$dir && $(SETUP) clean && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --ipid=$$dir-0.1.0.0 --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d && $(SETUP) build && $(SETUP) register --inplace && cd ..; \ + done; + + +ifeq "$(CLEANUP)" "1" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r unitTop* unit-p* top*/ tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) + ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -0,0 +1,9 @@ +test('mhu-perf', + [ collect_compiler_stats('bytes allocated',2), + extra_files(['genLargeHMU','Setup.hs']), + pre_cmd('$MAKE -s --no-print-directory mhu-perf'), + js_broken(22349), + compile_timeout_multiplier(5) + ], + multiunit_compile, + [['unitTop1', 'unitTop2'], '-fhide-source-paths']) ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/genLargeHMU ===================================== @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Generate $DEPTH layers of packages with $WIDTH modules on each layer +# Every package on layer N depends on all the packages on layer N-1 +# unitTop imports all the units from the last layer +DEPTH=8 +WIDTH=8 +for i in $(seq -w 1 $WIDTH); do + mkdir unit-p0M$i + echo "module DummyLevel0M$i where" > unit-p0M$i/DummyLevel0M$i.hs; + cat > unit-p0M$i/unit-p0M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel0M$i + build-depends: base +EOF +done +for l in $(seq 1 $DEPTH); do + for i in $(seq -w 1 $WIDTH); do + mkdir unit-p${l}M$i + cat > unit-p${l}M$i/unit-p${l}M$i.cabal <=1.10 +library + default-language: Haskell2010 + exposed-modules: DummyLevel${l}M$i + build-depends: base +EOF + echo "module DummyLevel${l}M$i where" > unit-p${l}M$i/DummyLevel${l}M$i.hs; + for j in $(seq -w 1 $WIDTH); do + echo " , unit-p$((l-1))M$j" >> unit-p${l}M$i/unit-p${l}M$i.cabal + echo "import DummyLevel$((l-1))M$j" >> unit-p${l}M$i/DummyLevel${l}M$i.hs; + done + done +done +mkdir top1 +echo "module Top1 where" > top1/Top1.hs +echo "-package-db ./tmp.d -i -itop1 Top1 -this-unit-id unit-top1 -package base" > unitTop1; +for j in $(seq -w 1 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop1; + echo "import DummyLevel${DEPTH}M$j" >> top1/Top1.hs; +done +mkdir top2 +echo "module Top2 where" > top2/Top2.hs +echo "-package-db ./tmp.d -i -itop2 Top2 -this-unit-id unit-top2 -package base" > unitTop2; +for j in $(seq -w 2 $WIDTH); do + echo "-package unit-p${DEPTH}M$j" >> unitTop2; + echo "import DummyLevel${DEPTH}M$j" >> top2/Top2.hs; +done ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/mhu-perf.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Top1[unit-top1] +[2 of 2] Compiling Top2[unit-top2] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a5150feba5dbc75f32aac8b934314d33060df6b...0fcc5b8433fad7b479c21b270e96d9a1cd45c939 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a5150feba5dbc75f32aac8b934314d33060df6b...0fcc5b8433fad7b479c21b270e96d9a1cd45c939 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:26:25 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 11:26:25 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6602e9216a13c_2edda595359a4143798@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: 738c8b42 by Jade at 2024-03-26T16:30:17+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -29,156 +29,148 @@ module System.IO -- descriptors when they have run out, it is your responsibility to -- ensure that this doesn't happen. - -- ** Standard handles - -- | Three handles are allocated during program initialisation, - -- and are initially open. - stdin, - stdout, - stderr, - -- * Opening and closing files - -- ** Opening files - withFile, - openFile, - IOMode(ReadMode, WriteMode, AppendMode, ReadWriteMode), - -- ** Closing files - hClose, - -- ** Special cases - -- | These functions are also exported by the "Prelude". - readFile, - readFile', - writeFile, - appendFile, - -- ** File locking - -- $locking - -- * Operations on handles - -- ** Determining and changing the size of a file - hFileSize, - hSetFileSize, - -- ** Detecting the end of input - hIsEOF, - isEOF, - -- ** Buffering operations - BufferMode(NoBuffering, LineBuffering, BlockBuffering), - hSetBuffering, - hGetBuffering, - hFlush, - -- ** Repositioning handles - hGetPosn, - hSetPosn, - HandlePosn, - hSeek, - SeekMode(AbsoluteSeek, RelativeSeek, SeekFromEnd), - hTell, - -- ** Handle properties - hIsOpen, - hIsClosed, - hIsReadable, - hIsWritable, - hIsSeekable, - -- ** Terminal operations (not portable: GHC only) - hIsTerminalDevice, - hSetEcho, - hGetEcho, - -- ** Showing handle state (not portable: GHC only) - hShow, - -- * Text input and output - -- ** Text input - hWaitForInput, - hReady, - hGetChar, - hGetLine, - hLookAhead, - hGetContents, - hGetContents', - -- ** Text output - hPutChar, - hPutStr, - hPutStrLn, - hPrint, - -- ** Special cases for standard input and output - -- | These functions are also exported by the "Prelude". - interact, - putChar, - putStr, - putStrLn, - print, - getChar, - getLine, - getContents, - getContents', - readIO, - readLn, - -- * Binary input and output - withBinaryFile, - openBinaryFile, - hSetBinaryMode, - hPutBuf, - hGetBuf, - hGetBufSome, - hPutBufNonBlocking, - hGetBufNonBlocking, - -- * Temporary files - openTempFile, - openBinaryTempFile, - openTempFileWithDefaultPermissions, - openBinaryTempFileWithDefaultPermissions, - -- * Unicode encoding\/decoding - -- | A text-mode 'Handle' has an associated 'TextEncoding', which - -- is used to decode bytes into Unicode characters when reading, - -- and encode Unicode characters into bytes when writing. - -- - -- The default 'TextEncoding' is the same as the default encoding - -- on your system, which is also available as 'localeEncoding'. - -- (GHC note: on Windows, we currently do not support double-byte - -- encodings; if the console\'s code page is unsupported, then - -- 'localeEncoding' will be 'latin1'.) - -- - -- Encoding and decoding errors are always detected and reported, - -- except during lazy I/O ('hGetContents', 'getContents', and - -- 'readFile'), where a decoding error merely results in - -- termination of the character stream, as with other I/O errors. - hSetEncoding, - hGetEncoding, - -- ** Unicode encodings - TextEncoding, - latin1, - utf8, - utf8_bom, - utf16, - utf16le, - utf16be, - utf32, - utf32le, - utf32be, - localeEncoding, - char8, - mkTextEncoding, - -- * Newline conversion - -- | In Haskell, a newline is always represented by the character - -- @\'\\n\'@. However, in files and external character streams, a - -- newline may be represented by another character sequence, such - -- as @\'\\r\\n\'@. - -- - -- A text-mode 'Handle' has an associated 'NewlineMode' that - -- specifies how to translate newline characters. The - -- 'NewlineMode' specifies the input and output translation - -- separately, so that for instance you can translate @\'\\r\\n\'@ - -- to @\'\\n\'@ on input, but leave newlines as @\'\\n\'@ on output. - -- - -- The default 'NewlineMode' for a 'Handle' is - -- 'nativeNewlineMode', which does no translation on Unix systems, - -- but translates @\'\\r\\n\'@ to @\'\\n\'@ and back on Windows. - -- - -- Binary-mode 'Handle's do no newline translation at all. - - hSetNewlineMode, - Newline(..), - nativeNewline, - NewlineMode(..), - noNewlineTranslation, - universalNewlineMode, - nativeNewlineMode - ) where + -- ** Standard handles + -- | Three handles are allocated during program initialisation, + -- and are initially open. + stdin, + stdout, + stderr, + -- * Opening and closing files + -- ** Opening files + withFile, + openFile, + IOMode(ReadMode,WriteMode,AppendMode,ReadWriteMode), + -- ** Closing files + hClose, + -- ** Special cases + -- | These functions are also exported by the "Prelude". + readFile, + readFile', + writeFile, + appendFile, + -- ** File locking + -- $locking + -- * Operations on handles + -- ** Determining and changing the size of a file + hFileSize, + hSetFileSize, + -- ** Detecting the end of input + hIsEOF, + isEOF, + -- ** Buffering operations + BufferMode(NoBuffering,LineBuffering,BlockBuffering), + hSetBuffering, + hGetBuffering, + hFlush, + -- ** Repositioning handles + hGetPosn, + hSetPosn, + HandlePosn, + hSeek, + SeekMode(AbsoluteSeek,RelativeSeek,SeekFromEnd), + hTell, + -- ** Handle properties + hIsOpen, + hIsClosed, + hIsReadable, + hIsWritable, + hIsSeekable, + -- ** Terminal operations (not portable: GHC only) + hIsTerminalDevice, + hSetEcho, + hGetEcho, + -- ** Showing handle state (not portable: GHC only) + hShow, + -- * Text input and output + -- ** Text input + hWaitForInput, + hReady, + hGetChar, + hGetLine, + hLookAhead, + hGetContents, + hGetContents', + -- ** Text output + hPutChar, + hPutStr, + hPutStrLn, + hPrint, + -- ** Special cases for standard input and output + -- | These functions are also exported by the "Prelude". + interact, + putChar, + putStr, + putStrLn, + print, + getChar, + getLine, + getContents, + getContents', + readIO, + readLn, + -- * Binary input and output + withBinaryFile, + openBinaryFile, + hSetBinaryMode, + hPutBuf, + hGetBuf, + hGetBufSome, + hPutBufNonBlocking, + hGetBufNonBlocking, + -- * Temporary files + openTempFile, + openBinaryTempFile, + openTempFileWithDefaultPermissions, + openBinaryTempFileWithDefaultPermissions, + -- * Unicode encoding\/decoding + -- | A text-mode 'Handle' has an associated 'TextEncoding', which + -- is used to decode bytes into Unicode characters when reading, + -- and encode Unicode characters into bytes when writing. + -- + -- The default 'TextEncoding' is the same as the default encoding + -- on your system, which is also available as 'localeEncoding'. + -- (GHC note: on Windows, we currently do not support double-byte + -- encodings; if the console\'s code page is unsupported, then + -- 'localeEncoding' will be 'latin1'.) + -- + -- Encoding and decoding errors are always detected and reported, + -- except during lazy I/O ('hGetContents', 'getContents', and + -- 'readFile'), where a decoding error merely results in + -- termination of the character stream, as with other I/O errors. + hSetEncoding, + hGetEncoding, + -- ** Unicode encodings + TextEncoding, + latin1, + utf8, utf8_bom, + utf16, utf16le, utf16be, + utf32, utf32le, utf32be, + localeEncoding, + char8, + mkTextEncoding, + -- * Newline conversion + -- | In Haskell, a newline is always represented by the character + -- @\'\\n\'@. However, in files and external character streams, a + -- newline may be represented by another character sequence, such + -- as @\'\\r\\n\'@. + -- + -- A text-mode 'Handle' has an associated 'NewlineMode' that + -- specifies how to translate newline characters. The + -- 'NewlineMode' specifies the input and output translation + -- separately, so that for instance you can translate @\'\\r\\n\'@ + -- to @\'\\n\'@ on input, but leave newlines as @\'\\n\'@ on output. + -- + -- The default 'NewlineMode' for a 'Handle' is + -- 'nativeNewlineMode', which does no translation on Unix systems, + -- but translates @\'\\r\\n\'@ to @\'\\n\'@ and back on Windows. + -- + -- Binary-mode 'Handle's do no newline translation at all. + -- + hSetNewlineMode, + Newline(..), nativeNewline, + NewlineMode(..), + noNewlineTranslation, universalNewlineMode, nativeNewlineMode, + ) where import GHC.Internal.System.IO @@ -199,3 +191,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -172,7 +173,7 @@ isEOF = hIsEOF stdin -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hLookAhead :: Handle -> IO Char hLookAhead handle = @@ -182,7 +183,7 @@ hLookAhead handle = -- Buffering Operations -- Three kinds of buffering are supported: line-buffering, --- block-buffering or no-buffering. See GHC.Internal.IO.Handle for definition and +-- block-buffering or no-buffering. See GHC.IO.Handle for definition and -- further explanation of what the type represent. -- | Computation 'hSetBuffering' @hdl mode@ sets the mode of buffering for @@ -197,7 +198,7 @@ hLookAhead handle = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if the handle has already been used +-- * 'System.IO.Error.isPermissionError' if the handle has already been used -- for reading or writing and the implementation does not allow the -- buffering mode to be changed. @@ -209,7 +210,7 @@ hSetBuffering handle mode = _ -> do if mode == haBufferMode then return handle_ else do - -- See [note Buffer Sizing] in GHC.Internal.IO.Handle.Types + -- See [note Buffer Sizing] in GHC.IO.Handle.Types -- check for errors: case mode of @@ -241,7 +242,7 @@ hSetBuffering handle mode = -- | The action 'hSetEncoding' @hdl@ @encoding@ changes the text encoding -- for the handle @hdl@ to @encoding at . The default encoding when a 'Handle' is --- created is 'GHC.Internal.System.IO.localeEncoding', namely the default encoding for the +-- created is 'System.IO.localeEncoding', namely the default encoding for the -- current locale. -- -- To create a 'Handle' with no encoding at all, use 'openBinaryFile'. To @@ -285,9 +286,9 @@ hGetEncoding hdl = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; +-- * 'System.IO.Error.isFullError' if the device is full; -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. It is unspecified whether the characters in the buffer are -- discarded or retained under these circumstances. @@ -302,13 +303,13 @@ hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; +-- * 'System.IO.Error.isFullError' if the device is full; -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. It is unspecified whether the characters in the buffer are -- discarded or retained under these circumstances; -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and +-- * 'System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and -- is not seekable. hFlushAll :: Handle -> IO () @@ -319,11 +320,11 @@ hFlushAll handle = withHandle_ "hFlushAll" handle flushBuffer data HandlePosn = HandlePosn Handle HandlePosition --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Eq HandlePosn where (HandlePosn h1 p1) == (HandlePosn h2 p2) = p1==p2 && h1==h2 --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show HandlePosn where showsPrec p (HandlePosn h pos) = showsPrec p h . showString " at position " . shows pos @@ -348,7 +349,7 @@ hGetPosn handle = do -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. hSetPosn :: HandlePosn -> IO () @@ -382,10 +383,10 @@ hSetPosn (HandlePosn h i) = hSeek h AbsoluteSeek i -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperationError' if the Handle is not seekable, +-- * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable, -- or does not support the requested seek mode. -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. hSeek :: Handle -> SeekMode -> Integer -> IO () @@ -431,7 +432,7 @@ hSeek handle mode offset = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperationError' if the Handle is not seekable. +-- * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable. -- hTell :: Handle -> IO Integer hTell handle = @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the type of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the type of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -141,7 +141,7 @@ hGetChar handle = -- buffering mode makes no difference: we just read whatever is available -- from the device (blocking only if there is nothing available), and then -- return the first character. - -- See [note Buffered Reading] in GHC.Internal.IO.Handle.Types + -- See [note Buffered Reading] in GHC.IO.Handle.Types buf0 <- readIORef haCharBuffer buf1 <- if isEmptyBuffer buf0 @@ -184,7 +184,7 @@ hGetChar handle = -- 'hGetLine' does not return the newline as part of the result. -- -- A line is separated by the newline --- set with 'GHC.Internal.System.IO.hSetNewlineMode' or 'nativeNewline' by default. +-- set with 'System.IO.hSetNewlineMode' or 'nativeNewline' by default. -- The read newline character(s) are not returned as part of the result. -- -- If 'hGetLine' encounters end-of-file at any point while reading @@ -272,7 +272,7 @@ maybeFillReadBuffer handle_ buf then return Nothing else ioError e) --- See GHC.Internal.IO.Buffer +-- See GHC.IO.Buffer #define CHARBUF_UTF32 -- #define CHARBUF_UTF16 @@ -372,9 +372,9 @@ unpack_nl !buf !r !w acc0 -- -- Any operation that fails because a handle is closed, -- also fails if a handle is semi-closed. The only exception is --- 'GHC.Internal.System.IO.hClose'. A semi-closed handle becomes closed: +-- 'System.IO.hClose'. A semi-closed handle becomes closed: -- --- * if 'GHC.Internal.System.IO.hClose' is applied to it; +-- * if 'System.IO.hClose' is applied to it; -- -- * if an I\/O error occurs when reading an item from the handle; -- @@ -461,7 +461,7 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- shuffle the '\r' to the beginning. This is only safe -- if we're about to call readTextDevice, otherwise it -- would mess up flushCharBuffer. - -- See [note Buffer Flushing], GHC.Internal.IO.Handle.Types + -- See [note Buffer Flushing], GHC.IO.Handle.Types _ <- writeCharBuf bufRaw 0 '\r' let buf' = buf{ bufL=0, bufR=1 } readTextDevice handle_ buf' @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- --- @since base-4.15.0.0 - +-- This is a strict version of 'hGetContents' +-- +-- @since 4.15.0.0 hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -890,7 +893,7 @@ bufferChunk h_ at Handle__{..} old_buf at Buffer{ bufRaw=raw, bufR=w, bufSize=size } p let copied_buf = old_buf{ bufR = w + count } -- If the write filled the buffer completely, we need to flush, -- to maintain the "INVARIANTS on Buffers" from - -- GHC.Internal.IO.Buffer.checkBuffer: "a write buffer is never full". + -- GHC.IO.Buffer.checkBuffer: "a write buffer is never full". if isFullBuffer copied_buf then do -- TODO: we should do a non-blocking flush here @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -118,7 +118,7 @@ data Handle -- * A 'FileHandle' is seekable. A 'DuplexHandle' may or may not be -- seekable. --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Eq Handle where (FileHandle _ h1) == (FileHandle _ h2) = h1 == h2 (DuplexHandle _ h1 _) == (DuplexHandle _ h2 _) = h1 == h2 @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- hdlType is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- hdlType is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -218,10 +226,10 @@ checkHandleInvariants _ = return () -- -- * /line-buffering/: the entire output buffer is flushed -- whenever a newline is output, the buffer overflows, --- a 'GHC.Internal.System.IO.hFlush' is issued, or the handle is closed. +-- a 'System.IO.hFlush' is issued, or the handle is closed. -- -- * /block-buffering/: the entire buffer is written out whenever it --- overflows, a 'GHC.Internal.System.IO.hFlush' is issued, or the handle is closed. +-- overflows, a 'System.IO.hFlush' is issued, or the handle is closed. -- -- * /no-buffering/: output is written immediately, and never stored -- in the buffer. @@ -242,7 +250,7 @@ checkHandleInvariants _ = return () -- the next block of data is read into the buffer. -- -- * /no-buffering/: the next input item is read and returned. --- The 'GHC.Internal.System.IO.hLookAhead' operation implies that even a no-buffered +-- The 'System.IO.hLookAhead' operation implies that even a no-buffered -- handle may require a one-character buffer. -- -- The default buffering mode when a handle is opened is @@ -259,10 +267,10 @@ data BufferMode -- ^ block-buffering should be enabled if possible. -- The size of the buffer is @n@ items if the argument -- is 'Just' @n@ and is otherwise implementation-dependent. - deriving ( Eq -- ^ @since base-4.2.0.0 - , Ord -- ^ @since base-4.2.0.0 - , Read -- ^ @since base-4.2.0.0 - , Show -- ^ @since base-4.2.0.0 + deriving ( Eq -- ^ @since 4.2.0.0 + , Ord -- ^ @since 4.2.0.0 + , Read -- ^ @since 4.2.0.0 + , Show -- ^ @since 4.2.0.0 ) {- @@ -275,7 +283,7 @@ Note [Buffered Reading] ~~~~~~~~~~~~~~~~~~~~~~~ For read Handles, bytes are read into the byte buffer, and immediately decoded into the Char buffer (see -GHC.Internal.IO.Handle.Internals.readTextDevice). The only way there might be +GHC.IO.Handle.Internals.readTextDevice). The only way there might be some data left in the byte buffer is if there is a partial multi-byte character sequence that cannot be decoded into a full character. @@ -365,10 +373,10 @@ and hence it is only possible on a seekable Handle. -- | The representation of a newline in the external file or stream. data Newline = LF -- ^ @\'\\n\'@ | CRLF -- ^ @\'\\r\\n\'@ - deriving ( Eq -- ^ @since base-4.2.0.0 - , Ord -- ^ @since base-4.3.0.0 - , Read -- ^ @since base-4.3.0.0 - , Show -- ^ @since base-4.3.0.0 + deriving ( Eq -- ^ @since 4.2.0.0 + , Ord -- ^ @since 4.3.0.0 + , Read -- ^ @since 4.3.0.0 + , Show -- ^ @since 4.3.0.0 ) -- | Specifies the translation, if any, of newline characters between @@ -382,10 +390,10 @@ data NewlineMode outputNL :: Newline -- ^ the representation of newlines on output } - deriving ( Eq -- ^ @since base-4.2.0.0 - , Ord -- ^ @since base-4.3.0.0 - , Read -- ^ @since base-4.3.0.0 - , Show -- ^ @since base-4.3.0.0 + deriving ( Eq -- ^ @since 4.2.0.0 + , Ord -- ^ @since 4.3.0.0 + , Read -- ^ @since 4.3.0.0 + , Show -- ^ @since 4.3.0.0 ) -- | The native newline representation for the current platform: 'LF' @@ -432,7 +440,7 @@ noNewlineTranslation = NewlineMode { inputNL = LF, outputNL = LF } -- we provide a more user-friendly Show instance for it -- than the derived one. --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show HandleType where showsPrec _ t = case t of @@ -443,11 +451,10 @@ instance Show HandleType where AppendHandle -> showString "writable (append)" ReadWriteHandle -> showString "read-writable" --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show Handle where showsPrec _ (FileHandle file _) = showHandle file showsPrec _ (DuplexHandle file _ _) = showHandle file showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing input from the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,244 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will cause the quotation marks to be printed as well. +-- +-- >>> print "Hello" +-- "Hello" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). -- --- @since base-4.15.0.0 - +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 +-- +-- @since 4.15.0.0 getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- In the following example, because of laziness, no more than three characters are read +-- from the file. +-- +-- >>> fmap (take 3) (readFile "~/hello_world") +-- "Gre" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. -- --- @since base-4.15.0.0 - +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. +-- +-- @since 4.15.0.0 readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'System.IO.Error.isUserError' if there is no unabiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,10 +554,10 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The Unicode encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by --- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. +-- 'GHC.IO.Encoding.setLocaleEncoding' this value will not reflect that change. localeEncoding :: TextEncoding localeEncoding = initLocaleEncoding @@ -392,22 +566,23 @@ localeEncoding = initLocaleEncoding -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +642,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +692,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/738c8b42389d9468b5246b5af62e10a89f1b9977 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/738c8b42389d9468b5246b5af62e10a89f1b9977 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:27:02 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 11:27:02 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6602e94666290_2edda59612a48146454@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: 637e48cd by Jade at 2024-03-26T16:31:06+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -172,7 +173,7 @@ isEOF = hIsEOF stdin -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hLookAhead :: Handle -> IO Char hLookAhead handle = @@ -182,7 +183,7 @@ hLookAhead handle = -- Buffering Operations -- Three kinds of buffering are supported: line-buffering, --- block-buffering or no-buffering. See GHC.Internal.IO.Handle for definition and +-- block-buffering or no-buffering. See GHC.IO.Handle for definition and -- further explanation of what the type represent. -- | Computation 'hSetBuffering' @hdl mode@ sets the mode of buffering for @@ -197,7 +198,7 @@ hLookAhead handle = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if the handle has already been used +-- * 'System.IO.Error.isPermissionError' if the handle has already been used -- for reading or writing and the implementation does not allow the -- buffering mode to be changed. @@ -209,7 +210,7 @@ hSetBuffering handle mode = _ -> do if mode == haBufferMode then return handle_ else do - -- See [note Buffer Sizing] in GHC.Internal.IO.Handle.Types + -- See [note Buffer Sizing] in GHC.IO.Handle.Types -- check for errors: case mode of @@ -241,7 +242,7 @@ hSetBuffering handle mode = -- | The action 'hSetEncoding' @hdl@ @encoding@ changes the text encoding -- for the handle @hdl@ to @encoding at . The default encoding when a 'Handle' is --- created is 'GHC.Internal.System.IO.localeEncoding', namely the default encoding for the +-- created is 'System.IO.localeEncoding', namely the default encoding for the -- current locale. -- -- To create a 'Handle' with no encoding at all, use 'openBinaryFile'. To @@ -285,9 +286,9 @@ hGetEncoding hdl = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; +-- * 'System.IO.Error.isFullError' if the device is full; -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. It is unspecified whether the characters in the buffer are -- discarded or retained under these circumstances. @@ -302,13 +303,13 @@ hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; +-- * 'System.IO.Error.isFullError' if the device is full; -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. It is unspecified whether the characters in the buffer are -- discarded or retained under these circumstances; -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and +-- * 'System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and -- is not seekable. hFlushAll :: Handle -> IO () @@ -319,11 +320,11 @@ hFlushAll handle = withHandle_ "hFlushAll" handle flushBuffer data HandlePosn = HandlePosn Handle HandlePosition --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Eq HandlePosn where (HandlePosn h1 p1) == (HandlePosn h2 p2) = p1==p2 && h1==h2 --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show HandlePosn where showsPrec p (HandlePosn h pos) = showsPrec p h . showString " at position " . shows pos @@ -348,7 +349,7 @@ hGetPosn handle = do -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. hSetPosn :: HandlePosn -> IO () @@ -382,10 +383,10 @@ hSetPosn (HandlePosn h i) = hSeek h AbsoluteSeek i -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperationError' if the Handle is not seekable, +-- * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable, -- or does not support the requested seek mode. -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if a system resource limit would be +-- * 'System.IO.Error.isPermissionError' if a system resource limit would be -- exceeded. hSeek :: Handle -> SeekMode -> Integer -> IO () @@ -431,7 +432,7 @@ hSeek handle mode offset = -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isIllegalOperationError' if the Handle is not seekable. +-- * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable. -- hTell :: Handle -> IO Integer hTell handle = @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the type of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the type of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -461,7 +461,7 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- shuffle the '\r' to the beginning. This is only safe -- if we're about to call readTextDevice, otherwise it -- would mess up flushCharBuffer. - -- See [note Buffer Flushing], GHC.Internal.IO.Handle.Types + -- See [note Buffer Flushing], GHC.IO.Handle.Types _ <- writeCharBuf bufRaw 0 '\r' let buf' = buf{ bufL=0, bufR=1 } readTextDevice handle_ buf' @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- hdlType is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- hdlType is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -242,7 +250,7 @@ checkHandleInvariants _ = return () -- the next block of data is read into the buffer. -- -- * /no-buffering/: the next input item is read and returned. --- The 'GHC.Internal.System.IO.hLookAhead' operation implies that even a no-buffered +-- The 'System.IO.hLookAhead' operation implies that even a no-buffered -- handle may require a one-character buffer. -- -- The default buffering mode when a handle is opened is @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing input from the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,244 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will cause the quotation marks to be printed as well. +-- +-- >>> print "Hello" +-- "Hello" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). -- --- @since base-4.15.0.0 - +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 +-- +-- @since 4.15.0.0 getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- In the following example, because of laziness, no more than three characters are read +-- from the file. +-- +-- >>> fmap (take 3) (readFile "~/hello_world") +-- "Gre" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. -- --- @since base-4.15.0.0 - +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. +-- +-- @since 4.15.0.0 readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'System.IO.Error.isUserError' if there is no unabiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,10 +554,10 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The Unicode encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by --- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. +-- 'GHC.IO.Encoding.setLocaleEncoding' this value will not reflect that change. localeEncoding :: TextEncoding localeEncoding = initLocaleEncoding @@ -392,22 +566,23 @@ localeEncoding = initLocaleEncoding -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +642,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +692,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/637e48cd280af8f57345257b3afdf74a6c512d5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/637e48cd280af8f57345257b3afdf74a6c512d5a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:43:52 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 11:43:52 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6602ed38949ea_2f603f4518c0575f3@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: e1fa1c56 by Jade at 2024-03-26T16:48:23+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -319,11 +320,11 @@ hFlushAll handle = withHandle_ "hFlushAll" handle flushBuffer data HandlePosn = HandlePosn Handle HandlePosition --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Eq HandlePosn where (HandlePosn h1 p1) == (HandlePosn h2 p2) = p1==p2 && h1==h2 --- | @since base-4.1.0.0 +-- | @since 4.1.0.0 instance Show HandlePosn where showsPrec p (HandlePosn h pos) = showsPrec p h . showString " at position " . shows pos @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the type of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the type of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- hdlType is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- hdlType is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing input from the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,244 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will cause the quotation marks to be printed as well. +-- +-- >>> print "Hello" +-- "Hello" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). -- --- @since base-4.15.0.0 - +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 +-- +-- @since 4.15.0.0 getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- In the following example, because of laziness, no more than three characters are read +-- from the file. +-- +-- >>> fmap (take 3) (readFile "~/hello_world") +-- "Gre" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. -- --- @since base-4.15.0.0 - +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. +-- +-- @since 4.15.0.0 readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'System.IO.Error.isUserError' if there is no unabiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,10 +554,10 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The Unicode encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by --- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. +-- 'GHC.IO.Encoding.setLocaleEncoding' this value will not reflect that change. localeEncoding :: TextEncoding localeEncoding = initLocaleEncoding @@ -392,22 +566,23 @@ localeEncoding = initLocaleEncoding -- -- This operation may fail with: -- --- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - +-- * 'System.IO.Error.isEOFError' if the end of file has been reached. hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +642,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +692,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1fa1c565be0029a00aaff4540cb0c54a170eda1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1fa1c565be0029a00aaff4540cb0c54a170eda1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:47:56 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 11:47:56 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6602ee2ccd41a_2f603f571a34611dc@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: a87a4adc by Jade at 2024-03-26T16:52:29+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the type of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the type of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- hdlType is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- hdlType is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing input from the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,244 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will cause the quotation marks to be printed as well. +-- +-- >>> print "Hello" +-- "Hello" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). +-- +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 -- -- @since base-4.15.0.0 - getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- In the following example, because of laziness, no more than three characters are read +-- from the file. +-- +-- >>> fmap (take 3) (readFile "~/hello_world") +-- "Gre" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. +-- +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. -- -- @since base-4.15.0.0 - readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'System.IO.Error.isUserError' if there is no unabiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,7 +554,7 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The Unicode encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by -- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. @@ -393,21 +567,22 @@ localeEncoding = initLocaleEncoding -- This operation may fail with: -- -- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +642,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +692,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a87a4adc9b3758e2316647d9df4e2c3641b4b605 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a87a4adc9b3758e2316647d9df4e2c3641b4b605 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 15:50:42 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 11:50:42 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6602eed21ab75_2f603f819d186161c@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: 8c7a6fea by Jade at 2024-03-26T16:55:13+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the type of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the type of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- hdlType is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- hdlType is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- hdlType is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing input from the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,244 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will cause the quotation marks to be printed as well. +-- +-- >>> print "Hello" +-- "Hello" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). +-- +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 -- -- @since base-4.15.0.0 - getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- In the following example, because of laziness, no more than three characters are read +-- from the file. +-- +-- >>> fmap (take 3) (readFile "~/hello_world") +-- "Gre" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. +-- +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. -- -- @since base-4.15.0.0 - readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'GHC.Internal.System.IO.Error.isUserError' if there is no unabiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,7 +554,7 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The Unicode encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by -- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. @@ -393,21 +567,22 @@ localeEncoding = initLocaleEncoding -- This operation may fail with: -- -- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +642,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +692,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c7a6feab36f2cda64717faa100f577dd34c9d67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c7a6feab36f2cda64717faa100f577dd34c9d67 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 17:01:39 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 13:01:39 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24594 Message-ID: <6602ff7367793_2f603f29e042477352@gitlab.mail> Ben Gamari pushed new branch wip/T24594 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24594 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 17:16:33 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 26 Mar 2024 13:16:33 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <660302f17ed95_2f603f3268740843d2@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: 72ad09ed by Teo Camarasu at 2024-03-26T17:06:32+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. We avoid duplicating the file by using an in-tree symlink. Resolves #23536 - - - - - 15 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - + libraries/ghc-boot/GHC/LanguageExtensions/Type.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,13 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; void $ return ns_spec -- to avoid CPP incurred unused variable warning + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1209,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1329,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2119,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2435,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2464,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2601,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2614,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2626,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2637,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2695,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2758,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2772,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -157,6 +157,7 @@ import Data.IORef import GHC.Parser.HaddockLex (lexHsDoc) import GHC.Parser (parseIdentifier) import GHC.Rename.Doc (rnHsDoc) +import GHC.LanguageExtensions @@ -1514,10 +1515,10 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + qIsExtEnabled = xoptM . migrateExt qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map unmigrateExt . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Just () +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -74,7 +74,7 @@ needDocDeps = do -- logic to determine the versions of packages shipped with GHC. let templatedCabalFiles = map pkgCabalFile [ ghcBoot - , ghcBootTh + -- , ghcBootTh , ghci , compiler , ghcHeap ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -158,7 +158,6 @@ toolTargets = [ binary -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot - , ghcBootTh , ghcPlatform , ghcToolchain , ghcToolchainBin @@ -172,7 +171,6 @@ toolTargets = [ binary , mtl , parsec , time - , templateHaskell , text , transformers , semaphoreCompat ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE PackageImports #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +11,39 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + , migrateExt + , unmigrateExt + ) + where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary -import GHC.LanguageExtensions.Type +import qualified "ghc-boot-th" GHC.LanguageExtensions.Type as TH +#if MIN_VERSION_ghc_boot_th(9,11,0) +import "ghc-boot-th" GHC.LanguageExtensions.Type (Extension(..)) +#else +import Text.Read (readMaybe) +import Data.Maybe (fromMaybe) +import GHC.LanguageExtensions.Type (Extension(..)) +#endif instance Binary Extension +instance Read Extension + +migrateExt :: TH.Extension -> Extension +unmigrateExt :: Extension -> TH.Extension +#if MIN_VERSION_ghc_boot_th(9,11,0) +migrateExt = id +unmigrateExt = id +#else +errStr :: String +errStr = "unsupported language extension encountered in TH while bootstrapping" +instance Read TH.Extension +migrateExt = fromMaybe (error errStr) . readMaybe . show +unmigrateExt = fromMaybe (error errStr) . readMaybe. show +#endif ===================================== libraries/ghc-boot/GHC/LanguageExtensions/Type.hs ===================================== @@ -0,0 +1 @@ +../../../../libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs \ No newline at end of file ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -56,12 +56,14 @@ Library GHC.UniqueSubdir GHC.Version + other-modules: + GHC.LanguageExtensions.Type + -- reexport modules from ghc-boot-th so that packages don't have to import -- both ghc-boot and ghc-boot-th. It makes the dependency graph easier to -- understand and to refactor. reexported-modules: - GHC.LanguageExtensions.Type - , GHC.ForeignSrcLang.Type + GHC.ForeignSrcLang.Type , GHC.Lexeme -- reexport platform modules from ghc-platform @@ -81,7 +83,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@ if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@, ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72ad09edcd4d008bb2670dd1f154a6ed04f436a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72ad09edcd4d008bb2670dd1f154a6ed04f436a4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 17:32:55 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 26 Mar 2024 13:32:55 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 7 commits: Detected lists with lot of redundant modules; considered invasive change Message-ID: <660306c7b83f2_2f603f3aaeb48884d4@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: fb9b266c by Rodrigo Mesquita at 2024-03-26T13:22:51+00:00 Detected lists with lot of redundant modules; considered invasive change - - - - - 34ef656d by Rodrigo Mesquita at 2024-03-26T13:23:30+00:00 Revert "Detected lists with lot of redundant modules; considered invasive change" This reverts commit fb9b266c4973eb98d837eff723438d799ee7beaf. - - - - - ef3a3c4c by Rodrigo Mesquita at 2024-03-26T16:32:35+00:00 VERY GOOD -3.5 seconds, instant main - - - - - 73b5ba3f by Rodrigo Mesquita at 2024-03-26T16:34:26+00:00 another potential perf improv - - - - - 8cc84e82 by Rodrigo Mesquita at 2024-03-26T16:34:26+00:00 DEBUG LINES TO DROP - - - - - 703e0b3a by Rodrigo Mesquita at 2024-03-26T16:34:26+00:00 Revert "DEBUG LINES TO DROP" This reverts commit dab08260e62eccec5697954133504a4865431ee0. - - - - - f6f6541b by Rodrigo Mesquita at 2024-03-26T17:32:43+00:00 Minus 1second wall time??? - - - - - 3 changed files: - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/Types.hs Changes: ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE StrictData #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeApplications #-} ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Error import GHC.Utils.Logger +import GHC.Utils.Misc import GHC.Utils.TmpFs import GHC.Unit.Env @@ -222,8 +223,8 @@ loadDependencies -> SrcSpan -> [Module] -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required +-- When called, the loader state must have been initialized (see `initLoaderState`) loadDependencies interp hsc_env pls span needed_mods = do --- initLoaderState (hsc_dflags hsc_env) dl let opts = initLinkDepsOpts hsc_env -- Find what packages and linkables are required @@ -622,6 +623,7 @@ loadExpr interp hsc_env span root_ul_bco = do where free_names = uniqDSetToList (bcoFreeNames root_ul_bco) + -- ROMES:TODO: Consider deduplicating, can have lots of duplicates. needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, isExternalName n, -- Names from other modules @@ -932,6 +934,7 @@ linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) + -- ROMES:TODO: Can we do this linkBCO sequence concurrently?! resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE StrictData #-} ----------------------------------------------------------------------------- -- -- Types for the linkers and the loader View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba972f7d77b75941b19d44ad7c505c28d14dc8ac...f6f6541be3c57867f2b9d9c5e5dd5a5677ec476e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba972f7d77b75941b19d44ad7c505c28d14dc8ac...f6f6541be3c57867f2b9d9c5e5dd5a5677ec476e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 17:39:47 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 26 Mar 2024 13:39:47 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/here-for-ci Message-ID: <660308633eda5_2f603f3bc6c889076b@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/here-for-ci at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/here-for-ci You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 17:46:57 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 13:46:57 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] Bump haddock submodule Message-ID: <66030a118bcfb_2f603f430f88c93985@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: c394cfa7 by Ben Gamari at 2024-03-26T13:46:41-04:00 Bump haddock submodule Fixes #24485 by fixing the default hyperlinked sources URL pattern. - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 243fefaa40ddcc7c657a95e92f30cb79ec4ecb45 +Subproject commit 1432bcc943d41736eca491ecec4eb9a6304dab36 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c394cfa72daa51cfcf9b79dfbd567f0db8c9394f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c394cfa72daa51cfcf9b79dfbd567f0db8c9394f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 17:48:41 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 26 Mar 2024 13:48:41 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 2 commits: Comment indent Message-ID: <66030a79d6eb6_2f603f439031096715@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: d8e87df4 by Rodrigo Mesquita at 2024-03-26T17:33:22+00:00 Comment indent - - - - - 638e7bc2 by Rodrigo Mesquita at 2024-03-26T17:48:24+00:00 delete misguided change - - - - - 2 changed files: - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Linker/Types.hs Changes: ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE StrictData #-} +-- {-# LANGUAGE StrictData #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeApplications #-} ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -186,10 +186,10 @@ instance Outputable LoadedPkgInfo where -- | Information we can use to dynamically link modules into the compiler data Linkable = LM { - linkableTime :: !UTCTime, -- ^ Time at which this linkable was built + linkableTime :: !UTCTime, -- ^ Time at which this linkable was built -- (i.e. when the bytecodes were produced, -- or the mod date on the files) - linkableModule :: !Module, -- ^ The linkable module itself + linkableModule :: !Module, -- ^ The linkable module itself linkableUnlinked :: [Unlinked] -- ^ Those files and chunks of code we have yet to link. -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f6f6541be3c57867f2b9d9c5e5dd5a5677ec476e...638e7bc233658597898fa368ac0e68833223f661 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f6f6541be3c57867f2b9d9c5e5dd5a5677ec476e...638e7bc233658597898fa368ac0e68833223f661 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 18:47:51 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 26 Mar 2024 14:47:51 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <66031857c0f0c_2f603f60ec7ec12182@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: c28849fe by Jade at 2024-03-26T19:52:19+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the 'haType' of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the 'haType' of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- @hdlType@ is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- @hdlType@ is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- @hdlType@ is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- @hdlType@ is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +- ----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,242 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will invoke 'show' and cause strings to be printed +-- with quotation marks and non-ascii symbols escaped. +-- +-- >>> print "λ :D" +-- "\995 :D" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). +-- +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 -- -- @since base-4.15.0.0 - getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- >>> take 5 <$> readFile "/dev/zero" +-- "\NUL\NUL\NUL\NUL\NUL" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. +-- +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. -- -- @since base-4.15.0.0 - readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'GHC.Internal.System.IO.Error.isUserError' if there is no unambiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,7 +552,7 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by -- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. @@ -393,21 +565,22 @@ localeEncoding = initLocaleEncoding -- This operation may fail with: -- -- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +588,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +640,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +690,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c28849fe17c9f4e16d86a5544b6ff330f9539a5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c28849fe17c9f4e16d86a5544b6ff330f9539a5f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 18:56:10 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 26 Mar 2024 14:56:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: configure: Use LDFLAGS when trying linkers Message-ID: <66031a4aab72_2f603f62d9b901268d0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b25725ec by Rodrigo Mesquita at 2024-03-26T14:56:01-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - 3300d2b4 by Rodrigo Mesquita at 2024-03-26T14:56:02-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - e1e7a132 by Rodrigo Mesquita at 2024-03-26T14:56:02-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 15 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - distrib/configure.ac.in - hadrian/bindist/Makefile - m4/fp_cc_linker_flag_try.m4 - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== distrib/configure.ac.in ===================================== @@ -105,6 +105,29 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) fi + +if test "$HostOS" = "darwin"; then + # On darwin, we need to clean the extended attributes of the + # ghc-toolchain binary and its dynamic library before we can execute it in the bindist + # (this is a workaround for #24554, for the lack of proper notarisation #17418) + + # The following is the work around suggested by @carter in #17418 during + # install time. This should help us with code signing issues by removing + # extended attributes from all files. + XATTR=${XATTR:-/usr/bin/xattr} + + if [ -e "${XATTR}" ]; then + + # Instead of cleaning the attributes of the ghc-toolchain binary only, + # we clean them from all files in the bin/ and lib/ directories, as it additionally future + # proofs running executables from the bindist besides ghc-toolchain at configure time, and + # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. + /usr/bin/xattr -rc bin/ + /usr/bin/xattr -rc lib/ + + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) ===================================== hadrian/bindist/Makefile ===================================== @@ -19,13 +19,6 @@ default: # TODO : find if a better function exists eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# the following is the work around suggested by @carter in #17418 during install -# time. This should help us with code signing issues by removing extended -# attributes from all files. -ifeq "$(Darwin_Host)" "YES" -XATTR ?= /usr/bin/xattr -endif - # patchpackageconf # # Hacky function to patch up the 'haddock-interfaces' and 'haddock-html' @@ -157,10 +150,6 @@ install_bin_libdir: $(INSTALL_PROGRAM) "$$i" "$(DESTDIR)$(ActualBinsDir)"; \ fi; \ done - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualBinsDir)"; \ - fi .PHONY: install_bin_direct install_bin_direct: @@ -195,10 +184,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ - fi .PHONY: install_docs install_docs: ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0fcc5b8433fad7b479c21b270e96d9a1cd45c939...e1e7a13281bc69e1a02d78ce4c5874e7cf2e3b54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0fcc5b8433fad7b479c21b270e96d9a1cd45c939...e1e7a13281bc69e1a02d78ce4c5874e7cf2e3b54 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 20:37:13 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 26 Mar 2024 16:37:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-trailing-zero-width-semis Message-ID: <660331f967dac_2f603f8fc35701458f2@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-trailing-zero-width-semis at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-trailing-zero-width-semis You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 23:07:06 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 19:07:06 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] Add build ordering edge for GHC.IO.Encoding.Iconv Message-ID: <6603551abf93_2f603fd2d4364163061@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 77e9b2d7 by Ben Gamari at 2024-03-26T19:06:22-04:00 Add build ordering edge for GHC.IO.Encoding.Iconv - - - - - 1 changed file: - libraries/base/src/GHC/IO/Encoding/Iconv.hs Changes: ===================================== libraries/base/src/GHC/IO/Encoding/Iconv.hs ===================================== @@ -27,4 +27,5 @@ import GHC.Internal.IO.Encoding.Iconv #else ( ) where +import GHC.Num.BigNat () -- for build ordering (#23942) #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77e9b2d7e56388264d98de62dd9346dea38be8c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77e9b2d7e56388264d98de62dd9346dea38be8c3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Mar 26 23:53:52 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 19:53:52 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] Add build ordering edge for GHC.IO.Encoding.Iconv Message-ID: <66036010847f3_2f603fe867ed816592e@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 337a5073 by Ben Gamari at 2024-03-26T19:53:32-04:00 Add build ordering edge for GHC.IO.Encoding.Iconv - - - - - 1 changed file: - libraries/base/src/GHC/IO/Encoding/Iconv.hs Changes: ===================================== libraries/base/src/GHC/IO/Encoding/Iconv.hs ===================================== @@ -27,4 +27,5 @@ import GHC.Internal.IO.Encoding.Iconv #else ( ) where +import Prelude () -- for build ordering (#23942) #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/337a5073e23fcb82e6b341ce083708e736c9ea89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/337a5073e23fcb82e6b341ce083708e736c9ea89 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 01:16:38 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 26 Mar 2024 21:16:38 -0400 Subject: [Git][ghc/ghc][master] configure: Use LDFLAGS when trying linkers Message-ID: <6603737643b29_2f603f10fa8a10178174@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - 1 changed file: - m4/fp_cc_linker_flag_try.m4 Changes: ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32a8103f3b3e22907fdd67b69c919c5251d8cc20 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32a8103f3b3e22907fdd67b69c919c5251d8cc20 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 01:17:24 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 26 Mar 2024 21:17:24 -0400 Subject: [Git][ghc/ghc][master] bindist: Clean xattrs of bin and lib at configure time Message-ID: <660373a4a6cb2_2f603f11166adc18336b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - 2 changed files: - distrib/configure.ac.in - hadrian/bindist/Makefile Changes: ===================================== distrib/configure.ac.in ===================================== @@ -105,6 +105,29 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) fi + +if test "$HostOS" = "darwin"; then + # On darwin, we need to clean the extended attributes of the + # ghc-toolchain binary and its dynamic library before we can execute it in the bindist + # (this is a workaround for #24554, for the lack of proper notarisation #17418) + + # The following is the work around suggested by @carter in #17418 during + # install time. This should help us with code signing issues by removing + # extended attributes from all files. + XATTR=${XATTR:-/usr/bin/xattr} + + if [ -e "${XATTR}" ]; then + + # Instead of cleaning the attributes of the ghc-toolchain binary only, + # we clean them from all files in the bin/ and lib/ directories, as it additionally future + # proofs running executables from the bindist besides ghc-toolchain at configure time, and + # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. + /usr/bin/xattr -rc bin/ + /usr/bin/xattr -rc lib/ + + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) ===================================== hadrian/bindist/Makefile ===================================== @@ -19,13 +19,6 @@ default: # TODO : find if a better function exists eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# the following is the work around suggested by @carter in #17418 during install -# time. This should help us with code signing issues by removing extended -# attributes from all files. -ifeq "$(Darwin_Host)" "YES" -XATTR ?= /usr/bin/xattr -endif - # patchpackageconf # # Hacky function to patch up the 'haddock-interfaces' and 'haddock-html' @@ -157,10 +150,6 @@ install_bin_libdir: $(INSTALL_PROGRAM) "$$i" "$(DESTDIR)$(ActualBinsDir)"; \ fi; \ done - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualBinsDir)"; \ - fi .PHONY: install_bin_direct install_bin_direct: @@ -195,10 +184,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ - fi .PHONY: install_docs install_docs: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf65a7c388b399b7b3c6b97f25d97164390b75f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf65a7c388b399b7b3c6b97f25d97164390b75f1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 01:18:08 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 26 Mar 2024 21:18:08 -0400 Subject: [Git][ghc/ghc][master] Revert "NCG: Fix a bug in jump shortcutting." Message-ID: <660373d056801_2f603f1134ab50187835@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 12 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfeb70d3fed9c135295359296208bd800bab418f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfeb70d3fed9c135295359296208bd800bab418f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 01:37:22 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 21:37:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24588 Message-ID: <66037852d6659_2f603f122feed4196673@gitlab.mail> Ben Gamari pushed new branch wip/T24588 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24588 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 01:48:43 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 26 Mar 2024 21:48:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: configure: Use LDFLAGS when trying linkers Message-ID: <66037afab4930_2f603f1268a3f0199790@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 00306827 by Serge S. Gulin at 2024-03-26T21:48:32-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 3d686560 by Alan Zimmerman at 2024-03-26T21:48:33-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - 20 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Parser.y - distrib/configure.ac.in - hadrian/bindist/Makefile - m4/fp_cc_linker_flag_try.m4 - rts/js/profiling.js - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PprLetIn.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Parser.y ===================================== @@ -1438,10 +1438,10 @@ ty_fam_inst_eqns :: { Located [LTyFamInstEqn GhcPs] } h' <- addTrailingSemiA h (gl $2) return (sLL $1 $> ($3 : h' : t)) } | ty_fam_inst_eqns ';' {% case unLoc $1 of - [] -> return (sLL $1 $> (unLoc $1)) + [] -> return (sLZ $1 $> (unLoc $1)) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | ty_fam_inst_eqn { sLL $1 $> [$1] } | {- empty -} { noLoc [] } @@ -1719,12 +1719,12 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_cls { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1765,12 +1765,12 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_inst { sL1 $1 ([],unLoc $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1806,12 +1806,12 @@ decls :: { Located ([AddEpAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLL $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemiA $2) + then return (sLZ $1 $> (((fst $ unLoc $1) ++ (msemiA $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -3334,11 +3334,11 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs return (sLL $1 $> (fst $ unLoc $1,$3 : h' : t)) } | alts1(PATS) ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (fst $ unLoc $1, h' : t)) } + return (sLZ $1 $> (fst $ unLoc $1, h' : t)) } | alt(PATS) { $1 >>= \ $1 -> return $ sL1 $1 ([],[$1]) } alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) } @@ -3442,7 +3442,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} @@ -3552,7 +3552,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed | dbinds ';' {% case unLoc $1 of (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | dbind { let this = $1 in this `seq` (sL1 $1 [this]) } -- | {- empty -} { [] } @@ -4195,6 +4195,12 @@ sLLAsl :: (HasLoc a) => [a] -> Located b -> c -> Located c sLLAsl [] = sL1 sLLAsl (!x:_) = sLL x +{-# INLINE sLZ #-} +sLZ :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c +sLZ !x !y = if isZeroWidthSpan (getHasLoc y) + then sL (getHasLoc x) + else sL (comb2 x y) + {- Note [Adding location info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== distrib/configure.ac.in ===================================== @@ -105,6 +105,29 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) fi + +if test "$HostOS" = "darwin"; then + # On darwin, we need to clean the extended attributes of the + # ghc-toolchain binary and its dynamic library before we can execute it in the bindist + # (this is a workaround for #24554, for the lack of proper notarisation #17418) + + # The following is the work around suggested by @carter in #17418 during + # install time. This should help us with code signing issues by removing + # extended attributes from all files. + XATTR=${XATTR:-/usr/bin/xattr} + + if [ -e "${XATTR}" ]; then + + # Instead of cleaning the attributes of the ghc-toolchain binary only, + # we clean them from all files in the bin/ and lib/ directories, as it additionally future + # proofs running executables from the bindist besides ghc-toolchain at configure time, and + # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. + /usr/bin/xattr -rc bin/ + /usr/bin/xattr -rc lib/ + + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) ===================================== hadrian/bindist/Makefile ===================================== @@ -19,13 +19,6 @@ default: # TODO : find if a better function exists eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# the following is the work around suggested by @carter in #17418 during install -# time. This should help us with code signing issues by removing extended -# attributes from all files. -ifeq "$(Darwin_Host)" "YES" -XATTR ?= /usr/bin/xattr -endif - # patchpackageconf # # Hacky function to patch up the 'haddock-interfaces' and 'haddock-html' @@ -157,10 +150,6 @@ install_bin_libdir: $(INSTALL_PROGRAM) "$$i" "$(DESTDIR)$(ActualBinsDir)"; \ fi; \ done - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualBinsDir)"; \ - fi .PHONY: install_bin_direct install_bin_direct: @@ -195,10 +184,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ - fi .PHONY: install_docs install_docs: ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) ===================================== rts/js/profiling.js ===================================== @@ -331,7 +331,3 @@ function h$buildCCSPtr(o) { function h$clearCCS(a) { throw new Error("ClearCCSOp not implemented"); } - -function h$rts_isProfiled() { - return 0; -} ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -821,3 +821,8 @@ AnnotationNoListTuplePuns: Test24533: $(CHECK_PPR) $(LIBDIR) Test24533.hs $(CHECK_EXACT) $(LIBDIR) Test24533.hs + +.PHONY: PprLetIn +PprLetIn: + $(CHECK_PPR) $(LIBDIR) PprLetIn.hs + $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs ===================================== testsuite/tests/printer/PprLetIn.hs ===================================== @@ -0,0 +1,5 @@ +module PprLetIn where + +ff = let + x = 1 + in 4 ===================================== testsuite/tests/printer/all.T ===================================== @@ -197,3 +197,4 @@ test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) +test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1e7a13281bc69e1a02d78ce4c5874e7cf2e3b54...3d686560e3d994c23e32cfe4da823b221d080520 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1e7a13281bc69e1a02d78ce4c5874e7cf2e3b54...3d686560e3d994c23e32cfe4da823b221d080520 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 02:20:17 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 22:20:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24598 Message-ID: <66038261a251e_2f603f136990982121ec@gitlab.mail> Ben Gamari pushed new branch wip/T24598 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24598 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 03:07:39 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 23:07:39 -0400 Subject: [Git][ghc/ghc][wip/T24598] compiler: Allow more types in GHCForeignImportPrim Message-ID: <66038d7b93954_2f603f150584482243cb@gitlab.mail> Ben Gamari pushed to branch wip/T24598 at Glasgow Haskell Compiler / GHC Commits: 67dd5635 by Ben Gamari at 2024-03-26T23:07:21-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 10 changed files: - compiler/GHC/Tc/Gen/Foreign.hs - + testsuite/tests/ffi/should_run/T24598.hs - + testsuite/tests/ffi/should_run/T24598.stdout - + testsuite/tests/ffi/should_run/T24598_cmm.cmm - + testsuite/tests/ffi/should_run/T24598b.hs - + testsuite/tests/ffi/should_run/T24598b.stdout - + testsuite/tests/ffi/should_run/T24598b_cmm.cmm - + testsuite/tests/ffi/should_run/T24598c.hs - + testsuite/tests/ffi/should_run/T24598c_cmm.cmm - testsuite/tests/ffi/should_run/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -84,7 +84,6 @@ import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class ( lift ) import Data.Maybe (isJust) -import GHC.Types.RepType (tyConPrimRep) import GHC.Builtin.Types (unitTyCon) -- Defines a binding @@ -737,7 +736,6 @@ marshalablePrimTyCon tc = isPrimTyCon tc && not (isLiftedTypeKind (tyConResKind marshalableTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledReason marshalableTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | otherwise = boxedMarshalableTyCon tc @@ -772,7 +770,6 @@ legalFIPrimResultTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledRe -- types and also unboxed tuple and sum result types. legalFIPrimResultTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | isUnboxedTupleTyCon tc || isUnboxedSumTyCon tc @@ -786,13 +783,3 @@ validIfUnliftedFFITypes dflags | xopt LangExt.UnliftedFFITypes dflags = IsValid | otherwise = NotValid UnliftedFFITypesNeeded -{- -Note [Marshalling void] -~~~~~~~~~~~~~~~~~~~~~~~ -We don't treat State# (whose PrimRep is VoidRep) as marshalable. -In turn that means you can't write - foreign import foo :: Int -> State# RealWorld - -Reason: the back end falls over with panic "primRepHint:VoidRep"; - and there is no compelling reason to permit it --} ===================================== testsuite/tests/ffi/should_run/T24598.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in results correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello >>= print + +hello :: IO Int +hello = IO $ \s -> case hello# s of (# s', n# #) -> (# s', I# n# #) ===================================== testsuite/tests/ffi/should_run/T24598.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello() { + return (42); +} ===================================== testsuite/tests/ffi/should_run/T24598b.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: Int# -> State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello 21 >>= print + +hello :: Int -> IO Int +hello (I# n#) = IO $ \s -> + case hello# n# s of (# s', n# #) -> (# s', I# n# #) + ===================================== testsuite/tests/ffi/should_run/T24598b.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598b_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello(W_ n) { + return (2*n); +} ===================================== testsuite/tests/ffi/should_run/T24598c.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> State# RealWorld + +main :: IO () +main = hello + +hello :: IO () +hello = IO $ \s -> + case hello# s of s' -> (# s', () #) + ===================================== testsuite/tests/ffi/should_run/T24598c_cmm.cmm ===================================== @@ -0,0 +1,11 @@ +#include "Cmm.h" + +section "data" { + test_str: bits8[] "hello"; +} + +hello() { + ccall puts(test_str); + return (); +} + ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -268,3 +268,7 @@ test('T24314', # libffi-wasm doesn't support more than 4 args yet when(arch('wasm32'), skip)], compile_and_run, ['T24314_c.c']) + +test('T24598', req_cmm, compile_and_run, ['T24598_cmm.cmm']) +test('T24598b', req_cmm, compile_and_run, ['T24598b_cmm.cmm']) +test('T24598c', req_cmm, compile_and_run, ['T24598c_cmm.cmm']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/67dd56359afd4c575d733269189b7bb5a9127946 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/67dd56359afd4c575d733269189b7bb5a9127946 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 03:40:54 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 23:40:54 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/ghc-9.10 Message-ID: <66039546cf407_2f603f15ff9c802329ec@gitlab.mail> Ben Gamari deleted branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 03:40:58 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 26 Mar 2024 23:40:58 -0400 Subject: [Git][ghc/ghc][ghc-9.10] 12 commits: Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" Message-ID: <6603954ad1177_2f603f16006930233153@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: b09cbad8 by Zubin Duggal at 2024-03-25T12:21:37-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- (cherry picked from commit 576f8b7ec292382aaa47fceab504b5abf4cc1f8a) - - - - - 0d4ee209 by Andrei Borzenkov at 2024-03-25T12:27:07-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) (cherry picked from commit 7ea971d314c4eba59e12e94bf3eb8edb95fbfac5) - - - - - 688cb2ff by Cheng Shao at 2024-03-25T12:28:00-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. (cherry picked from commit 39f3ac3e1b47e9fdac8fcf2d1edcc300a37deb82) - - - - - c5c19c14 by Cheng Shao at 2024-03-25T12:28:01-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. (cherry picked from commit e6bfb85c842edca36754bb8914e725fbaa1a83a6) - - - - - 67defa84 by Alan Zimmerman at 2024-03-25T12:28:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 (cherry picked from commit 7da7f8f643f1bfc4aa034a731f2f85cda007b286) - - - - - 97afcca5 by Alan Zimmerman at 2024-03-25T12:28:31-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time (cherry picked from commit bd8209eb8e447a5ae1d736f034f4a3986e0727f7) - - - - - 850fc30e by Alan Zimmerman at 2024-03-25T12:28:48-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework (cherry picked from commit 5f27517687c711593a23f1c9e5bd09ad9ec22fa4) - - - - - 01a6a717 by Vladislav Zavialov at 2024-03-25T12:29:02-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. (cherry picked from commit da2a10ceab7498fbbd5723dee0393ce75f2bb562) - - - - - e5b111e9 by Simon Peyton Jones at 2024-03-25T12:29:15-04:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 (cherry picked from commit 97a2bb1cdfa4b244a58374658aec6d48ce23a54a) - - - - - 222a5240 by Andrei Borzenkov at 2024-03-25T12:29:27-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () (cherry picked from commit 6fafc51e9206abd62881131c282ec3b9e1584c5b) - - - - - c394cfa7 by Ben Gamari at 2024-03-26T13:46:41-04:00 Bump haddock submodule Fixes #24485 by fixing the default hyperlinked sources URL pattern. - - - - - 337a5073 by Ben Gamari at 2024-03-26T19:53:32-04:00 Add build ordering edge for GHC.IO.Encoding.Iconv - - - - - 30 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/cbits/genSym.c - libraries/base/src/GHC/IO/Encoding/Iconv.hs - m4/fp_settings.m4 - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24533.hs - + testsuite/tests/printer/Test24533.stdout - testsuite/tests/printer/all.T - + testsuite/tests/th/T24559.hs - + testsuite/tests/th/T24571.hs - testsuite/tests/th/all.T - + testsuite/tests/typecheck/should_compile/T24470b.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T24470a.hs - + testsuite/tests/typecheck/should_fail/T24470a.stderr - testsuite/tests/typecheck/should_fail/all.T - + testsuite/tests/vdq-rta/should_compile/T24570.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cf814fe982f42483c672802ce905350d99a85a35...337a5073e23fcb82e6b341ce083708e736c9ea89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cf814fe982f42483c672802ce905350d99a85a35...337a5073e23fcb82e6b341ce083708e736c9ea89 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 08:31:03 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 27 Mar 2024 04:31:03 -0400 Subject: [Git][ghc/ghc][wip/T24359] Working I think Message-ID: <6603d9474845c_2f603f1da80170239545@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: 84958f48 by Simon Peyton Jones at 2024-03-27T08:30:44+00:00 Working I think - - - - - 4 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Zonk/Type.hs Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -963,7 +963,7 @@ instance Outputable TcSpecPrag where ppr (SpecPragE { spe_tv_bndrs = tv_bndrs, spe_id_bndrs = id_bndrs , spe_call = spec_e, spe_inl = inl }) = text (extractSpecPragName $ inl_src inl) - <+> hang (ppr (tv_bndrs ++ id_bndrs) 2 (pprLExpr spec_e) + <+> hang (ppr (tv_bndrs ++ id_bndrs)) 2 (pprLExpr spec_e) pprMinimalSig :: (OutputableBndr name) => LBooleanFormula (GenLocated l name) -> SDoc ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -827,42 +827,49 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl)) -- E.g. /\a \(d:Eq a). let d2 = $df d in [] (Maybe a) d2 = putSrcSpanDs loc $ dsHsWrapper spec_app $ \core_app -> - finishSpecPrag mb_poly_rhs spec_bndrs - (core_app (Var poly_id)) - (\_ poly_rhs -> core_app poly_rhs) + finishSpecPrag mb_poly_rhs + spec_bndrs (core_app (Var poly_id)) + spec_bndrs (\_ poly_rhs -> core_app poly_rhs) spec_inl -dsSpec mb_poly_rhs (L loc (SpecPragE { spe_bndrs = bndrs +dsSpec mb_poly_rhs (L loc (SpecPragE { spe_tv_bndrs = tv_bndrs + , spe_id_bndrs = id_bndrs + , spe_lhs_ev_bndrs = lhs_evs , spe_lhs_binds = lhs_binds , spe_call = the_call + , spe_rhs_ev_bndrs = rhs_evs , spe_rhs_binds = rhs_binds , spe_inl = inl })) = putSrcSpanDs loc $ - do { core_call <- dsTcEvBinds lhs_binds $ \ ds_binds -> - do { ds_call <- dsLExpr the_call - ; return (mkLets ds_binds ds_call) } + dsTcEvBinds lhs_binds $ \ ds_lhs_binds -> + dsTcEvBinds rhs_binds $ \ ds_rhs_binds -> + do { ds_call <- dsLExpr the_call + ; let core_call = mkLets ds_lhs_binds ds_call - ; mk_spec_call <- dsTcEvBinds rhs_binds $ \ ds_binds -> - do { ds_call <- dsLExpr the_call + ; mk_spec_call <- do { ds_call <- dsLExpr the_call ; return $ \ poly_id poly_rhs -> - mkLetNonRec poly_id poly_rhs $ - mkLets ds_binds ds_call } + mkLetNonRec (localiseId poly_id) poly_rhs $ + mkLets ds_lhs_binds $ + mkLets ds_rhs_binds ds_call } - ; finishSpecPrag mb_poly_rhs bndrs core_call mk_spec_call inl } + ; finishSpecPrag mb_poly_rhs + (tv_bndrs ++ lhs_evs ++ id_bndrs) core_call + (tv_bndrs ++ rhs_evs ++ id_bndrs) mk_spec_call + inl } finishSpecPrag :: Maybe CoreExpr -- See the first param of dsSpec -> [Var] -- LHS binders -> CoreExpr -- LHS pattern - -> (Id -> CoreExpr -> CoreExpr) -- Make spec RHS given function body + -> [Var] -> (Id -> CoreExpr -> CoreExpr) -- Make spec RHS given function body -> InlinePragma -> DsM (Maybe (OrdList (Id,CoreExpr), CoreRule)) -finishSpecPrag mb_poly_rhs spec_bndrs - rule_lhs - mk_spec_rhs +finishSpecPrag mb_poly_rhs + lhs_bndrs rule_lhs + spec_bndrs mk_spec_rhs spec_inl = do { dflags <- getDynFlags - ; case decomposeRuleLhs dflags spec_bndrs rule_lhs (mkVarSet spec_bndrs) of { + ; case decomposeRuleLhs dflags lhs_bndrs rule_lhs (mkVarSet lhs_bndrs) of { Left msg -> do { diagnosticDs msg; return Nothing } ; Right (rule_bndrs, poly_id, rule_lhs_args) -> @@ -871,7 +878,6 @@ finishSpecPrag mb_poly_rhs spec_bndrs ; let poly_name = idName poly_id spec_occ = mkSpecOcc (getOccName poly_name) spec_name = mkInternalName uniq spec_occ (getSrcSpan poly_name) - spec_ty = mkLamTypes spec_bndrs (exprType rule_lhs) poly_rhs = specFunBody poly_id mb_poly_rhs id_inl = idInlinePragma poly_id inl_prag = specFunInlinePrag mb_poly_rhs poly_id id_inl spec_inl @@ -880,6 +886,7 @@ finishSpecPrag mb_poly_rhs spec_bndrs simpl_opts = initSimpleOpts dflags fn_unf = realIdUnfolding poly_id spec_unf = specUnfolding simpl_opts spec_bndrs mk_app rule_lhs_args fn_unf + mk_app e = mkApps e rule_lhs_args spec_id = mkLocalId spec_name ManyTy spec_ty -- Specialised binding is toplevel, hence Many. `setInlinePragma` inl_prag @@ -887,9 +894,9 @@ finishSpecPrag mb_poly_rhs spec_bndrs rule = mkSpecRule dflags this_mod False rule_act (text "USPEC") poly_id rule_bndrs rule_lhs_args - (mkVarApps (Var spec_id) spec_bndrs) + (mkVarApps (Var spec_id) lhs_bndrs) - mk_app e = mkApps e rule_lhs_args + spec_ty = mkLamTypes spec_bndrs (exprType rule_lhs) spec_rhs = mkLams spec_bndrs $ mk_spec_rhs poly_id poly_rhs ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -877,21 +877,22 @@ tcSpecPrag _poly_id (SpecSigE nm bndrs spec_e inl) qtkvs lhs_evs residual_wanted -- rhs_binds uses rhs_evs to build `wanted` (NB not just `residual_wanted`) - ; let rhs_preds = mkMinimalBySCs id quant_preds - ; rhs_evs <- mapM newEvVar rhs_preds + ; let quant_wanted = emptyWC { wc_simple = quant_cts } + ; rhs_evs <- mapM newEvVar quant_preds ; (implic2, rhs_binds) <- buildImplicationFor tc_lvl skol_info_anon - qtkvs rhs_evs wanted + qtkvs rhs_evs quant_wanted ; emitImplications (implic1 `unionBags` implic2) - ; let all_bndrs = qtkvs ++ rule_evs ++ id_bndrs ; traceTc "tcSpecPrag:SpecSigE" $ - vcat [ text "all_bndrs:" <+> ppr all_bndrs + vcat [ text "tv/id bndrs:" <+> ppr qtkvs <+> ppr id_bndrs + , text "lhs_evs:" <+> ppr lhs_evs + , text "rhs_evs:" <+> ppr rhs_evs , text "spec_e:" <+> ppr spec_e' , text "inl:" <+> ppr inl ] ; return [SpecPragE { spe_tv_bndrs = qtkvs , spe_id_bndrs = id_bndrs - , spe_lhs_ev_bndrs = rule_evs + , spe_lhs_ev_bndrs = lhs_evs , spe_lhs_binds = lhs_binds , spe_rhs_ev_bndrs = rhs_evs , spe_rhs_binds = rhs_binds ===================================== compiler/GHC/Tc/Zonk/Type.hs ===================================== @@ -855,15 +855,22 @@ zonkLTcSpecPrags ps = do { co_fn' <- don'tBind $ zonkCoFn co_fn ; id' <- zonkIdOcc id ; return (L loc (SpecPrag id' co_fn' inl)) } - zonk_prag (L loc (SpecPragE { spe_bndrs = bndrs, spe_lhs_binds = lhs_binds - , spe_call = spec_e, spe_rhs_binds = rhs_binds + zonk_prag (L loc (SpecPragE { spe_tv_bndrs = tv_bndrs, spe_id_bndrs = id_bndrs + , spe_lhs_ev_bndrs = lhs_evs, spe_rhs_ev_bndrs = rhs_evs + , spe_lhs_binds = lhs_binds, spe_rhs_binds = rhs_binds + , spe_call = spec_e , spe_inl = inl })) - = runZonkBndrT (zonkCoreBndrsX bndrs) $ \bndrs' -> - runZonkBndrT (zonkTcEvBinds lhs_binds) $ \lhs_binds' -> - runZonkBndrT (zonkTcEvBinds rhs_binds) $ \rhs_binds' -> + = runZonkBndrT (zonkCoreBndrsX tv_bndrs) $ \tv_bndrs' -> + runZonkBndrT (zonkCoreBndrsX id_bndrs) $ \id_bndrs' -> + runZonkBndrT (zonkCoreBndrsX lhs_evs) $ \lhs_evs' -> + runZonkBndrT (zonkTcEvBinds lhs_binds) $ \lhs_binds' -> + runZonkBndrT (zonkCoreBndrsX rhs_evs) $ \rhs_evs' -> + runZonkBndrT (zonkTcEvBinds rhs_binds) $ \rhs_binds' -> do { spec_e' <- zonkLExpr spec_e - ; return (L loc (SpecPragE { spe_bndrs = bndrs', spe_lhs_binds = lhs_binds' - , spe_call = spec_e', spe_rhs_binds = rhs_binds' + ; return (L loc (SpecPragE { spe_tv_bndrs = tv_bndrs', spe_id_bndrs = id_bndrs' + , spe_lhs_ev_bndrs = lhs_evs', spe_rhs_ev_bndrs = rhs_evs' + , spe_lhs_binds = lhs_binds', spe_rhs_binds = rhs_binds' + , spe_call = spec_e' , spe_inl = inl })) } {- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84958f48c4200b2861c47af802c031d042226db9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84958f48c4200b2861c47af802c031d042226db9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 10:07:41 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 27 Mar 2024 06:07:41 -0400 Subject: [Git][ghc/ghc][wip/T23536-teo] Make template-haskell a stage1 package Message-ID: <6603efedb5b36_3d40562a5e414477f5@gitlab.mail> Teo Camarasu pushed to branch wip/T23536-teo at Glasgow Haskell Compiler / GHC Commits: e9290c3e by Teo Camarasu at 2024-03-27T10:07:17+00:00 Make template-haskell a stage1 package We enable building stage1 ghc with the boot version of template-haskell (and all its dependencies). Both template-haskell and ghc-boot-th are promoted to stage1 packages. We add CPP to the modules converting between TH and GHC ASTs to deal with differences between TH versions. The canonical list of language extensions lives in `ghc-boot-th`. As this is a dependency of template-haskell, we must use the boot version when building stage1 GHC. In that case, we add a duplicate list of language extensions to `ghc-boot` with the full list of language extensions for the in-tree version of GHC. We avoid duplicating the file by using an in-tree symlink. Resolves #23536 - - - - - 14 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/ghc-boot/GHC/LanguageExtensions.hs - + libraries/ghc-boot/GHC/LanguageExtensions/Type.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map import Data.List.NonEmpty (NonEmpty(..)) -import GHC.LanguageExtensions.Type +import GHC.LanguageExtensions import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -11,6 +11,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -161,6 +162,14 @@ type MetaM a = ReaderT MetaWrappers DsM a getPlatform :: MetaM Platform getPlatform = targetPlatform <$> getDynFlags +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +type THArgPat = TH.ArgPat +#else +type THArgPat = TH.Pat +type BndrVis = () +#endif + ----------------------------------------------------------------------------- dsBracket :: HsBracketTc -> DsM CoreExpr -- See Note [Desugaring Brackets] @@ -513,7 +522,7 @@ repKiSigD (L loc kisig) = ------------------------- repDataDefn :: Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) -- the repTyClD case (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -- the repDataFamInstD case @@ -536,7 +545,7 @@ repDataDefn tc opts derivs1 } } -repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repSynDecl :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> LHsType GhcRn -> MetaM (Core (M TH.Dec)) repSynDecl tc bndrs ty @@ -789,8 +798,13 @@ rep_fix_d loc (FixitySig ns_spec names (Fixity _ prec dir)) InfixN -> infixNWithSpecDName ; let do_one name = do { MkC name' <- lookupLOcc name +#if MIN_VERSION_template_haskell(2,22,0) ; MkC ns_spec' <- repNamespaceSpecifier ns_spec ; dec <- rep2 rep_fn [prec', ns_spec', name'] +#else + ; void $ return ns_spec -- to avoid CPP incurred unused variable warning + ; dec <- rep2 rep_fn [prec', name'] +#endif ; return (loc,dec) } ; mapM do_one names } @@ -1195,16 +1209,20 @@ rep_flag :: Specificity -> MetaM (Core TH.Specificity) rep_flag SpecifiedSpec = rep2_nw specifiedSpecName [] rep_flag InferredSpec = rep2_nw inferredSpecName [] -instance RepTV (HsBndrVis GhcRn) TH.BndrVis where +instance RepTV (HsBndrVis GhcRn) BndrVis where tyVarBndrName = tyVarBndrVisTyConName repPlainTV (MkC nm) vis = do { (MkC vis') <- rep_bndr_vis vis ; rep2 plainBndrTVName [nm, vis'] } repKindedTV (MkC nm) vis (MkC ki) = do { (MkC vis') <- rep_bndr_vis vis ; rep2 kindedBndrTVName [nm, vis', ki] } -rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core TH.BndrVis) +rep_bndr_vis :: HsBndrVis GhcRn -> MetaM (Core BndrVis) +#if MIN_VERSION_template_haskell(2,21,0) rep_bndr_vis (HsBndrRequired _) = rep2_nw bndrReqName [] rep_bndr_vis (HsBndrInvisible _) = rep2_nw bndrInvisName [] +#else +rep_bndr_vis _ = rep2_nw bndrReqName [] +#endif addHsOuterFamEqnTyVarBinds :: HsOuterFamEqnTyVarBndrs GhcRn @@ -1311,7 +1329,7 @@ addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside addQTyVarBinds :: FreshOrReuse -> LHsQTyVars GhcRn -- the binders to be added - -> (Core [(M (TH.TyVarBndr TH.BndrVis))] -> MetaM (Core (M a))) -- action in the ext env + -> (Core [(M (TH.TyVarBndr BndrVis))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) addQTyVarBinds fresh_or_reuse qtvs thing_inside = let HsQTvs { hsq_ext = imp_tvs @@ -2101,10 +2119,10 @@ repLP :: LPat GhcRn -> MetaM (Core (M TH.Pat)) repLP p = repP (unLoc p) -- Process a list of arg patterns -repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M TH.ArgPat])) +repLMPs :: [LArgPat GhcRn] -> MetaM (Core ([M THArgPat])) repLMPs ps = repListM argPatTyConName repLMP ps -repLMP :: LArgPat GhcRn -> MetaM (Core (M TH.ArgPat)) +repLMP :: LArgPat GhcRn -> MetaM (Core (M THArgPat)) repLMP (L _ (VisPat _ p)) = do {p' <- repLP p; repAPvis p'} repLMP (L _ (InvisPat _ t)) = do {t' <- repLTy (hstp_body t); repAPinvis t'} @@ -2417,10 +2435,10 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] repPtype :: Core (M TH.Type) -> MetaM (Core (M TH.Pat)) repPtype (MkC t) = rep2 typePName [t] -repAPvis :: Core (M TH.Pat) -> MetaM (Core (M TH.ArgPat)) +repAPvis :: Core (M TH.Pat) -> MetaM (Core (M THArgPat)) repAPvis (MkC t) = rep2 visAPName [t] -repAPinvis :: Core (M TH.Type) -> MetaM (Core (M TH.ArgPat)) +repAPinvis :: Core (M TH.Type) -> MetaM (Core (M THArgPat)) repAPinvis (MkC t) = rep2 invisAPName [t] --------------- Expressions ----------------- @@ -2446,7 +2464,7 @@ repApp (MkC x) (MkC y) = rep2 appEName [x,y] repAppType :: Core (M TH.Exp) -> Core (M TH.Type) -> MetaM (Core (M TH.Exp)) repAppType (MkC x) (MkC y) = rep2 appTypeEName [x,y] -repLam :: Core [(M TH.ArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) +repLam :: Core [(M THArgPat)] -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repLam (MkC ps) (MkC e) = rep2 lamArgEName [ps, e] repLamCase :: Core [(M TH.Match)] -> MetaM (Core (M TH.Exp)) @@ -2583,7 +2601,7 @@ repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToEName [x,y,z] repMatch :: Core (M TH.Pat) -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Match)) repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds] -repClause :: Core [(M TH.ArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) +repClause :: Core [(M THArgPat)] -> Core (M TH.Body) -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Clause)) repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseArgName [ps, bod, ds] -------------- Dec ----------------------------- @@ -2596,7 +2614,7 @@ repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] repData :: Bool -- ^ @True@ for a @type data@ declaration. -- See Note [Type data declarations] in GHC.Rename.Module -> Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2608,7 +2626,7 @@ repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] repNewtype :: Core (M TH.Cxt) -> Core TH.Name - -> Either (Core [(M (TH.TyVarBndr TH.BndrVis))]) + -> Either (Core [(M (TH.TyVarBndr BndrVis))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core (M TH.Con) -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) @@ -2619,7 +2637,7 @@ repNewtype (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC con) (MkC derivs) = rep2 newtypeInstDName [cxt, mb_bndrs, ty, ksig, con, derivs] -repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repTySyn :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.Type) -> MetaM (Core (M TH.Dec)) repTySyn (MkC nm) (MkC tvs) (MkC rhs) = rep2 tySynDName [nm, tvs, rhs] @@ -2677,14 +2695,15 @@ repOverlap mb = nothing = coreNothing overlapTyConName just = coreJust overlapTyConName - +#if MIN_VERSION_template_haskell(2,22,0) repNamespaceSpecifier :: NamespaceSpecifier -> MetaM (Core (TH.NamespaceSpecifier)) repNamespaceSpecifier ns_spec = case ns_spec of NoNamespaceSpecifier{} -> dataCon noNamespaceSpecifierDataConName TypeNamespaceSpecifier{} -> dataCon typeNamespaceSpecifierDataConName DataNamespaceSpecifier{} -> dataCon dataNamespaceSpecifierDataConName +#endif -repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repClass :: Core (M TH.Cxt) -> Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core [TH.FunDep] -> Core [(M TH.Dec)] -> MetaM (Core (M TH.Dec)) repClass (MkC cxt) (MkC cls) (MkC tvs) (MkC fds) (MkC ds) @@ -2739,13 +2758,13 @@ repTySynInst :: Core (M TH.TySynEqn) -> MetaM (Core (M TH.Dec)) repTySynInst (MkC eqn) = rep2 tySynInstDName [eqn] -repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr TH.BndrVis))] +repDataFamilyD :: Core TH.Name -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (Maybe (M TH.Kind)) -> MetaM (Core (M TH.Dec)) repDataFamilyD (MkC nm) (MkC tvs) (MkC kind) = rep2 dataFamilyDName [nm, tvs, kind] repOpenFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> MetaM (Core (M TH.Dec)) @@ -2753,7 +2772,7 @@ repOpenFamilyD (MkC nm) (MkC tvs) (MkC result) (MkC inj) = rep2 openTypeFamilyDName [nm, tvs, result, inj] repClosedFamilyD :: Core TH.Name - -> Core [(M (TH.TyVarBndr TH.BndrVis))] + -> Core [(M (TH.TyVarBndr BndrVis))] -> Core (M TH.FamilyResultSig) -> Core (Maybe TH.InjectivityAnn) -> Core [(M TH.TySynEqn)] ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -157,6 +157,7 @@ import Data.IORef import GHC.Parser.HaddockLex (lexHsDoc) import GHC.Parser (parseIdentifier) import GHC.Rename.Doc (rnHsDoc) +import GHC.LanguageExtensions @@ -1514,10 +1515,10 @@ instance TH.Quasi TcM where th_state_var <- fmap tcg_th_state getGblEnv updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m) - qIsExtEnabled = xoptM + qIsExtEnabled = xoptM . migrateExt qExtsEnabled = - EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv + map unmigrateExt . EnumSet.toList . extensionFlags . hsc_dflags <$> getTopEnv qPutDoc doc_loc s = do th_doc_var <- tcg_th_docs <$> getGblEnv @@ -2002,7 +2003,9 @@ getThing th_name ppr_ns (TH.Name _ (TH.NameG TH.DataName _pkg _mod)) = text "data" ppr_ns (TH.Name _ (TH.NameG TH.TcClsName _pkg _mod)) = text "tc" ppr_ns (TH.Name _ (TH.NameG TH.VarName _pkg _mod)) = text "var" +#if MIN_VERSION_template_haskell(2,21,0) ppr_ns (TH.Name _ (TH.NameG (TH.FldName {}) _pkg _mod)) = text "fld" +#endif ppr_ns _ = panic "reify/ppr_ns" reify :: TH.Name -> TcM TH.Info @@ -2674,6 +2677,14 @@ reifyCxt = mapM reifyType reifyFunDep :: ([TyVar], [TyVar]) -> TH.FunDep reifyFunDep (xs, ys) = TH.FunDep (map reifyName xs) (map reifyName ys) +#if MIN_VERSION_template_haskell(2,21,0) +type BndrVis = TH.BndrVis +#else +type BndrVis = () +deriving instance Foldable TH.TyVarBndr +deriving instance Traversable TH.TyVarBndr +#endif + class ReifyFlag flag flag' | flag -> flag' where reifyFlag :: flag -> flag' @@ -2684,15 +2695,19 @@ instance ReifyFlag Specificity TH.Specificity where reifyFlag SpecifiedSpec = TH.SpecifiedSpec reifyFlag InferredSpec = TH.InferredSpec -instance ReifyFlag TyConBndrVis (Maybe TH.BndrVis) where +instance ReifyFlag TyConBndrVis (Maybe BndrVis) where +#if MIN_VERSION_template_haskell(2,21,0) reifyFlag AnonTCB = Just TH.BndrReq reifyFlag (NamedTCB Required) = Just TH.BndrReq reifyFlag (NamedTCB (Invisible _)) = Nothing -- See Note [Reifying invisible type variable binders] and #22828. +#else + reifyFlag _ = Just () +#endif -- Currently does not return invisible type variable binders (@k-binders). -- See Note [Reifying invisible type variable binders] and #22828. -reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr TH.BndrVis] +reifyTyConBinders :: TyCon -> TcM [TH.TyVarBndr BndrVis] reifyTyConBinders tc = fmap (mapMaybe get_bndr) (reifyTyVarBndrs (tyConBinders tc)) where get_bndr :: TH.TyVarBndr (Maybe flag) -> Maybe (TH.TyVarBndr flag) @@ -2801,8 +2816,10 @@ reifyName thing mk_varg | OccName.isDataOcc occ = TH.mkNameG_d | OccName.isVarOcc occ = TH.mkNameG_v | OccName.isTcOcc occ = TH.mkNameG_tc +#if MIN_VERSION_template_haskell(2,21,0) | Just con_fs <- OccName.fieldOcc_maybe occ = \ pkg mod occ -> TH.mkNameG_fld pkg mod (unpackFS con_fs) occ +#endif | otherwise = pprPanic "reifyName" (ppr name) reifyFieldLabel :: FieldLabel -> TH.Name ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -164,6 +165,10 @@ wrapLA (CvtM m) = CvtM $ \origin loc -> case m origin loc of Left err -> Left err Right (loc', v) -> Right (loc', L (noAnnSrcSpan loc) v) +#if !MIN_VERSION_template_haskell(2,21,0) +type BndrVis = () +#endif + {- Note [Source locations within TH splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -243,19 +248,31 @@ cvtDec (TH.KiSigD nm ki) ; let sig' = StandaloneKindSig noAnn nm' ki' ; returnJustLA $ Hs.KindSigD noExtField sig' } -cvtDec (TH.InfixD fx th_ns_spec nm) +cvtDec (TH.InfixD fx +#if MIN_VERSION_template_haskell(2,22,0) + th_ns_spec +#endif + nm) -- Fixity signatures are allowed for variables, constructors, and types -- the renamer automatically looks for types during renaming, even when -- the RdrName says it's a variable or a constructor. So, just assume -- it's a variable or constructor and proceed. = do { nm' <- vcNameN nm ; returnJustLA (Hs.SigD noExtField (FixSig noAnn - (FixitySig ns_spec [nm'] (cvtFixity fx)))) } + (FixitySig +#if MIN_VERSION_template_haskell(2,22,0) + ns_spec +#else + Hs.NoNamespaceSpecifier +#endif + [nm'] (cvtFixity fx)))) } where +#if MIN_VERSION_template_haskell(2,22,0) ns_spec = case th_ns_spec of TH.NoNamespaceSpecifier -> Hs.NoNamespaceSpecifier TH.TypeNamespaceSpecifier -> Hs.TypeNamespaceSpecifier noAnn TH.DataNamespaceSpecifier -> Hs.DataNamespaceSpecifier noAnn +#endif cvtDec (TH.DefaultD tys) = do { tys' <- traverse cvtType tys @@ -469,7 +486,7 @@ cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding -- Convert a @data@ declaration. -cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtDataDec = cvtGenDataDec False @@ -477,14 +494,14 @@ cvtDataDec = cvtGenDataDec False -- Convert a @type data@ declaration. -- These have neither contexts nor derived clauses. -- See Note [Type data declarations] in GHC.Rename.Module. -cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr TH.BndrVis] -> Maybe TH.Kind -> [TH.Con] +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> CvtM (Maybe (LHsDecl GhcPs)) cvtTypeDataDec tc tvs ksig constrs = cvtGenDataDec True [] tc tvs ksig constrs [] -- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). -- See Note [Type data declarations] in GHC.Rename.Module. -cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] -> CvtM (Maybe (LHsDecl GhcPs)) cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs @@ -538,6 +555,20 @@ cvtDataDefnCons type_data ksig constrs c:_ -> c ; mapM (cvtConstr first_datacon_name con_name) constrs } +#if !MIN_VERSION_template_haskell(2,21,0) +get_cons_names :: TH.Con -> [TH.Name] +get_cons_names (TH.NormalC n _) = [n] +get_cons_names (TH.RecC n _) = [n] +get_cons_names (TH.InfixC _ n _) = [n] +get_cons_names (TH.ForallC _ _ con) = get_cons_names con +-- GadtC can have multiple names, e.g +-- > data Bar a where +-- > MkBar1, MkBar2 :: a -> Bar a +-- Will have one GadtC with [MkBar1, MkBar2] as names +get_cons_names (TH.GadtC ns _ _) = ns +get_cons_names (TH.RecGadtC ns _ _) = ns +#endif + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -590,7 +621,7 @@ cvt_ci_decs declDescr decs ; return (listToBag binds', sigs', fams', ats', adts') } ---------------- -cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr TH.BndrVis] +cvt_tycl_hdr :: TH.Cxt -> TH.Name -> [TH.TyVarBndr BndrVis] -> CvtM ( LHsContext GhcPs , LocatedN RdrName , LHsQTyVars GhcPs) @@ -954,12 +985,14 @@ cvtPragmaD (CompleteP cls mty) ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } +#if MIN_VERSION_template_haskell(2,22,0) cvtPragmaD (SCCP nm str) = do nm' <- vcNameN nm str' <- traverse (\s -> returnLA $ StringLiteral NoSourceText (mkFastString s) Nothing) str returnJustLA $ Hs.SigD noExtField $ SCCFunSig (noAnn, SourceText $ fsLit "{-# SCC") nm' str' +#endif dfltActivation :: TH.Inline -> Activation dfltActivation TH.NoInline = NeverActive @@ -1165,12 +1198,17 @@ cvtl e = wrapLA (cvt e) (L noSrcSpanA (DotFieldOcc noAnn (L noSrcSpanA (FieldLabelString (fsLit f))))) } cvt (ProjectionE xs) = return $ HsProjection noAnn $ fmap (L noSrcSpanA . DotFieldOcc noAnn . L noSrcSpanA . FieldLabelString . fsLit) xs + +#if MIN_VERSION_template_haskell(2,21,0) cvt (TypedSpliceE e) = do { e' <- parenthesizeHsExpr appPrec <$> cvtl e ; return $ HsTypedSplice [] e' } cvt (TypedBracketE e) = do { e' <- cvtl e ; return $ HsTypedBracket noAnn e' } +#endif +#if MIN_VERSION_template_haskell(2,22,0) cvt (TypeE t) = do { t' <- cvtType t ; return $ HsEmbTy noAnn (mkHsWildCardBndrs t') } +#endif {- | #16895 Ensure an infix expression's operator is a variable/constructor. Consider this example: @@ -1416,6 +1454,7 @@ cvtLit _ = panic "Convert.cvtLit: Unexpected literal" quotedSourceText :: String -> SourceText quotedSourceText s = SourceText $ fsLit $ "\"" ++ s ++ "\"" +#if MIN_VERSION_template_haskell(2,22,0) cvtArgPats :: [TH.ArgPat] -> CvtM [Hs.LArgPat GhcPs] cvtArgPats pats = mapM cvtArgPat pats @@ -1427,6 +1466,18 @@ cvtap (VisAP pat) = do { pat' <- cvtPat pat ; pure (VisPat noExtField pat')} cvtap (InvisAP t) = do { t' <- cvtType t ; pure (InvisPat noAnn (mkHsTyPat noAnn t'))} +#else +cvtArgPats :: [TH.Pat] -> CvtM [Hs.LArgPat GhcPs] +cvtArgPats pats = mapM cvtArgPat pats + +cvtArgPat :: TH.Pat -> CvtM (Hs.LArgPat GhcPs) +cvtArgPat pat = wrapLA (cvtap pat) + +cvtap :: TH.Pat -> CvtM (Hs.ArgPat GhcPs) +cvtap pat = do { pat' <- cvtPat pat + ; pure (VisPat noExtField pat')} +#endif + cvtPats :: [TH.Pat] -> CvtM [Hs.LPat GhcPs] cvtPats pats = mapM cvtPat pats @@ -1498,8 +1549,10 @@ cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} +#if MIN_VERSION_template_haskell(2,22,0) cvtp (TypeP t) = do { t' <- cvtType t ; return $ EmbTyPat noAnn (mkHsTyPat noAnn t') } +#endif cvtPatFld :: (TH.Name, TH.Pat) -> CvtM (LHsRecField GhcPs (LPat GhcPs)) cvtPatFld (s,p) @@ -1533,7 +1586,7 @@ cvtOpAppP x op y ----------------------------------------------------------- -- Types and type variables -class CvtFlag flag flag' | flag -> flag' where +class CvtFlag flag flag' where cvtFlag :: flag -> flag' instance CvtFlag () () where @@ -1543,9 +1596,14 @@ instance CvtFlag TH.Specificity Hs.Specificity where cvtFlag TH.SpecifiedSpec = Hs.SpecifiedSpec cvtFlag TH.InferredSpec = Hs.InferredSpec +#if MIN_VERSION_template_haskell(2,21,0) instance CvtFlag TH.BndrVis (HsBndrVis GhcPs) where cvtFlag TH.BndrReq = HsBndrRequired noExtField cvtFlag TH.BndrInvis = HsBndrInvisible noAnn +#else +instance CvtFlag () (HsBndrVis GhcPs) where + cvtFlag () = HsBndrRequired noExtField +#endif cvtTvs :: CvtFlag flag flag' => [TH.TyVarBndr flag] -> CvtM [LHsTyVarBndr flag' GhcPs] cvtTvs tvs = mapM cvt_tv tvs @@ -2212,7 +2270,9 @@ mk_ghc_ns :: TH.NameSpace -> OccName.NameSpace mk_ghc_ns TH.DataName = OccName.dataName mk_ghc_ns TH.TcClsName = OccName.tcClsName mk_ghc_ns TH.VarName = OccName.varName +#if MIN_VERSION_template_haskell(2,22,0) mk_ghc_ns (TH.FldName con) = OccName.fieldName (fsLit con) +#endif mk_mod :: TH.ModName -> ModuleName mk_mod mod = mkModuleName (TH.modString mod) ===================================== compiler/ghc.cabal.in ===================================== @@ -115,7 +115,7 @@ Library containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -35,7 +35,10 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = do + dep (p1, m1) (p2, m2) s = + -- We use the boot compiler's `template-haskell` library when building stage0, + -- so we don't need to register dependencies. + if isStage0 s then pure [] else 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) ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -158,7 +158,6 @@ toolTargets = [ binary -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot - , ghcBootTh , ghcPlatform , ghcToolchain , ghcToolchainBin @@ -172,7 +171,6 @@ toolTargets = [ binary , mtl , parsec , time - , templateHaskell , text , transformers , semaphoreCompat ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -93,7 +93,6 @@ stage0Packages = do , ghc , runGhc , ghcBoot - , ghcBootTh , ghcPlatform , ghcHeap , ghcToolchain @@ -108,7 +107,6 @@ stage0Packages = do , parsec , semaphoreCompat , time - , templateHaskell , text , transformers , unlit @@ -143,6 +141,7 @@ stage1Packages = do , deepseq , exceptions , ghc + , ghcBootTh , ghcBignum , ghcCompact , ghcExperimental @@ -156,6 +155,7 @@ stage1Packages = do , pretty , rts , semaphoreCompat + , templateHaskell , stm , unlit , xhtml ===================================== libraries/ghc-boot/GHC/LanguageExtensions.hs ===================================== @@ -1,3 +1,6 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE PackageImports #-} +{-# LANGUAGE StandaloneDeriving #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | This module re-exports the 'Extension' type along with an orphan 'Binary' @@ -9,9 +12,39 @@ -- which has no dependencies outside of @base at . For this reason -- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot at . -- -module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where +-- When building the stage1 GHC, we have a potentially old version of +-- @ghc-boot-th@, which comes with an old list of extensions. +-- In that case, we define the current list of extensions here, and export that. +module GHC.LanguageExtensions + ( Extension(..) + , migrateExt + , unmigrateExt + ) + where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary -import GHC.LanguageExtensions.Type +import qualified "ghc-boot-th" GHC.LanguageExtensions.Type as TH +#if MIN_VERSION_ghc_boot_th(9,11,0) +import "ghc-boot-th" GHC.LanguageExtensions.Type (Extension(..)) +#else +import Text.Read (readMaybe) +import Data.Maybe (fromMaybe) +import GHC.LanguageExtensions.Type (Extension(..)) +#endif instance Binary Extension +deriving instance Read Extension + +migrateExt :: TH.Extension -> Extension +unmigrateExt :: Extension -> TH.Extension +#if MIN_VERSION_ghc_boot_th(9,11,0) +migrateExt = id +unmigrateExt = id +#else +errStr :: String +errStr = "unsupported language extension encountered in TH while bootstrapping" +deriving instance Read TH.Extension +migrateExt = fromMaybe (error errStr) . readMaybe . show +unmigrateExt = fromMaybe (error errStr) . readMaybe. show +#endif ===================================== libraries/ghc-boot/GHC/LanguageExtensions/Type.hs ===================================== @@ -0,0 +1,2 @@ +{-# LANGUAGE CPP #-} +#include "../../../../libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs" ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -56,12 +56,14 @@ Library GHC.UniqueSubdir GHC.Version + other-modules: + GHC.LanguageExtensions.Type + -- reexport modules from ghc-boot-th so that packages don't have to import -- both ghc-boot and ghc-boot-th. It makes the dependency graph easier to -- understand and to refactor. reexported-modules: - GHC.LanguageExtensions.Type - , GHC.ForeignSrcLang.Type + GHC.ForeignSrcLang.Type , GHC.Lexeme -- reexport platform modules from ghc-platform @@ -81,7 +83,7 @@ Library filepath >= 1.3 && < 1.6, deepseq >= 1.4 && < 1.6, ghc-platform >= 0.1, - ghc-boot-th == @ProjectVersionMunged@ + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@ if !os(windows) build-depends: unix >= 2.7 && < 2.9 ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -32,7 +32,9 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHCi.ResolvedBCO -import GHC.LanguageExtensions +-- Import the ghc-boot-th version of the extension list because when building +-- stage1, we want to use the list bundled with `template-haskell`. +import GHC.LanguageExtensions.Type import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint @@ -58,6 +60,9 @@ import System.Exit import System.IO import System.IO.Error +-- orphan instance +instance Binary Extension + -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server ===================================== libraries/ghci/GHCi/TH/Binary.hs ===================================== @@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE CPP #-} -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where @@ -27,17 +28,23 @@ instance Binary TH.Info instance Binary TH.Type instance Binary TH.TyLit instance Binary TH.Specificity +#if MIN_VERSION_template_haskell(2,21,0) instance Binary TH.BndrVis +#endif instance Binary flag => Binary (TH.TyVarBndr flag) instance Binary TH.Role instance Binary TH.Lit instance Binary TH.Range instance Binary TH.Stmt instance Binary TH.Pat +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.ArgPat +#endif instance Binary TH.Exp instance Binary TH.Dec +#if MIN_VERSION_template_haskell(2,22,0) instance Binary TH.NamespaceSpecifier +#endif instance Binary TH.Overlap instance Binary TH.DerivClause instance Binary TH.DerivStrategy ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -83,8 +83,9 @@ library deepseq >= 1.4 && < 1.6, filepath >= 1.4 && < 1.6, ghc-boot == @ProjectVersionMunged@, + ghc-boot-th >= 9.6 && <= @ProjectVersionMunged@, ghc-heap == @ProjectVersionMunged@, - template-haskell == 2.22.*, + template-haskell >= 2.20 && < 2.23, transformers >= 0.5 && < 0.7 if !os(windows) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9290c3e65208709854b1419e649228d37816194 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9290c3e65208709854b1419e649228d37816194 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 10:39:17 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 27 Mar 2024 06:39:17 -0400 Subject: [Git][ghc/ghc][wip/T24251a] 8 commits: rts: fix clang compilation on aarch64 Message-ID: <6603f7557cab9_3d40563879044560bb@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24251a at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - c5424f66 by Simon Peyton Jones at 2024-03-27T10:38:51+00:00 Eliminate redundant cases in CSE Addresses programs like this f xs = xs `seq` (let t = reverse $ reverse $ reverse $ reverse $ reverse $ reverse xs in case xs of [] -> (t,True) (_:_) -> (t,False)) Also including the case where t is a join point. Relates to #24251. Test in T24251a. (And see Simon's GHC Log 13 March.) Also added a perf test for #21741 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Types/Id.hs - distrib/configure.ac.in - hadrian/bindist/Makefile - libffi-tarballs - m4/fp_cc_linker_flag_try.m4 - rts/ARMOutlineAtomicsSymbols.h - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - + testsuite/tests/perf/should_run/T21741.hs - + testsuite/tests/perf/should_run/T21741.stdout - testsuite/tests/perf/should_run/all.T - + testsuite/tests/simplCore/should_compile/T24251a.hs - + testsuite/tests/simplCore/should_compile/T24251a.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -14,13 +14,15 @@ import GHC.Types.Var.Env ( mkInScopeSet ) import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding , idInlineActivation, setInlineActivation , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) -import GHC.Core.Utils ( mkAltExpr - , exprIsTickedString + , isJoinId, idJoinPointHood, idUnfolding + , zapIdUnfolding, isDeadBinder ) +import GHC.Core.Utils ( mkAltExpr, exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) import GHC.Core.FVs ( exprFreeVars ) import GHC.Core.Type ( tyConAppArgs ) import GHC.Core +import GHC.Core.Utils ( exprIsTrivial ) +import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Utils.Outputable import GHC.Types.Basic import GHC.Types.Tickish @@ -714,25 +716,33 @@ cseExpr env (Case e bndr ty alts) = cseCase env e bndr ty alts cseCase :: CSEnv -> InExpr -> InId -> InType -> [InAlt] -> OutExpr cseCase env scrut bndr ty alts - = Case scrut1 bndr3 ty' $ - combineAlts (map cse_alt alts) + | Just body <- caseElim scrut bndr alts + , -- See Note [Eliminating redundant cases] + let zapped_bndr = zapIdUnfolding bndr -- Wrinkle (ERC1) + = cseExpr env (Let (NonRec zapped_bndr scrut) body) + + | otherwise + = Case scrut' bndr' ty' alts' + where ty' = substTyUnchecked (csEnvSubst env) ty - (cse_done, scrut1) = try_for_cse env scrut + (cse_done, scrut') = try_for_cse env scrut bndr1 = zapIdOccInfo bndr -- Zapping the OccInfo is needed because the extendCSEnv -- in cse_alt may mean that a dead case binder -- becomes alive, and Lint rejects that (env1, bndr2) = addBinder env bndr1 - (alt_env, bndr3) = extendCSEnvWithBinding env1 bndr bndr2 scrut1 cse_done + (alt_env, bndr') = extendCSEnvWithBinding env1 bndr bndr2 scrut' cse_done -- extendCSEnvWithBinding: see Note [CSE for case expressions] + alts' = combineAlts (map cse_alt alts) + con_target :: OutExpr con_target = lookupSubst alt_env bndr arg_tys :: [OutType] - arg_tys = tyConAppArgs (idType bndr3) + arg_tys = tyConAppArgs (idType bndr') -- See Note [CSE for case alternatives] cse_alt (Alt (DataAlt con) args rhs) @@ -747,6 +757,45 @@ cseCase env scrut bndr ty alts where (env', args') = addBinders alt_env args +caseElim :: InExpr -> InId -> [InAlt] -> Maybe InExpr +-- Can we eliminate the case altogether? If so return the body. +-- Note [Eliminating redundant cases] +caseElim scrut case_bndr alts + | [Alt _ bndrs rhs] <- alts + , Just (scrut_var, _) <- scrutBinderSwap_maybe scrut + , all isDeadBinder bndrs + , isEvaldSoon (scrut_var, case_bndr) rhs + = Just rhs + + | otherwise + = Nothing + +isEvaldSoon :: (OutId, OutId) -> OutExpr -> Bool +-- (isEvaldSoon (v1,v2) e) is True if either v1 or v2 is evaluated "soon" by e +isEvaldSoon (v1,v2) expr + = go expr + where + hit :: Var -> Bool + hit v = v==v1 || v==v2 + + go (Var v) = hit v + go (Let _ e) = go e + go (Tick _ e) = go e + go (Cast e _) = go e + + go (Case scrut cb _ alts) + = go scrut || + (exprIsTrivial scrut && + all go_alt alts && + not (hit cb) && -- Check for + all ok_alt alts) -- shadowing + -- ok_alt only runs if things look good + + go _ = False -- Lit, App, Lam, Coercion, Type + + go_alt (Alt _ _ rhs) = go rhs + ok_alt (Alt _ cbs _) = not (any hit cbs) + combineAlts :: [OutAlt] -> [OutAlt] -- See Note [Combine case alternatives] combineAlts alts @@ -798,6 +847,64 @@ turning K2 into 'x' increases the number of live variables. But * The next run of the simplifier will turn 'x' back into K2, so we won't permanently bloat the free-var count. +Note [Eliminating redundant cases] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + case x of x' { DEFAULT -> + case y of y' { DEFAULT -> + let v = in + case x' of { True -> e1; False -> e2 } + body }}} + +The initial `seq` of `x` is redundant. But the Simplifier is generally +careful not to drop that outer `case x` based on its demand-info: see Note +[Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration. + +Instead we peek at the body of the case, using `isEvaldSoon`, to see if `x` is +evaluated "soon" in the code path that follows. If so we transform the +`case` to a `let` + let x' = x in + case y of y' ... etc... + +The notion of "soon" is a bit squishy, and is implemented by `isEvaldSoon`. +We allow interchanging eval's (as in the `case x` vs `case y` above. But +what about + case x of x' { DEFAULT -> + case (f y) of y' { DEFAULT -> + case x' of { True -> e1; False -> e2 } +If we drop the `seq` on `x` we fall vicitm of #21741. There is nothing +wrong /semantically/ with dropping the `seq`, but the case of #21741 it causes +a big space leak. + +So the conditions in `isEvaldSoon` are quite narrow: the two evals are +separated only by lets and other evals on /variables/. + +Wrinkle (ERC1): + x' will have an (OtherCon []) unfolding on it. We want to zap that + unfolding before turning it into (let x' = x in ...). + +Wrinkle (ERC2): + You might wonder if case-merging in the Simplifer doesn't cover this. + See GHC.Core.Opt.Simplify.Utils.tryCaseMerge. and Note [Merge Nested Cases] + in that same module. But no, it is defeated by the 'let v = ` in our + example above, and I didn't want to make it more complicated. + + Mabye case-merging should be made simpler, or even moved outright here into CSE. + +Wrinkle (ERC3): + Why is this done in CSE? Becuase the "peeking" is tiresome and potentially a bit + expensive (quadratic in deep nests) so we don't want too often. CSE runs seldom, + it is a pretty simple pass, and it's easy to "drop in" this extra optimisation. + Also eliminating redundant cases is a bit like commoning up duplicated work. + +Wrinkle (ERC4): + You might wonder whether we want to do this "optimisation" /at all/. After all, as + Note [Case-to-let for strictly-used binders] point out, dropping the eval is + not a huge deal, because the inner eval should just be a multi-way jump (no + actual eval). But droppping the eval removes clutter, and I found that not dropping + made some functions look a bit bigger, and hence they didn't get inlined. + + This is small beer though: I don't think it's an /important/ transformation. Note [Combine case alternatives] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -17,7 +17,7 @@ module GHC.Core.Opt.Simplify.Env ( seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, - mkSimplEnv, extendIdSubst, + mkSimplEnv, extendIdSubst, extendCvIdSubst, extendTvSubst, extendCvSubst, zapSubstEnv, setSubstEnv, bumpCaseDepth, getInScope, setInScopeFromE, setInScopeFromF, @@ -550,6 +550,10 @@ extendCvSubst env@(SimplEnv {seCvSubst = csubst}) var co = assert (isCoVar var) $ env {seCvSubst = extendVarEnv csubst var co} +extendCvIdSubst :: SimplEnv -> Id -> OutExpr -> SimplEnv +extendCvIdSubst env bndr (Coercion co) = extendCvSubst env bndr co +extendCvIdSubst env bndr rhs = extendIdSubst env bndr (DoneEx rhs NotJoinPoint) + --------------------- getInScope :: SimplEnv -> InScopeSet getInScope env = seInScope env ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -412,9 +412,7 @@ simplAuxBind env bndr new_rhs -- have no NOLINE pragmas, nor RULEs | exprIsTrivial new_rhs -- Short-cut for let x = y in ... = return ( emptyFloats env - , case new_rhs of - Coercion co -> extendCvSubst env bndr co - _ -> extendIdSubst env bndr (DoneEx new_rhs NotJoinPoint) ) + , extendCvIdSubst env bndr new_rhs ) -- bndr can be a CoVar | otherwise = do { -- ANF-ise the RHS ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2394,6 +2394,9 @@ the outer case scrutinises the same variable as the outer case. This transformation is called Case Merging. It avoids that the same variable is scrutinised multiple times. +See also Note [Eliminating redundant cases] in GHC.Core.Opt.CSE, especially +wrinkle (ERC2). + Wrinkles (MC1) `tryCaseMerge` "looks though" an inner single-alternative case-on-variable. ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -736,12 +736,12 @@ mkBigLHsPatTup = mkChunkified mkLHsPatTup -- | Convert an 'LHsType' to an 'LHsSigType'. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -hsTypeToHsSigType lty@(L loc ty) = L loc $ case ty of +hsTypeToHsSigType lty@(L loc ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an , hsf_invis_bndrs = bndrs } , hst_body = body } - -> mkHsExplicitSigType an bndrs body - _ -> mkHsImplicitSigType lty + -> L loc $ mkHsExplicitSigType an bndrs body + _ -> L (l2l loc) $ mkHsImplicitSigType lty -- The annotations are in lty, erase them from loc -- | Convert an 'LHsType' to an 'LHsSigWcType'. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2870,7 +2870,7 @@ alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' unsafeChr :: Int -> Char -unsafeChr (I# c) = C# (chr# c) +unsafeChr (I# c) = GHC.Exts.C# (GHC.Exts.chr# c) -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -625,7 +625,7 @@ isImplicitId id idIsFrom :: Module -> Id -> Bool idIsFrom mod id = nameIsLocalOrFrom mod (idName id) -isDeadBinder :: Id -> Bool +isDeadBinder :: Var -> Bool isDeadBinder bndr | isId bndr = isDeadOcc (idOccInfo bndr) | otherwise = False -- TyVars count as not dead ===================================== distrib/configure.ac.in ===================================== @@ -105,6 +105,29 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) fi + +if test "$HostOS" = "darwin"; then + # On darwin, we need to clean the extended attributes of the + # ghc-toolchain binary and its dynamic library before we can execute it in the bindist + # (this is a workaround for #24554, for the lack of proper notarisation #17418) + + # The following is the work around suggested by @carter in #17418 during + # install time. This should help us with code signing issues by removing + # extended attributes from all files. + XATTR=${XATTR:-/usr/bin/xattr} + + if [ -e "${XATTR}" ]; then + + # Instead of cleaning the attributes of the ghc-toolchain binary only, + # we clean them from all files in the bin/ and lib/ directories, as it additionally future + # proofs running executables from the bindist besides ghc-toolchain at configure time, and + # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. + /usr/bin/xattr -rc bin/ + /usr/bin/xattr -rc lib/ + + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) ===================================== hadrian/bindist/Makefile ===================================== @@ -19,13 +19,6 @@ default: # TODO : find if a better function exists eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# the following is the work around suggested by @carter in #17418 during install -# time. This should help us with code signing issues by removing extended -# attributes from all files. -ifeq "$(Darwin_Host)" "YES" -XATTR ?= /usr/bin/xattr -endif - # patchpackageconf # # Hacky function to patch up the 'haddock-interfaces' and 'haddock-html' @@ -157,10 +150,6 @@ install_bin_libdir: $(INSTALL_PROGRAM) "$$i" "$(DESTDIR)$(ActualBinsDir)"; \ fi; \ done - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualBinsDir)"; \ - fi .PHONY: install_bin_direct install_bin_direct: @@ -195,10 +184,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ - fi .PHONY: install_docs install_docs: ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/perf/should_run/T21741.hs ===================================== @@ -0,0 +1,25 @@ +{-# LANGUAGE BangPatterns #-} +module Main where + +import System.Environment + +f :: [Int] -> Int +f xs = g (length xs) (even $ mySum xs) +{-# NOINLINE f #-} + +g :: Int -> Bool -> Int +g 0 _ = 0 +g n !b = length xs + mySum xs + if b then 0 else 1 + where + xs = [0..n] +{-# NOINLINE g #-} + +mySum :: [Int] -> Int +mySum = go 0 + where + go acc (x:xs) = go (x+acc) xs + go acc _ = acc + +main = do + (n:_) <- map read <$> getArgs + print $ f [0..n] ===================================== testsuite/tests/perf/should_run/T21741.stdout ===================================== @@ -0,0 +1 @@ +50000025000003 ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -413,3 +413,9 @@ test('T21839r', # perf doesn't regress further, so it is not marked as such. test('T18964', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O']) test('T23021', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O2']) + +# GC bytes copied goes up a lot if the space leak returns +test('T21741', [collect_stats('copied_bytes', 2), + extra_run_opts('10000000'), + only_ways(['normal'])], + compile_and_run, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T24251a.hs ===================================== @@ -0,0 +1,9 @@ +module T24251a where + +f xs = xs `seq` + (let t = reverse (reverse (reverse (reverse xs))) in + case xs of + [] -> (t,True) + (_:_) -> (t,False)) + +-- We start with an eval of xs, but that should disappear. ===================================== testsuite/tests/simplCore/should_compile/T24251a.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 33, types: 60, coercions: 0, joins: 0/1} + +$wf + = \ @a xs -> + let { + t = reverse1 (reverse1 (reverse1 (reverse1 xs []) []) []) [] } in + case xs of { + [] -> (# t, True #); + : ds ds1 -> (# t, False #) + } + +f = \ @a xs -> case $wf xs of { (# ww, ww1 #) -> (ww, ww1) } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24251a', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-all']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b2a487e4f6c46069441eed762deae4732203e335...c5424f6671c3780ade753fd2b09a232f2eca1be3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b2a487e4f6c46069441eed762deae4732203e335...c5424f6671c3780ade753fd2b09a232f2eca1be3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 11:29:19 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 27 Mar 2024 07:29:19 -0400 Subject: [Git][ghc/ghc][master] JS: `h$rts_isProfiled` is removed from `profiling` and left its version at Message-ID: <6604030fa42e_3d405651dfe4863637@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 1 changed file: - rts/js/profiling.js Changes: ===================================== rts/js/profiling.js ===================================== @@ -331,7 +331,3 @@ function h$buildCCSPtr(o) { function h$clearCCS(a) { throw new Error("ClearCCSOp not implemented"); } - -function h$rts_isProfiled() { - return 0; -} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13223f6d6c7ef7591e53d033296c6ceb760ead63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13223f6d6c7ef7591e53d033296c6ceb760ead63 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 11:29:53 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 27 Mar 2024 07:29:53 -0400 Subject: [Git][ghc/ghc][master] EPA: Do not extend declaration range for trailine zero len semi Message-ID: <66040331cf7bc_3d405653a482866932@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - 4 changed files: - compiler/GHC/Parser.y - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PprLetIn.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1438,10 +1438,10 @@ ty_fam_inst_eqns :: { Located [LTyFamInstEqn GhcPs] } h' <- addTrailingSemiA h (gl $2) return (sLL $1 $> ($3 : h' : t)) } | ty_fam_inst_eqns ';' {% case unLoc $1 of - [] -> return (sLL $1 $> (unLoc $1)) + [] -> return (sLZ $1 $> (unLoc $1)) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | ty_fam_inst_eqn { sLL $1 $> [$1] } | {- empty -} { noLoc [] } @@ -1719,12 +1719,12 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_cls { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1765,12 +1765,12 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_inst { sL1 $1 ([],unLoc $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1806,12 +1806,12 @@ decls :: { Located ([AddEpAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLL $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemiA $2) + then return (sLZ $1 $> (((fst $ unLoc $1) ++ (msemiA $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -3334,11 +3334,11 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs return (sLL $1 $> (fst $ unLoc $1,$3 : h' : t)) } | alts1(PATS) ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (fst $ unLoc $1, h' : t)) } + return (sLZ $1 $> (fst $ unLoc $1, h' : t)) } | alt(PATS) { $1 >>= \ $1 -> return $ sL1 $1 ([],[$1]) } alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) } @@ -3442,7 +3442,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} @@ -3552,7 +3552,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed | dbinds ';' {% case unLoc $1 of (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | dbind { let this = $1 in this `seq` (sL1 $1 [this]) } -- | {- empty -} { [] } @@ -4195,6 +4195,12 @@ sLLAsl :: (HasLoc a) => [a] -> Located b -> c -> Located c sLLAsl [] = sL1 sLLAsl (!x:_) = sLL x +{-# INLINE sLZ #-} +sLZ :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c +sLZ !x !y = if isZeroWidthSpan (getHasLoc y) + then sL (getHasLoc x) + else sL (comb2 x y) + {- Note [Adding location info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/printer/Makefile ===================================== @@ -821,3 +821,8 @@ AnnotationNoListTuplePuns: Test24533: $(CHECK_PPR) $(LIBDIR) Test24533.hs $(CHECK_EXACT) $(LIBDIR) Test24533.hs + +.PHONY: PprLetIn +PprLetIn: + $(CHECK_PPR) $(LIBDIR) PprLetIn.hs + $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs ===================================== testsuite/tests/printer/PprLetIn.hs ===================================== @@ -0,0 +1,5 @@ +module PprLetIn where + +ff = let + x = 1 + in 4 ===================================== testsuite/tests/printer/all.T ===================================== @@ -197,3 +197,4 @@ test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) +test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0acfe391583d77a72051d505f05fab0ada056c49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0acfe391583d77a72051d505f05fab0ada056c49 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 12:34:25 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 27 Mar 2024 08:34:25 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.10 Message-ID: <66041251dca7e_3d4056764c1a0809f7@gitlab.mail> Ben Gamari pushed new branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 12:40:47 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 27 Mar 2024 08:40:47 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 4 commits: EPA: Do not extend declaration range for trailine zero len semi Message-ID: <660413cf6965b_3d4056783c62c98162@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 5dd67b52 by Alan Zimmerman at 2024-03-27T08:37:54-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. (cherry picked from commit 0acfe391583d77a72051d505f05fab0ada056c49) - - - - - 10829530 by Rodrigo Mesquita at 2024-03-27T08:38:20-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. (cherry picked from commit 32a8103f3b3e22907fdd67b69c919c5251d8cc20) - - - - - 3914808d by Cheng Shao at 2024-03-27T08:38:35-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. (cherry picked from commit 810660b780e1111b36c91326bcd0041e1f62706b) - - - - - 6ecd5f2f by Cheng Shao at 2024-03-27T08:38:49-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. (cherry picked from commit 7db8c9927fae3369fc4ecff68f80c4cb32eea757) - - - - - 7 changed files: - compiler/GHC/Parser.y - libffi-tarballs - m4/fp_cc_linker_flag_try.m4 - rts/ARMOutlineAtomicsSymbols.h - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PprLetIn.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1438,10 +1438,10 @@ ty_fam_inst_eqns :: { Located [LTyFamInstEqn GhcPs] } h' <- addTrailingSemiA h (gl $2) return (sLL $1 $> ($3 : h' : t)) } | ty_fam_inst_eqns ';' {% case unLoc $1 of - [] -> return (sLL $1 $> (unLoc $1)) + [] -> return (sLZ $1 $> (unLoc $1)) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | ty_fam_inst_eqn { sLL $1 $> [$1] } | {- empty -} { noLoc [] } @@ -1719,12 +1719,12 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_cls { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1765,12 +1765,12 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_inst { sL1 $1 ([],unLoc $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1806,12 +1806,12 @@ decls :: { Located ([AddEpAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLL $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemiA $2) + then return (sLZ $1 $> (((fst $ unLoc $1) ++ (msemiA $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -3334,11 +3334,11 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs return (sLL $1 $> (fst $ unLoc $1,$3 : h' : t)) } | alts1(PATS) ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (fst $ unLoc $1, h' : t)) } + return (sLZ $1 $> (fst $ unLoc $1, h' : t)) } | alt(PATS) { $1 >>= \ $1 -> return $ sL1 $1 ([],[$1]) } alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) } @@ -3442,7 +3442,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} @@ -3552,7 +3552,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed | dbinds ';' {% case unLoc $1 of (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | dbind { let this = $1 in this `seq` (sL1 $1 [this]) } -- | {- empty -} { [] } @@ -4195,6 +4195,12 @@ sLLAsl :: (HasLoc a) => [a] -> Located b -> c -> Located c sLLAsl [] = sL1 sLLAsl (!x:_) = sLL x +{-# INLINE sLZ #-} +sLZ :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c +sLZ !x !y = if isZeroWidthSpan (getHasLoc y) + then sL (getHasLoc x) + else sL (comb2 x y) + {- Note [Adding location info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } ===================================== testsuite/tests/printer/Makefile ===================================== @@ -821,3 +821,8 @@ AnnotationNoListTuplePuns: Test24533: $(CHECK_PPR) $(LIBDIR) Test24533.hs $(CHECK_EXACT) $(LIBDIR) Test24533.hs + +.PHONY: PprLetIn +PprLetIn: + $(CHECK_PPR) $(LIBDIR) PprLetIn.hs + $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs ===================================== testsuite/tests/printer/PprLetIn.hs ===================================== @@ -0,0 +1,5 @@ +module PprLetIn where + +ff = let + x = 1 + in 4 ===================================== testsuite/tests/printer/all.T ===================================== @@ -197,3 +197,4 @@ test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) +test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/725343aa1f261f615dc3119d0b139e45df04198a...6ecd5f2ff97af53c7334f2d8581651203a2c6b7d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/725343aa1f261f615dc3119d0b139e45df04198a...6ecd5f2ff97af53c7334f2d8581651203a2c6b7d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 12:44:08 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 27 Mar 2024 08:44:08 -0400 Subject: [Git][ghc/ghc][wip/T24598] compiler: Allow more types in GHCForeignImportPrim Message-ID: <66041498df08f_3d405679ccf789833@gitlab.mail> Ben Gamari pushed to branch wip/T24598 at Glasgow Haskell Compiler / GHC Commits: ab1b6941 by Ben Gamari at 2024-03-27T08:43:20-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 12 changed files: - compiler/GHC/Tc/Gen/Foreign.hs - testsuite/tests/ffi/should_fail/ccfail001.stderr - + testsuite/tests/ffi/should_run/T24598.hs - + testsuite/tests/ffi/should_run/T24598.stdout - + testsuite/tests/ffi/should_run/T24598_cmm.cmm - + testsuite/tests/ffi/should_run/T24598b.hs - + testsuite/tests/ffi/should_run/T24598b.stdout - + testsuite/tests/ffi/should_run/T24598b_cmm.cmm - + testsuite/tests/ffi/should_run/T24598c.hs - + testsuite/tests/ffi/should_run/T24598c.stdout - + testsuite/tests/ffi/should_run/T24598c_cmm.cmm - testsuite/tests/ffi/should_run/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -84,7 +84,6 @@ import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class ( lift ) import Data.Maybe (isJust) -import GHC.Types.RepType (tyConPrimRep) import GHC.Builtin.Types (unitTyCon) -- Defines a binding @@ -737,7 +736,6 @@ marshalablePrimTyCon tc = isPrimTyCon tc && not (isLiftedTypeKind (tyConResKind marshalableTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledReason marshalableTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | otherwise = boxedMarshalableTyCon tc @@ -772,7 +770,6 @@ legalFIPrimResultTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledRe -- types and also unboxed tuple and sum result types. legalFIPrimResultTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | isUnboxedTupleTyCon tc || isUnboxedSumTyCon tc @@ -786,13 +783,3 @@ validIfUnliftedFFITypes dflags | xopt LangExt.UnliftedFFITypes dflags = IsValid | otherwise = NotValid UnliftedFFITypesNeeded -{- -Note [Marshalling void] -~~~~~~~~~~~~~~~~~~~~~~~ -We don't treat State# (whose PrimRep is VoidRep) as marshalable. -In turn that means you can't write - foreign import foo :: Int -> State# RealWorld - -Reason: the back end falls over with panic "primRepHint:VoidRep"; - and there is no compelling reason to permit it --} ===================================== testsuite/tests/ffi/should_fail/ccfail001.stderr ===================================== @@ -1,6 +1,8 @@ -ccfail001.hs:10:1: error: [GHC-89401] +ccfail001.hs:10:1: error: [GHC-10964] • Unacceptable result type in foreign declaration: ‘State# RealWorld’ cannot be marshalled in a foreign call + UnliftedFFITypes is required to marshal unlifted types • When checking declaration: foreign import ccall safe foo :: Int -> State# RealWorld + Suggested fix: Perhaps you intended to use UnliftedFFITypes ===================================== testsuite/tests/ffi/should_run/T24598.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in results correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello >>= print + +hello :: IO Int +hello = IO $ \s -> case hello# s of (# s', n# #) -> (# s', I# n# #) ===================================== testsuite/tests/ffi/should_run/T24598.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello() { + return (42); +} ===================================== testsuite/tests/ffi/should_run/T24598b.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: Int# -> State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello 21 >>= print + +hello :: Int -> IO Int +hello (I# n#) = IO $ \s -> + case hello# n# s of (# s', n# #) -> (# s', I# n# #) + ===================================== testsuite/tests/ffi/should_run/T24598b.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598b_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello(W_ n) { + return (2*n); +} ===================================== testsuite/tests/ffi/should_run/T24598c.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> State# RealWorld + +main :: IO () +main = hello + +hello :: IO () +hello = IO $ \s -> + case hello# s of s' -> (# s', () #) + ===================================== testsuite/tests/ffi/should_run/T24598c.stdout ===================================== @@ -0,0 +1 @@ +hello ===================================== testsuite/tests/ffi/should_run/T24598c_cmm.cmm ===================================== @@ -0,0 +1,11 @@ +#include "Cmm.h" + +section "data" { + test_str: bits8[] "hello"; +} + +hello() { + ccall puts(test_str); + return (); +} + ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -268,3 +268,7 @@ test('T24314', # libffi-wasm doesn't support more than 4 args yet when(arch('wasm32'), skip)], compile_and_run, ['T24314_c.c']) + +test('T24598', req_cmm, compile_and_run, ['T24598_cmm.cmm']) +test('T24598b', req_cmm, compile_and_run, ['T24598b_cmm.cmm']) +test('T24598c', req_cmm, compile_and_run, ['T24598c_cmm.cmm']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab1b69413852ca59c2f5510b52056a861e617a2d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab1b69413852ca59c2f5510b52056a861e617a2d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 14:03:47 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 27 Mar 2024 10:03:47 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Never UNPACK `FastMutInt` for counting z-encoded `FastString`s Message-ID: <66042743824e7_26159322f80a8886de@gitlab.mail> Hannes Siebenhandl pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: de963147 by Fendor at 2024-03-27T15:02:52+01:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in GHC. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - 1 changed file: - compiler/GHC/Data/FastString.hs Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -308,7 +308,7 @@ See Note [Updating the FastString table] on how it's updated. -} data FastStringTable = FastStringTable {-# UNPACK #-} !FastMutInt -- the unique ID counter shared with all buckets - {-# UNPACK #-} !FastMutInt -- number of computed z-encodings for all buckets + {-# NOUNPACK #-} !FastMutInt -- number of computed z-encodings for all buckets (Array# (IORef FastStringTableSegment)) -- concurrent segments data FastStringTableSegment = FastStringTableSegment View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de963147f76ee311e0a888f212e347f7c9bf8713 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de963147f76ee311e0a888f212e347f7c9bf8713 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 15:39:05 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 27 Mar 2024 11:39:05 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] Eliminate name thunk in declaration fingerprinting Message-ID: <66043d99895bf_2615934b59e34974b9@gitlab.mail> Hannes Siebenhandl pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: 42ce32c8 by Fendor at 2024-03-27T15:55:24+01:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. - - - - - 1 changed file: - compiler/GHC/IfaceToCore.hs Changes: ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -957,7 +957,7 @@ tc_iface_decl_fingerprint :: Bool -- Don't load pragmas into tc_iface_decl_fingerprint ignore_prags (_version, decl) = do { -- Populate the name cache with final versions of all -- the names associated with the decl - let main_name = ifName decl + let !main_name = ifName decl -- Typecheck the thing, lazily -- NB. Firstly, the laziness is there in case we never need the View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/42ce32c800b6c22c150cde35e7db66da61fa0085 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/42ce32c800b6c22c150cde35e7db66da61fa0085 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 16:33:09 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 27 Mar 2024 12:33:09 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] 9 commits: Don't use unsafeInterleaveIO when reading type symbol table Message-ID: <66044a459b653_261593609a1b81038b9@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: c5678e4c by Matthew Pickering at 2024-03-27T16:32:48+00:00 Don't use unsafeInterleaveIO when reading type symbol table - - - - - 1f0e5fd5 by Matthew Pickering at 2024-03-27T16:32:48+00:00 Don't retain whole 1mb buffer from shareIface - - - - - f3930158 by Matthew Pickering at 2024-03-27T16:32:48+00:00 Strictness around deserialising FullBinData We want to make sure to leave an explicit "thunk" here, a FullBinData constructor rather than another layer of indirection via another thunk. - - - - - 191cd9e9 by Matthew Pickering at 2024-03-27T16:32:48+00:00 Force in_multi to avoid retaining entire hsc_env - - - - - 927da7f1 by Fendor at 2024-03-27T16:32:48+00:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 20ffbe88 by Matthew Pickering at 2024-03-27T16:32:48+00:00 Share IfaceTypes in CgBreakInfo via shared buffer - - - - - 12b4dbba by Matthew Pickering at 2024-03-27T16:32:48+00:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 5f89c66a by Matthew Pickering at 2024-03-27T16:32:48+00:00 Add Binary instance for Word - - - - - 6ed397bd by Matthew Pickering at 2024-03-27T16:32:48+00:00 Share common bitmaps This avoid allocating lots of duplicate ByteStrings for the bytecode bitmaps. - - - - - 13 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Data/FlatBag.hs - compiler/GHC/Data/SmallArray.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/Utils/Binary.hs - ghc/GHCi/UI.hs - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -optc-DNON_POSIX_SOURCE #-} -- -- (c) The University of Glasgow 2002-2006 @@ -226,12 +227,49 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm return ul_bco + +bitmap_0_0, bitmap_1_0, bitmap_2_0, bitmap_3_0, bitmap_4_0, bitmap_5_0, bitmap_6_0, bitmap_7_0, bitmap_8_0 :: UArray Int Word64 + +bitmap_0_0 = Array.listArray (0,0) [0] +bitmap_1_0 = Array.listArray (0,1) [ 1, 0 ] +bitmap_2_0 = Array.listArray (0,1) [ 2, 0 ] +bitmap_3_0 = Array.listArray (0,1) [ 3, 0 ] +bitmap_4_0 = Array.listArray (0,1) [ 4, 0 ] +bitmap_5_0 = Array.listArray (0,1) [ 5, 0 ] +bitmap_6_0 = Array.listArray (0,1) [ 6, 0 ] +bitmap_7_0 = Array.listArray (0,1) [ 7, 0 ] +bitmap_8_0 = Array.listArray (0,1) [ 8, 0 ] + +{-# NOINLINE bitmap_0_0 #-} +{-# NOINLINE bitmap_1_0 #-} +{-# NOINLINE bitmap_2_0 #-} +{-# NOINLINE bitmap_3_0 #-} +{-# NOINLINE bitmap_4_0 #-} +{-# NOINLINE bitmap_5_0 #-} +{-# NOINLINE bitmap_6_0 #-} +{-# NOINLINE bitmap_7_0 #-} +{-# NOINLINE bitmap_8_0 #-} + + mkBitmapArray :: Word -> [StgWord] -> UArray Int Word64 -- Here the return type must be an array of Words, not StgWords, -- because the underlying ByteArray# will end up as a component -- of a BCO object. +mkBitmapArray 0 [] = bitmap_0_0 +mkBitmapArray 1 [fromStgWord -> 0] = bitmap_1_0 +mkBitmapArray 2 [fromStgWord -> 0] = bitmap_2_0 +mkBitmapArray 3 [fromStgWord -> 0] = bitmap_3_0 +mkBitmapArray 4 [fromStgWord -> 0] = bitmap_4_0 +mkBitmapArray 5 [fromStgWord -> 0] = bitmap_5_0 +mkBitmapArray 6 [fromStgWord -> 0] = bitmap_6_0 +mkBitmapArray 7 [fromStgWord -> 0] = bitmap_7_0 +mkBitmapArray 8 [fromStgWord -> 0] = bitmap_8_0 mkBitmapArray bsize bitmap - = Array.listArray (0, length bitmap) $ + = reallyMkBitmapArray bsize bitmap + +reallyMkBitmapArray :: Word -> [StgWord] -> UArray Int Word64 +reallyMkBitmapArray bsize bitmap = + Array.listArray (0, length bitmap) $ fromIntegral bsize : map (fromInteger . fromStgWord) bitmap -- instrs nonptrs ptrs ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -52,6 +52,7 @@ import GHC.Cmm.Expr ( GlobalRegSet, emptyRegSet, regSetToList ) import GHC.Iface.Syntax import Language.Haskell.Syntax.Module.Name (ModuleName) import GHC.Base (ByteArray#) +import GHC.Utils.Binary -- ----------------------------------------------------------------------------- -- Compiled Byte Code @@ -229,6 +230,11 @@ data CgBreakInfo , cgb_vars :: ![Maybe (IfaceIdBndr, Word)] , cgb_resty :: !IfaceType } + +instance Binary CgBreakInfo where + putNoStack_ bh (CgBreakInfo tv vs rty) = + put_ bh tv >> put_ bh vs >> put_ bh rty + get bh = CgBreakInfo <$> get bh <*> get bh <*> get bh -- See Note [Syncing breakpoint info] in GHC.Runtime.Eval seqCgBreakInfo :: CgBreakInfo -> () ===================================== compiler/GHC/Data/FlatBag.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE UnboxedTuples #-} module GHC.Data.FlatBag ( FlatBag , emptyFlatBag @@ -16,7 +17,7 @@ import GHC.Data.SizedSeq (SizedSeq, ssElts, sizeSS) import Control.DeepSeq -import Data.Array +import GHC.Data.SmallArray -- | Store elements in a flattened representation. -- @@ -39,20 +40,19 @@ data FlatBag a = EmptyFlatBag | UnitFlatBag !a | TupleFlatBag !a !a - | FlatBag {-# UNPACK #-} !(Array Word a) - deriving (Show) + | FlatBag {-# UNPACK #-} !(SmallArray a) instance Functor FlatBag where fmap _ EmptyFlatBag = EmptyFlatBag fmap f (UnitFlatBag a) = UnitFlatBag $ f a fmap f (TupleFlatBag a b) = TupleFlatBag (f a) (f b) - fmap f (FlatBag e) = FlatBag $ fmap f e + fmap f (FlatBag e) = FlatBag $ mapSmallArray f e instance Foldable FlatBag where foldMap _ EmptyFlatBag = mempty foldMap f (UnitFlatBag a) = f a foldMap f (TupleFlatBag a b) = f a `mappend` f b - foldMap f (FlatBag e) = foldMap f e + foldMap f (FlatBag arr) = foldMapSmallArray f arr length = fromIntegral . sizeFlatBag @@ -60,13 +60,13 @@ instance Traversable FlatBag where traverse _ EmptyFlatBag = pure EmptyFlatBag traverse f (UnitFlatBag a) = UnitFlatBag <$> f a traverse f (TupleFlatBag a b) = TupleFlatBag <$> f a <*> f b - traverse f (FlatBag e) = FlatBag <$> traverse f e + traverse f fl@(FlatBag arr) = fromList (fromIntegral $ sizeofSmallArray arr) <$> traverse f (elemsFlatBag fl) instance NFData a => NFData (FlatBag a) where rnf EmptyFlatBag = () rnf (UnitFlatBag a) = rnf a rnf (TupleFlatBag a b) = rnf a `seq` rnf b - rnf (FlatBag e) = rnf e + rnf (FlatBag arr) = rnfSmallArray arr -- | Create an empty 'FlatBag'. -- @@ -83,14 +83,15 @@ sizeFlatBag :: FlatBag a -> Word sizeFlatBag EmptyFlatBag = 0 sizeFlatBag UnitFlatBag{} = 1 sizeFlatBag TupleFlatBag{} = 2 -sizeFlatBag (FlatBag e) = fromIntegral (length e) +sizeFlatBag (FlatBag arr) = fromIntegral $ sizeofSmallArray arr -- | Get all elements that are stored in the 'FlatBag'. elemsFlatBag :: FlatBag a -> [a] elemsFlatBag EmptyFlatBag = [] elemsFlatBag (UnitFlatBag a) = [a] elemsFlatBag (TupleFlatBag a b) = [a, b] -elemsFlatBag (FlatBag e) = elems e +elemsFlatBag (FlatBag arr) = + [indexSmallArray arr i | i <- [0 .. sizeofSmallArray arr - 1]] -- | Combine two 'FlatBag's. -- @@ -100,6 +101,7 @@ elemsFlatBag (FlatBag e) = elems e mappendFlatBag :: FlatBag a -> FlatBag a -> FlatBag a mappendFlatBag EmptyFlatBag b = b mappendFlatBag a EmptyFlatBag = a +mappendFlatBag (UnitFlatBag a) (UnitFlatBag b) = TupleFlatBag a b mappendFlatBag a b = fromList (sizeFlatBag a + sizeFlatBag b) (elemsFlatBag a ++ elemsFlatBag b) @@ -107,7 +109,7 @@ mappendFlatBag a b = -- | Store the list in a flattened memory representation, avoiding the memory overhead -- of a linked list. -- --- The size 'n' needs to be at least the length of the list. +-- The size 'n' needs to be smaller or equal to the length of the list. -- If it is smaller than the length of the list, overflowing elements are -- discarded. It is undefined behaviour to set 'n' to be bigger than the -- length of the list. @@ -117,7 +119,8 @@ fromList n elts = [] -> EmptyFlatBag [a] -> UnitFlatBag a [a, b] -> TupleFlatBag a b - xs -> FlatBag (listArray (0, n - 1) xs) + xs -> + FlatBag (listToArray (fromIntegral n) fst snd (zip [0..] xs)) -- | Convert a 'SizedSeq' into its flattened representation. -- A 'FlatBag a' is more memory efficient than '[a]', if no further modification ===================================== compiler/GHC/Data/SmallArray.hs ===================================== @@ -11,13 +11,18 @@ module GHC.Data.SmallArray , freezeSmallArray , unsafeFreezeSmallArray , indexSmallArray + , sizeofSmallArray , listToArray + , mapSmallArray + , foldMapSmallArray + , rnfSmallArray ) where import GHC.Exts import GHC.Prelude import GHC.ST +import Control.DeepSeq data SmallArray a = SmallArray (SmallArray# a) @@ -64,6 +69,14 @@ unsafeFreezeSmallArray (SmallMutableArray ma) s = case unsafeFreezeSmallArray# ma s of (# s', a #) -> (# s', SmallArray a #) +-- | Get the size of a 'SmallArray' +sizeofSmallArray + :: SmallArray a + -> Int +{-# INLINE sizeofSmallArray #-} +sizeofSmallArray (SmallArray sa#) = + case sizeofSmallArray# sa# of + s -> I# s -- | Index a small-array (no bounds checking!) indexSmallArray @@ -71,9 +84,51 @@ indexSmallArray -> Int -- ^ index -> a {-# INLINE indexSmallArray #-} -indexSmallArray (SmallArray sa#) (I# i) = case indexSmallArray# sa# i of - (# v #) -> v +indexSmallArray (SmallArray sa#) (I# i) = + case indexSmallArray# sa# i of + (# v #) -> v +-- | Map a function over the elements of a 'SmallArray' +-- +mapSmallArray :: (a -> b) -> SmallArray a -> SmallArray b +{-# INLINE mapSmallArray #-} +mapSmallArray f sa = runST $ ST $ \s -> + let + n = sizeofSmallArray sa + go !i saMut# state# + | i < n = + let + a = indexSmallArray sa i + newState# = writeSmallArray saMut# i (f a) state# + in + go (i + 1) saMut# newState# + | otherwise = state# + in + case newSmallArray n (error "SmallArray: internal error, uninitialised elements") s of + (# s', mutArr #) -> + case go 0 mutArr s' of + s'' -> unsafeFreezeSmallArray mutArr s'' + +-- | Fold the values of a 'SmallArray' into a 'Monoid m' of choice +foldMapSmallArray :: Monoid m => (a -> m) -> SmallArray a -> m +{-# INLINE foldMapSmallArray #-} +foldMapSmallArray f sa = go 0 + where + n = sizeofSmallArray sa + go i + | i < n = f (indexSmallArray sa i) `mappend` go (i + 1) + | otherwise = mempty + +-- | Force the elements of the given 'SmallArray' +-- +rnfSmallArray :: NFData a => SmallArray a -> () +{-# INLINE rnfSmallArray #-} +rnfSmallArray sa = go 0 + where + n = sizeofSmallArray sa + go !i + | i < n = rnf (indexSmallArray sa i) `seq` go (i + 1) + | otherwise = () -- | Convert a list into an array. listToArray :: Int -> (e -> Int) -> (e -> a) -> [e] -> SmallArray a ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -19,6 +19,8 @@ module GHC.Iface.Binary ( TraceBinIFace(..), getWithUserData, putWithUserData, + putWithTables', + getTables', -- * Internal serialisation functions getSymbolTable, @@ -62,6 +64,7 @@ import qualified Data.Map as Map import System.IO import Data.List import System.FilePath +import System.IO.Unsafe -- --------------------------------------------------------------------------- -- Reading and writing binary interface files @@ -180,7 +183,7 @@ getWithUserData name_cache bh = do -- (getDictFastString dict) data ReadIfaceTable out = ReadIfaceTable - { getTable :: HasCallStack => IORef BinHandle -> BinHandle -> IO out + { getTable :: HasCallStack => BinHandle -> IO out } data WriteIfaceTable = WriteIfaceTable @@ -189,21 +192,22 @@ data WriteIfaceTable = WriteIfaceTable getTables' :: HasCallStack => NameCache -> BinHandle -> IO BinHandle getTables' name_cache bh = do + bhRef <- newIORef (error "used too soon") + ud <- unsafeInterleaveIO (readIORef bhRef) fsCache <- initReadFsCachedBinary nameCache <- initReadNameCachedBinary name_cache -- ifaceCache <- initReadIfaceTyConTable - ifaceTypeCache <- initReadIfaceTypeTable - bhRef <- newIORef (error "used too soon") + ifaceTypeCache <- initReadIfaceTypeTable ud -- 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 <- Binary.forwardGet bh (getTable fsCache bhRef bh) + dict <- Binary.forwardGet bh (getTable fsCache bh) let fsDecoder = mkReader $ getDictFastString dict bh_fs = addDecoder (mkCache (Proxy @FastString) fsDecoder) bh - symtab <- Binary.forwardGet bh_fs (getTable nameCache bhRef bh_fs) + symtab <- Binary.forwardGet bh_fs (getTable nameCache bh_fs) let nameCache' = mkReader $ getSymtabName symtab @@ -215,10 +219,10 @@ getTables' name_cache bh = do -- bh_name2 = addDecoder (mkCache (Proxy :: Proxy IfaceTyCon) ifaceDecoder) bh_name - ifaceSymTab2 <- Binary.forwardGet bh_name (getTable ifaceTypeCache bhRef bh_name) + ifaceSymTab2 <- Binary.forwardGet bh_name (getTable ifaceTypeCache bh_name) let ifaceDecoder2 = mkReader $ getGenericSymtab ifaceSymTab2 let bh_type = addDecoder (mkCache (Proxy :: Proxy IfaceType) ifaceDecoder2) bh_name - writeIORef bhRef bh_type + writeIORef bhRef (getUserData bh_type) return bh_type @@ -265,7 +269,7 @@ writeStackFormat fp report = do -- This segment should be read using `getWithUserData`. putWithUserData :: HasCallStack => Binary a => TraceBinIFace -> BinHandle -> a -> IO () putWithUserData traceBinIface bh payload = do - (name_count, fs_count, _b) <- putWithTables' bh (\bh' -> putNoStack bh' payload) + (name_count, fs_count, type_count, _b) <- putWithTables' bh (\bh' -> putNoStack bh' payload) case traceBinIface of QuietBinIFace -> return () @@ -279,7 +283,7 @@ initReadFsCachedBinary :: (HasCallStack) => IO (ReadIfaceTable (SymbolTable Fast initReadFsCachedBinary = do return $ ReadIfaceTable - { getTable = \_ -> getDictionary + { getTable = getDictionary } initWriteFsTable :: (HasCallStack) => IO (WriteIfaceTable, CachedBinary FastString) @@ -308,7 +312,7 @@ initReadNameCachedBinary :: (HasCallStack) => NameCache -> IO (ReadIfaceTable (S initReadNameCachedBinary cache = do return $ ReadIfaceTable - { getTable = \_ bh -> getSymbolTable bh cache + { getTable = \bh -> getSymbolTable bh cache } initWriteNameTable :: (HasCallStack) => IO (WriteIfaceTable, CachedBinary Name) @@ -338,14 +342,21 @@ initReadIfaceTyConTable :: HasCallStack => IO (ReadIfaceTable (SymbolTable Iface initReadIfaceTyConTable = do pure $ ReadIfaceTable - { getTable = getGenericSymbolTable (\_ -> getIfaceTyCon) + { getTable = getGenericSymbolTable getIfaceTyCon } -initReadIfaceTypeTable :: HasCallStack => IO (ReadIfaceTable (SymbolTable IfaceType)) -initReadIfaceTypeTable = do +readFromSymTab :: UserData -> BinHandle -> IO FullBinData +readFromSymTab ud bh = do + p <- get @(Bin ()) bh -- a BinPtr + frozen_bh <- freezeBinHandle p (setUserData bh ud) + seekBinNoExpand bh p -- skip over the object for now + return frozen_bh + +initReadIfaceTypeTable :: HasCallStack => UserData -> IO (ReadIfaceTable (SymbolTable IfaceType)) +initReadIfaceTypeTable ud = do pure $ ReadIfaceTable - { getTable = getGenericSymbolTable (\optr bh -> IfaceSerialisedType <$> freezeBinHandle optr bh) + { getTable = getGenericSymbolTable (\bh -> IfaceSerialisedType <$!> readFromSymTab ud bh) } @@ -365,7 +376,7 @@ initWriteIfaceType = do sym_tab <- initGenericSymbolTable pure ( WriteIfaceTable - { putTable = putGenericSymbolTable sym_tab putIfaceType + { putTable = putGenericSymbolTable sym_tab (lazyPut' putIfaceType) } , mkWriter $ putGenericSymTab sym_tab ) @@ -417,7 +428,7 @@ initWriteIfaceType = do -- return (name_count, fs_count, r) -putWithTables' :: HasCallStack => BinHandle -> (BinHandle -> IO b) -> IO (Int,Int,b) +putWithTables' :: HasCallStack => BinHandle -> (BinHandle -> IO b) -> IO (Int,Int, Int, b) putWithTables' bh' put_payload = do (fsTbl, fsWriter) <- initWriteFsTable (nameTbl, nameWriter) <- initWriteNameTable @@ -432,14 +443,14 @@ putWithTables' bh' put_payload = do ] let bh = setUserData bh' userData - (fs_count,(name_count,(_, r))) <- + (fs_count,(name_count,(type_count, r))) <- forwardPut bh (const (putTable fsTbl bh)) $ do forwardPut bh (const (putTable nameTbl bh)) $ do -- forwardPut bh (const (putTable ifaceTyConTbl bh)) $ do forwardPut bh (const (putTable ifaceTypeTbl bh)) $ do put_payload bh - return (name_count, fs_count, r) + return (name_count, fs_count, type_count, r) -- | Initial ram buffer to allocate for writing interface files initBinMemSize :: Int ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -96,6 +96,8 @@ import Data.List ( sortBy ) import Data.Ord import Data.IORef +import qualified Data.ByteString as BS + {- ************************************************************************ @@ -157,10 +159,11 @@ shareIface :: NameCache -> ModIface -> IO ModIface shareIface nc mi = do bh <- openBinMem (1024 * 1024) -- Todo, not quite right (See ext fields etc) - start <- tellBin @() bh putWithUserData QuietBinIFace bh mi - seekBin bh start - res <- getWithUserData nc bh + -- Copy out just the part of the buffer which is used, otherwise each interface + -- retains a 1mb bytearray + bh' <- withBinBuffer bh (\bs -> unsafeUnpackBinBuffer (BS.copy bs)) + res <- getWithUserData nc bh' let resiface = res { mi_src_hash = mi_src_hash mi } forceModIface resiface return resiface ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -619,7 +619,7 @@ fromIfaceStringLiteral (IfStringLiteral st fs) = StringLiteral st fs Nothing -} data IfaceExpr - = IfaceSerialisedExpr FullBinData + = IfaceSerialisedExpr !FullBinData | IfaceLcl IfLclName | IfaceExt IfExtName | IfaceType IfaceType ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -161,7 +161,7 @@ type IfaceKind = IfaceType -- Any time a 'Type' is pretty-printed, it is first converted to an 'IfaceType' -- before being printed. See Note [Pretty printing via Iface syntax] in "GHC.Types.TyThing.Ppr" data IfaceType - = IfaceSerialisedType FullBinData + = IfaceSerialisedType !FullBinData | IfaceFreeTyVar TyVar -- See Note [Free tyvars in IfaceType] | IfaceTyVar IfLclName -- Type/coercion variable only, not tycon | IfaceLitTy IfaceTyLit ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -92,6 +92,10 @@ import GHC.Stg.Syntax import qualified Data.IntSet as IntSet import GHC.CoreToIface import Data.Array as Array +import GHC.Utils.Binary +import Data.IORef +import System.IO.Unsafe +import GHC.Iface.Binary -- ----------------------------------------------------------------------------- -- Generating byte code for a complete module @@ -2190,6 +2194,7 @@ data BcM_State -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints , breakInfo :: IntMap CgBreakInfo + , breakInfoBuffer :: (BinHandle, UserData) -- ^ A buffer which enables CgBreakInfo to be shared. } newtype BcM r = BcM (BcM_State -> IO (BcM_State, r)) deriving (Functor) @@ -2202,8 +2207,32 @@ ioToBc io = BcM $ \st -> do runBc :: HscEnv -> Module -> Maybe ModBreaks -> BcM r -> IO (BcM_State, r) -runBc hsc_env this_mod modBreaks (BcM m) - = m (BcM_State hsc_env this_mod 0 [] modBreaks IntMap.empty) +runBc hsc_env this_mod modBreaks (BcM m) = do + bh <- openBinMem 1024 + start <- tellBin @() bh + user_data <- newIORef (error "used too soon") + read_ud <- unsafeInterleaveIO (readIORef user_data) + (fs, n, t, r) <- putWithTables' bh + (\bh' -> m (BcM_State hsc_env this_mod 0 [] modBreaks IntMap.empty (bh', read_ud))) + seekBinNoExpand bh start + bh_with_user <- getTables' (hsc_NC hsc_env) bh + writeIORef user_data (getUserData bh_with_user) + return r + +{- +shareIface :: NameCache -> ModIface -> IO ModIface +shareIface nc mi = do + bh <- openBinMem (1024 * 1024) + -- Todo, not quite right (See ext fields etc) + putWithUserData QuietBinIFace bh mi + -- Copy out just the part of the buffer which is used, otherwise each interface + -- retains a 1mb bytearray + bh' <- withBinBuffer bh (\bs -> unsafeUnpackBinBuffer (BS.copy bs)) + res <- getWithUserData nc bh' + let resiface = res { mi_src_hash = mi_src_hash mi } + forceModIface resiface + return resiface + -} thenBc :: BcM a -> (a -> BcM b) -> BcM b thenBc (BcM expr) cont = BcM $ \st0 -> do @@ -2260,8 +2289,13 @@ getLabelsBc n in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) newBreakInfo :: BreakIndex -> CgBreakInfo -> BcM () -newBreakInfo ix info = BcM $ \st -> - return (st{breakInfo = IntMap.insert ix info (breakInfo st)}, ()) +newBreakInfo ix info = BcM $ \st -> do + let (bh, read_ud) = breakInfoBuffer st + start <- tellBin @() bh + lazyPut bh info + seekBinNoExpand bh start + shared_info <- lazyGet (setUserData bh read_ud) + return (st{breakInfo = IntMap.insert ix shared_info (breakInfo st)}, ()) getCurrentModule :: BcM Module getCurrentModule = BcM $ \st -> return (st, thisModule st) ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -344,7 +344,7 @@ tellBin (BinMem _ r _ _ _) = do ix <- readFastMutInt r; return (BinPtr ix) seekBin :: BinHandle -> Bin a -> IO () seekBin h@(BinMem _ ix_r sz_r _ _) (BinPtr !p) = do sz <- readFastMutInt sz_r - if (p >= sz) + if (p > sz) then do expandBin h p; writeFastMutInt ix_r p else writeFastMutInt ix_r p @@ -352,7 +352,7 @@ seekBin h@(BinMem _ ix_r sz_r _ _) (BinPtr !p) = do seekBinNoExpand :: BinHandle -> Bin a -> IO () seekBinNoExpand (BinMem _ ix_r sz_r _ _) (BinPtr !p) = do sz <- readFastMutInt sz_r - if (p >= sz) + if (p > sz) then panic "seekBinNoExpand: seek out of range" else writeFastMutInt ix_r p @@ -746,6 +746,10 @@ instance Binary Word64 where putNoStack_ = putULEB128 get = getULEB128 +instance Binary Word where + putNoStack_ = putULEB128 + get = getULEB128 + -- ----------------------------------------------------------------------------- -- Primitive Int writes @@ -1274,20 +1278,21 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do case vs of [] -> return table_count todo -> do - mapM_ (\n -> lazyPut' serialiser bh n) (map snd vs) + mapM_ (\n -> serialiser bh n) (map snd vs) loop table_count snd <$> (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop 0) -getGenericSymbolTable :: forall a. (Bin () -> BinHandle -> IO a) -> IORef BinHandle -> BinHandle -> IO (SymbolTable a) -getGenericSymbolTable deserialiser bhRef bh = do +getGenericSymbolTable :: forall a. (BinHandle -> IO a) -> BinHandle -> IO (SymbolTable a) +getGenericSymbolTable deserialiser bh = do sz <- forwardGet bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) -- Using lazyPut/lazyGet is quite space inefficient as each usage will allocate a large closure -- (6 arguments-ish). forM_ [0..(sz-1)] $ \i -> do - f <- lazyGet' (Just bhRef) deserialiser bh +-- f <- lazyGet' (Just bhRef) deserialiser bh + !f <- deserialiser bh writeArray mut_arr i f -- pprTraceM "gotten" (ppr sz) unsafeFreeze mut_arr ===================================== ghc/GHCi/UI.hs ===================================== @@ -558,7 +558,7 @@ interactiveUI config srcs maybe_exprs = do -- Set to True because Prelude is implicitly imported. impDecl at ImportDecl{ideclExt=ext} -> impDecl{ideclExt = ext{ideclImplicit=True}} hsc_env <- GHC.getSession - let in_multi = length (hsc_all_home_unit_ids hsc_env) > 1 + let !in_multi = length (hsc_all_home_unit_ids hsc_env) > 1 empty_cache <- liftIO newIfaceCache startGHCi (runGHCi srcs maybe_exprs) GHCiState{ progname = default_progname, ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -71,6 +71,7 @@ GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList GHC.Data.Pair +GHC.Data.SmallArray GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -72,6 +72,7 @@ GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList GHC.Data.Pair +GHC.Data.SmallArray GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/42ce32c800b6c22c150cde35e7db66da61fa0085...6ed397bde8d9d0a8214d8b90ac2d07b3d754d70c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/42ce32c800b6c22c150cde35e7db66da61fa0085...6ed397bde8d9d0a8214d8b90ac2d07b3d754d70c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 16:39:41 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 27 Mar 2024 12:39:41 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] More small improvements Message-ID: <66044bcd71714_26159366ece80104083@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 1b1281ef by Simon Peyton Jones at 2024-03-27T16:39:08+00:00 More small improvements 1. use `isBetterUnfoldingThan` in join-point inlinint 2. In Inline, some_benefit is only true for RhsCtxt when UnfWhen c.f. seqIsBoring and #22317 3. Simplify StrictArgCtxt... not sure here 4. Add tagToEnum# to CaseMerge. Good for case (case f x of r -> tagToEnum# r) of alts Avoids danger that we make a join point $j r -> case tagToEnum# r of alts which involves a test we don't have to do. - - - - - 15 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Utils.hs - testsuite/tests/cpranal/should_compile/T18401.stderr - testsuite/tests/dmdanal/sigs/T21081.stderr - testsuite/tests/driver/inline-check.stderr - testsuite/tests/numeric/should_compile/T19641.stderr - + testsuite/tests/perf/compiler/T18730.hs - + testsuite/tests/perf/compiler/T18730.stderr - + testsuite/tests/perf/compiler/T18730_A.hs - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T22317.hs - testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/spec-inline.stderr Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -64,7 +64,7 @@ module GHC.Core ( isValueUnfolding, isEvaldUnfolding, isCheapUnfolding, isExpandableUnfolding, isConLikeUnfolding, isCompulsoryUnfolding, isStableUnfolding, isStableUserUnfolding, isStableSystemUnfolding, - isInlineUnfolding, isBootUnfolding, + isInlineUnfolding, isBootUnfolding, isBetterUnfoldingThan, hasCoreUnfolding, hasSomeUnfolding, canUnfold, neverUnfoldGuidance, isStableSource, @@ -1640,6 +1640,23 @@ canUnfold :: Unfolding -> Bool canUnfold (CoreUnfolding { uf_guidance = g }) = not (neverUnfoldGuidance g) canUnfold _ = False +isBetterUnfoldingThan :: Unfolding -> Unfolding -> Bool +-- Used in inlining checks +isBetterUnfoldingThan NoUnfolding _ = False +isBetterUnfoldingThan BootUnfolding _ = False + +isBetterUnfoldingThan (CoreUnfolding {}) (CoreUnfolding {}) = False +isBetterUnfoldingThan (CoreUnfolding {}) _ = True + +isBetterUnfoldingThan (DFunUnfolding {}) (DFunUnfolding {}) = False +isBetterUnfoldingThan (DFunUnfolding {}) _ = True + +isBetterUnfoldingThan (OtherCon cs) (OtherCon cs') = not (null cs) && null cs' -- A bit crude +isBetterUnfoldingThan (OtherCon {}) (CoreUnfolding {}) = False +isBetterUnfoldingThan (OtherCon {}) (DFunUnfolding {}) = False +isBetterUnfoldingThan (OtherCon {}) NoUnfolding = True +isBetterUnfoldingThan (OtherCon {}) BootUnfolding = True + {- Note [Fragile unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ An unfolding is "fragile" if it mentions free variables (and hence would ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -314,7 +314,7 @@ tryUnfolding env logger id lone_variable arg_infos | otherwise -> traceInline logger opts id str (mk_doc some_benefit empty False) Nothing where - some_benefit = calc_some_benefit uf_arity + some_benefit = calc_some_benefit uf_arity True enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size } @@ -326,7 +326,7 @@ tryUnfolding env logger id lone_variable arg_infos yes = traceInline logger opts id str (mk_doc some_benefit extra_doc True) (Just unf_template) no = traceInline logger opts id str (mk_doc some_benefit extra_doc False) Nothing - some_benefit = calc_some_benefit (length arg_discounts) + some_benefit = calc_some_benefit (length arg_discounts) False -- depth_penalty: see Note [Avoid inlining into deeply nested cases] depth_threshold = unfoldingCaseThreshold opts @@ -389,9 +389,9 @@ tryUnfolding env logger id lone_variable arg_infos -- arguments (ie n_val_args >= arity). But there must -- be *something* interesting about some argument, or the -- result context, to make it worth inlining - calc_some_benefit :: Arity -> Bool -- The Arity is the number of args + calc_some_benefit :: Arity -> Bool -> Bool -- The Arity is the number of args -- expected by the unfolding - calc_some_benefit uf_arity + calc_some_benefit uf_arity is_inline | not saturated = interesting_args -- Under-saturated -- Note [Unsaturated applications] | otherwise = interesting_args -- Saturated or over-saturated @@ -413,7 +413,7 @@ tryUnfolding env logger id lone_variable arg_infos ValAppCtxt -> True -- Note [Cast then apply] RuleArgCtxt -> uf_arity > 0 -- See Note [RHS of lets] DiscArgCtxt -> uf_arity > 0 -- Note [Inlining in ArgCtxt] - RhsCtxt NonRecursive + RhsCtxt NonRecursive | is_inline -> uf_arity > 0 -- See Note [RHS of lets] _other -> False -- See Note [Nested functions] @@ -424,9 +424,8 @@ vselems s = nonDetStrictFoldVarSet (\v vs -> v : vs) [] s is_more_evald :: InScopeSet -> Id -> Bool -- See Note [Inlining join points] is_more_evald in_scope v - | not (isEvaldUnfolding (idUnfolding v)) - , Just v' <- lookupInScope in_scope v - , isEvaldUnfolding (idUnfolding v') + | Just v1 <- lookupInScope in_scope v + , idUnfolding v1 `isBetterUnfoldingThan` idUnfolding v = True | otherwise = False ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -888,20 +888,22 @@ lazyArgContext (ArgInfo { ai_encl = encl_rules, ai_discs = discs }) | otherwise = BoringCtxt -- Nothing interesting strictArgContext :: ArgInfo -> CallCtxt -strictArgContext (ArgInfo { ai_encl = encl_rules, ai_discs = discs }) --- Use this for strict arguments - | encl_rules = RuleArgCtxt - | disc:_ <- discs, disc > 0 = DiscArgCtxt -- Be keener here - | otherwise = RhsCtxt NonRecursive - -- Why RhsCtxt? if we see f (g x), and f is strict, we - -- want to be a bit more eager to inline g, because it may - -- expose an eval (on x perhaps) that can be eliminated or - -- shared. I saw this in nofib 'boyer2', RewriteFuns.onewayunify1 - -- It's worth an 18% improvement in allocation for this - -- particular benchmark; 5% on 'mate' and 1.3% on 'multiplier' - -- - -- Why NonRecursive? Becuase it's a bit like - -- let a = g x in f a +strictArgContext _ = DiscArgCtxt + -- XXXX TODO TODO c.f. Seq is boring + -- Why RhsCtxt? if we see f (g x), and f is strict, we + -- want to be a bit more eager to inline g, because it may + -- expose an eval (on x perhaps) that can be eliminated or + -- shared. I saw this in nofib 'boyer2', RewriteFuns.onewayunify1 + -- It's worth an 18% improvement in allocation for this + -- particular benchmark; 5% on 'mate' and 1.3% on 'multiplier' + -- + -- Why NonRecursive? Becuase it's a bit like + -- let a = g x in f a + +-- (ArgInfo { ai_encl = encl_rules, ai_discs = discs }) +-- | encl_rules = RuleArgCtxt +-- | disc:_ <- discs, disc > 0 = DiscArgCtxt -- Be keener here +-- | otherwise = RhsCtxt NonRecursive interestingCallContext :: SimplEnv -> SimplCont -> CallCtxt -- See Note [Interesting call context] ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -16,7 +16,7 @@ module GHC.Core.Utils ( -- * Taking expressions apart findDefault, addDefault, findAlt, isDefaultAlt, - mergeAlts, mergeCaseAlts, trimConArgs, + mergeAlts, mergeCaseAlts, trimConArgs, filterAlts, combineIdenticalAlts, refineDefaultAlt, scaleAltsBy, @@ -674,8 +674,7 @@ mergeCaseAlts outer_bndr alts -- duplication we are prepared to put up with. go 0 _ _ _ = Nothing - go n wrap free_bndrs (Tick t rhs) - = go n (wrap . Tick t) free_bndrs rhs + -- Whizzo: we can merge! go _ wrap free_bndrs (Case (Var inner_scrut_var) inner_bndr _ inner_alts) | inner_scrut_var == outer_bndr , let wrap_let rhs' = Let (NonRec inner_bndr (Var outer_bndr)) rhs' @@ -686,6 +685,26 @@ mergeCaseAlts outer_bndr alts | any (`elemVarSet` free_bndrs') bndrs = Nothing | otherwise = Just (Alt con bndrs (wrap (wrap_let rhs))) = mapM do_one inner_alts + + -- Deal with tagToEnum# See See Note [Merge Nested Cases] wrinkle (MNC1) + go _ wrap _ (App (App (Var f) (Type type_arg)) (Var v)) + | v == outer_bndr + , Just TagToEnumOp <- isPrimOpId_maybe f + , Just tc <- tyConAppTyCon_maybe type_arg + , Just (dc:dcs) <- tyConDataCons_maybe tc + , dcs `lengthAtMost` 3 -- Arbitrary + = Just ( Alt DEFAULT [] (mk_rhs dc) + : [Alt (LitAlt (mk_lit dc)) [] (mk_rhs dc) | dc <- dcs] ) + + where + mk_lit dc = mkLitIntUnchecked $ toInteger $ dataConTagZ dc + mk_rhs dc = wrap $ Var (dataConWorkId dc) + + -- Look past ticks + go n wrap free_bndrs (Tick t rhs) + = go n (wrap . Tick t) free_bndrs rhs + + -- Look past cases on another variable go n wrap free_bndrs (Case (Var inner_scrut) inner_bndr ty inner_alts) | [Alt con bndrs rhs] <- inner_alts -- Wrinkle (MC1) , not (outer_bndr `elem` (inner_bndr : bndrs)) ===================================== testsuite/tests/cpranal/should_compile/T18401.stderr ===================================== @@ -4,34 +4,34 @@ Result size of Tidy Core = {terms: 58, types: 93, coercions: 0, joins: 1/1} Rec { -- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} -T18401.$w$spoly_$wgo2 :: forall a. a -> [a] -> (# [a] #) -T18401.$w$spoly_$wgo2 - = \ (@a_s1dv) (sc_s1dw :: a_s1dv) (sc1_s1dx :: [a_s1dv]) -> - case sc1_s1dx of { - [] -> (# GHC.Types.[] @a_s1dv #); - : y_a1ct ys_a1cu -> (# GHC.Types.: @a_s1dv sc_s1dw (case T18401.$w$spoly_$wgo2 @a_s1dv y_a1ct ys_a1cu of { (# ww_s1dC #) -> ww_s1dC }) #) +T18401.$w$spoly_$wgo1 :: forall a. a -> [a] -> (# [a] #) +T18401.$w$spoly_$wgo1 + = \ (@a_s1eu) (sc_s1ev :: a_s1eu) (sc1_s1ew :: [a_s1eu]) -> + case sc1_s1ew of { + [] -> (# GHC.Types.[] @a_s1eu #); + : y_a1dy ys_a1dz -> (# GHC.Types.: @a_s1eu sc_s1ev (case T18401.$w$spoly_$wgo1 @a_s1eu y_a1dy ys_a1dz of { (# ww_s1eA #) -> ww_s1eA }) #) } end Rec } -- RHS size: {terms: 23, types: 29, coercions: 0, joins: 1/1} si :: forall a. [a] -> (Bool, [a]) si - = \ (@a_s1cD) (xs0_s1cE :: [a_s1cD]) -> + = \ (@a_s1dI) (xs0_s1dJ :: [a_s1dI]) -> join { - $j_s1dr :: Bool %1 -> [a_s1cD] %1 -> (Bool, [a_s1cD]) - $j_s1dr (ww_s1cS :: Bool) (ww1_s1cT :: [a_s1cD]) = (ww_s1cS, ww1_s1cT) } in - case xs0_s1cE of { - [] -> jump $j_s1dr GHC.Types.False (GHC.Types.[] @a_s1cD); - : y_a1ct ys_a1cu -> jump $j_s1dr GHC.Types.True (case T18401.$w$spoly_$wgo2 @a_s1cD y_a1ct ys_a1cu of { (# ww_s1dC #) -> ww_s1dC }) + $j_s1eq :: Bool %1 -> [a_s1dI] %1 -> (Bool, [a_s1dI]) + $j_s1eq (ww_s1dX :: Bool) (ww1_s1dY :: [a_s1dI]) = (ww_s1dX, ww1_s1dY) } in + case xs0_s1dJ of { + [] -> jump $j_s1eq GHC.Types.False (GHC.Types.[] @a_s1dI); + : y_a1dy ys_a1dz -> jump $j_s1eq GHC.Types.True (case T18401.$w$spoly_$wgo1 @a_s1dI y_a1dy ys_a1dz of { (# ww_s1eA #) -> ww_s1eA }) } -- RHS size: {terms: 14, types: 19, coercions: 0, joins: 0/0} safeInit :: forall a. [a] -> Maybe [a] safeInit - = \ (@a_aR8) (xs_awS :: [a_aR8]) -> - case xs_awS of { - [] -> GHC.Maybe.Nothing @[a_aR8]; - : y_a1ct ys_a1cu -> GHC.Maybe.Just @[a_aR8] (case T18401.$w$spoly_$wgo2 @a_aR8 y_a1ct ys_a1cu of { (# ww_s1dC #) -> ww_s1dC }) + = \ (@a_aQY) (xs_awU :: [a_aQY]) -> + case xs_awU of { + [] -> GHC.Internal.Maybe.Nothing @[a_aQY]; + : y_a1dy ys_a1dz -> GHC.Internal.Maybe.Just @[a_aQY] (case T18401.$w$spoly_$wgo1 @a_aQY y_a1dy ys_a1dz of { (# ww_s1eA #) -> ww_s1eA }) } ===================================== testsuite/tests/dmdanal/sigs/T21081.stderr ===================================== @@ -15,7 +15,7 @@ T21081.fst': <1!P(1L,A)> T21081.g: T21081.h: <1!P(1L)> T21081.h2: -T21081.i: <1L><1L> +T21081.i: <1L><1L> T21081.j: T21081.myfoldl: <1L><1L> T21081.snd': <1!P(A,1L)> @@ -61,7 +61,7 @@ T21081.fst': <1!P(1L,A)> T21081.g: T21081.h: <1!P(1L)> T21081.h2: <1!P(SL)> -T21081.i: <1L><1L> +T21081.i: <1L><1L> T21081.j: <1!P(1L,1L)> T21081.myfoldl: <1L><1L> T21081.snd': <1!P(A,1L)> ===================================== testsuite/tests/driver/inline-check.stderr ===================================== @@ -8,7 +8,7 @@ Considering inlining: foo case depth = 0 inline depth = 0 depth based penalty = 0 - discounted size = 10 + adjusted size = 10 ANSWER = YES Inactive unfolding: foo1 Inactive unfolding: foo1 @@ -28,6 +28,6 @@ Considering inlining: foo case depth = 0 inline depth = 0 depth based penalty = 0 - discounted size = 20 + adjusted size = 20 ANSWER = NO Inactive unfolding: foo1 ===================================== testsuite/tests/numeric/should_compile/T19641.stderr ===================================== @@ -13,9 +13,9 @@ natural_to_word integer_to_int = \ eta -> case eta of { - IS x1 -> Just (I# x1); - IP ipv -> Nothing; - IN ds1 -> Nothing + IS ipv -> Just (I# ipv); + IP x -> Nothing; + IN ds2 -> Nothing } ===================================== testsuite/tests/perf/compiler/T18730.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE TupleSections #-} +{-# OPTIONS_GHC -funfolding-case-scaling=5 #-} + +module T18730 where + +import T18730_A (Gen) + +genFields :: Gen [(String, Int)] +genFields = + mapM + (\(f, g) -> (f,) <$> g) + [ ("field", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + , ("field_10", genIntField) + ] + +genIntField :: Gen Int +genIntField = pure 0 ===================================== testsuite/tests/perf/compiler/T18730.stderr ===================================== @@ -0,0 +1 @@ + ===================================== testsuite/tests/perf/compiler/T18730_A.hs ===================================== @@ -0,0 +1,50 @@ +module T18730_A where + +import Control.Monad (ap) +import Data.Word +import Data.Bits + +newtype Gen a = MkGen + { -- | Run the generator on a particular seed. + -- If you just want to get a random value out, consider using 'generate'. + unGen :: QCGen -> Int -> a + } + +instance Functor Gen where + fmap f (MkGen h) = + MkGen (\r n -> f (h r n)) + +instance Applicative Gen where + pure x = + MkGen (\_ _ -> x) + (<*>) = ap + +instance Monad Gen where + return = pure + + MkGen m >>= k = + MkGen + ( \r n -> + case split r of + (r1, r2) -> + let MkGen m' = k (m r1 n) + in m' r2 n + ) + + (>>) = (*>) + +data QCGen = QCGen !Word64 !Word64 + +split :: QCGen -> (QCGen, QCGen) +split (QCGen seed gamma) = + (QCGen seed'' gamma, QCGen seed' (mixGamma seed'')) + where + seed' = seed + gamma + seed'' = seed' + gamma + +-- This piece appears to be critical +mixGamma :: Word64 -> Word64 +mixGamma z0 = + if z0 >= 24 + then z0 + else z0 `xor` 0xaaaaaaaaaaaaaaaa ===================================== testsuite/tests/simplCore/should_compile/T15631.stdout ===================================== @@ -1,5 +1,6 @@ - case GHC.List.$wlenAcc @a xs 0# of ww1 { __DEFAULT -> - = case GHC.List.$wlenAcc - case GHC.List.reverse1 @a xs (GHC.Types.[] @a) of { + case reverse @a xs of ys { __DEFAULT -> + case GHC.Internal.List.$wlenAcc @a xs 0# of ww1 { __DEFAULT -> + = case GHC.Internal.List.$wlenAcc + case ys of { case Foo.$wf @a xs of ww [Occ=Once1] { __DEFAULT -> case Foo.$wf @a xs of ww { __DEFAULT -> GHC.Types.I# ww } ===================================== testsuite/tests/simplCore/should_compile/T22317.hs ===================================== @@ -6,9 +6,9 @@ data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) m :: Maybe a -> Maybe a -> Maybe a +-- Don't make this INLINE; if you do, ,it's not unreasonable to inline it m (Just v1) Nothing = Just v1 m _ mb = mb -{-# INLINE m #-} f :: T -> T -> T f (T a1 b1 c1 d1) (T a2 b2 c2 d2) ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 28, types: 15, coercions: 0, joins: 2/2} + = {terms: 32, types: 14, coercions: 0, joins: 1/1} -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T22428.f1 :: Integer @@ -11,36 +11,37 @@ T22428.f1 :: Integer Guidance=IF_ARGS [] 10 10}] T22428.f1 = GHC.Num.Integer.IS 1# --- RHS size: {terms: 24, types: 11, coercions: 0, joins: 2/2} +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} f :: Integer -> Integer -> Integer [GblId, Arity=2, - Str=, + Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [0 0] 94 0}] + Guidance=IF_ARGS [0 0] 140 0}] f = \ (x :: Integer) (y :: Integer) -> joinrec { go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] :: Integer -> Integer [LclId[JoinId(1)(Just [!])], Arity=1, - Str=, + Str=<1L>, Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] go (ds :: Integer) - = join { - $j [Dmd=ML] :: Integer - [LclId[JoinId(0)(Nothing)]] - $j = jump go (GHC.Num.Integer.integerSub ds T22428.f1) } in - case ds of { - GHC.Num.Integer.IS x1 -> - case x1 of { - __DEFAULT -> jump $j; + = case ds of x1 { + GHC.Num.Integer.IS x2 -> + case x2 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub x1 T22428.f1); 0# -> x }; - GHC.Num.Integer.IP x1 -> jump $j; - GHC.Num.Integer.IN x1 -> jump $j + GHC.Num.Integer.IP x2 -> + jump go (GHC.Num.Integer.integerSub x1 T22428.f1); + GHC.Num.Integer.IN x2 -> + jump go (GHC.Num.Integer.integerSub x1 T22428.f1) }; } in jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -1,41 +1,114 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 57, types: 17, coercions: 0, joins: 1/1} + = {terms: 136, types: 55, coercions: 0, joins: 0/0} --- RHS size: {terms: 48, types: 11, coercions: 0, joins: 1/1} -Roman.$wfoo [InlPrag=[2]] :: Int -> GHC.Prim.Int# -[GblId[StrictWorker([!])], - Arity=1, - Str=<1L>, +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] +lvl = "spec-inline.hs:(19,5)-(29,25)|function go"# + +-- RHS size: {terms: 2, types: 2, coercions: 0, joins: 0/0} +Roman.foo3 :: () +[GblId, Str=b, Cpr=b] +Roman.foo3 + = GHC.Internal.Control.Exception.Base.patError + @GHC.Types.LiftedRep @() lvl + +Rec { +-- RHS size: {terms: 40, types: 5, coercions: 0, joins: 0/0} +Roman.foo_$s$wgo [Occ=LoopBreaker] + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=, Unf=OtherCon []] +Roman.foo_$s$wgo + = \ (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#) -> + case GHC.Prim.<=# sc1 0# of { + __DEFAULT -> + case GHC.Prim.<# sc1 100# of { + __DEFAULT -> + case GHC.Prim.<# sc1 500# of { + __DEFAULT -> + Roman.foo_$s$wgo (GHC.Prim.*# 14# sc) (GHC.Prim.-# sc1 1#); + 1# -> Roman.foo_$s$wgo (GHC.Prim.*# 7# sc) (GHC.Prim.-# sc1 3#) + }; + 1# -> Roman.foo_$s$wgo sc (GHC.Prim.-# sc1 2#) + }; + 1# -> 0# + } +end Rec } + +-- RHS size: {terms: 61, types: 18, coercions: 0, joins: 0/0} +Roman.$wgo [InlPrag=[2]] :: Maybe Int -> Maybe Int -> GHC.Prim.Int# +[GblId[StrictWorker([!, !])], + Arity=2, + Str=<1L><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [20] 78 0}] -Roman.$wfoo - = \ (n :: Int) -> - case n of { GHC.Types.I# ipv -> - joinrec { - $sgo [Occ=LoopBreaker, Dmd=SC(S,C(1,L))] - :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# - [LclId[JoinId(2)(Nothing)], Arity=2, Str=, Unf=OtherCon []] - $sgo (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#) - = case GHC.Prim.<=# sc1 0# of { - __DEFAULT -> - case GHC.Prim.<# sc1 100# of { - __DEFAULT -> - case GHC.Prim.<# sc1 500# of { - __DEFAULT -> jump $sgo (GHC.Prim.*# 14# sc) (GHC.Prim.-# sc1 1#); - 1# -> jump $sgo (GHC.Prim.*# 7# sc) (GHC.Prim.-# sc1 3#) - }; - 1# -> jump $sgo sc (GHC.Prim.-# sc1 2#) - }; - 1# -> 0# - }; } in - jump $sgo 6# ipv + Guidance=IF_ARGS [61 30] 249 0}] +Roman.$wgo + = \ (u :: Maybe Int) (ds :: Maybe Int) -> + case ds of { + Nothing -> case Roman.foo3 of {}; + Just x -> + case x of { GHC.Types.I# ipv -> + case u of { + Nothing -> Roman.foo_$s$wgo (GHC.Prim.*# 7# ipv) 10#; + Just n -> + case n of { GHC.Types.I# x2 -> + case GHC.Prim.<=# x2 0# of { + __DEFAULT -> + case GHC.Prim.<# x2 100# of { + __DEFAULT -> + case GHC.Prim.<# x2 500# of { + __DEFAULT -> + Roman.foo_$s$wgo (GHC.Prim.*# 14# ipv) (GHC.Prim.-# x2 1#); + 1# -> Roman.foo_$s$wgo (GHC.Prim.*# 7# ipv) (GHC.Prim.-# x2 3#) + }; + 1# -> Roman.foo_$s$wgo ipv (GHC.Prim.-# x2 2#) + }; + 1# -> 0# + } + } + } + } } --- RHS size: {terms: 7, types: 2, coercions: 0, joins: 0/0} -foo [InlPrag=[2]] :: Int -> Int +-- RHS size: {terms: 9, types: 5, coercions: 0, joins: 0/0} +Roman.foo_go [InlPrag=[2]] :: Maybe Int -> Maybe Int -> Int +[GblId[StrictWorker([!, !])], + Arity=2, + Str=<1L><1L>, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) + Tmpl= \ (u [Occ=Once1] :: Maybe Int) + (ds [Occ=Once1] :: Maybe Int) -> + case Roman.$wgo u ds of ww [Occ=Once1] { __DEFAULT -> + GHC.Types.I# ww + }}] +Roman.foo_go + = \ (u :: Maybe Int) (ds :: Maybe Int) -> + case Roman.$wgo u ds of ww { __DEFAULT -> GHC.Types.I# ww } + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +Roman.foo2 :: Int +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] +Roman.foo2 = GHC.Types.I# 6# + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +Roman.foo1 :: Maybe Int +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] +Roman.foo1 = GHC.Internal.Maybe.Just @Int Roman.foo2 + +-- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} +foo :: Int -> Int [GblId, Arity=1, Str=<1L>, @@ -43,11 +116,22 @@ foo [InlPrag=[2]] :: Int -> Int Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (n [Occ=Once1] :: Int) -> - case Roman.$wfoo n of ww [Occ=Once1] { __DEFAULT -> - GHC.Types.I# ww + Tmpl= \ (n [Occ=Once1!] :: Int) -> + case n of n1 [Occ=Once1] { GHC.Types.I# _ [Occ=Dead] -> + Roman.foo_go (GHC.Internal.Maybe.Just @Int n1) Roman.foo1 }}] foo = \ (n :: Int) -> - case Roman.$wfoo n of ww { __DEFAULT -> GHC.Types.I# ww } + case n of { GHC.Types.I# ipv -> + case Roman.foo_$s$wgo 6# ipv of ww { __DEFAULT -> GHC.Types.I# ww } + } + + +------ Local rules for imported ids -------- +"SC:$wgo0" [2] + forall (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#). + Roman.$wgo (GHC.Internal.Maybe.Just @Int (GHC.Types.I# sc1)) + (GHC.Internal.Maybe.Just @Int (GHC.Types.I# sc)) + = Roman.foo_$s$wgo sc sc1 + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b1281efbe996f81653cf82735f44452ec10d5db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b1281efbe996f81653cf82735f44452ec10d5db You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 17:38:34 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 27 Mar 2024 13:38:34 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 32 commits: rts: fix clang compilation on aarch64 Message-ID: <6604599a38c3e_26159380f127c1209d6@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - 94d396f3 by Rodrigo Mesquita at 2024-03-27T11:53:10+00:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - 6107040e by Rodrigo Mesquita at 2024-03-27T11:53:10+00:00 Start writing test - - - - - 295a9a91 by Alexis King at 2024-03-27T11:53:10+00:00 wip: avoid linear search when looking up Haskell symbols via dlsym - - - - - 83145dd0 by Alexis King at 2024-03-27T11:53:10+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - 501b965d by Alexis King at 2024-03-27T11:53:10+00:00 wip: use loadNativeObj to implement addDLL - - - - - 1c9e9080 by Rodrigo Mesquita at 2024-03-27T11:53:10+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - 3b3bfb27 by Rodrigo Mesquita at 2024-03-27T16:14:49+00:00 Note down thing we need to refactor because of duplication - - - - - c0f52819 by Rodrigo Mesquita at 2024-03-27T16:14:49+00:00 Fail if no symbol is found in the relevant DLLs - - - - - 380d490e by Rodrigo Mesquita at 2024-03-27T16:54:32+00:00 Revert "Fail if no symbol is found in the relevant DLLs" This reverts commit c0f528199ae6000750ee0a220cebe005e24a753d. - - - - - 7abdbcf7 by Rodrigo Mesquita at 2024-03-27T16:58:10+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - 3d6c9c3a by Rodrigo Mesquita at 2024-03-27T16:58:10+00:00 Use lookupHsSymbol for PrimOps too - - - - - f0e072c9 by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - 19a86c6a by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 Write Note [Looking up symbols in the relevant objects] - - - - - 831d1af0 by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 VERY GOOD -3.5 seconds, instant main - - - - - c7d00128 by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 another potential perf improv - - - - - 90a9b715 by Matthew Pickering at 2024-03-27T16:58:11+00:00 Add support for ghc-debug to ghc executable - - - - - 810f7572 by Fendor at 2024-03-27T16:58:11+00:00 Bump ghc-debug submodule - - - - - 61a3225d by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 Debug traces - - - - - e6ebb068 by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 Revert "Debug traces" This reverts commit 6d409089abb02ea4cf6b3334206d0eb37b3550fd. - - - - - eb01dd6b by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 Attempt refactor ObjsLoaded instead of LinkableSet - - - - - a0f51f5f by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 Revert "Attempt refactor ObjsLoaded instead of LinkableSet" This reverts commit f66191bea1e0218faefe2ce748ff604d1e549817. - - - - - 2a31aec5 by Rodrigo Mesquita at 2024-03-27T16:58:11+00:00 misc comments - - - - - fdab3e60 by Rodrigo Mesquita at 2024-03-27T17:37:34+00:00 Write Note [Symbols may not be found in pkgs_loaded] - - - - - 30 changed files: - .gitmodules - + T23415/Makefile - + T23415/main.hs - + T23415/make_shared_libs.sh - + T23415/new-main.hs - + T23415/run_test.sh - compiler/GHC.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs - distrib/configure.ac.in - + ghc-debug - ghc/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/638e7bc233658597898fa368ac0e68833223f661...fdab3e60cb3cce2b154928c29ca136cbb4f15131 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/638e7bc233658597898fa368ac0e68833223f661...fdab3e60cb3cce2b154928c29ca136cbb4f15131 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 17:54:13 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 27 Mar 2024 13:54:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/err-orphans Message-ID: <66045d45916b5_261593881fdc8122395@gitlab.mail> Ben Gamari pushed new branch wip/err-orphans at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/err-orphans You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 18:02:44 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 27 Mar 2024 14:02:44 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 19 commits: loader: Note down structure suggestion for needed_mods Message-ID: <66045f44ec079_2615938b4672c1242fd@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 25cd808e by Rodrigo Mesquita at 2024-03-27T18:00:48+00:00 loader: Note down structure suggestion for needed_mods The associated ticket is #24600 - - - - - ce390488 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - 90d0101c by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Start writing test - - - - - b563544e by Alexis King at 2024-03-27T18:00:52+00:00 wip: avoid linear search when looking up Haskell symbols via dlsym - - - - - ea7bb5bf by Alexis King at 2024-03-27T18:00:52+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - 7ecaab07 by Alexis King at 2024-03-27T18:00:52+00:00 wip: use loadNativeObj to implement addDLL - - - - - a4b5376a by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - 1a59a391 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Fail if no symbol is found in the relevant DLLs - - - - - 0ec0f262 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Revert "Fail if no symbol is found in the relevant DLLs" This reverts commit c0f528199ae6000750ee0a220cebe005e24a753d. - - - - - 2d8fba19 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - b2442091 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Use lookupHsSymbol for PrimOps too - - - - - 1e525218 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - fef73688 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 Write Note [Looking up symbols in the relevant objects] - - - - - b5f4bc27 by Rodrigo Mesquita at 2024-03-27T18:00:52+00:00 VERY GOOD -3.5 seconds, instant main - - - - - 16094368 by Rodrigo Mesquita at 2024-03-27T18:00:53+00:00 Debug traces - - - - - 9df68c73 by Rodrigo Mesquita at 2024-03-27T18:00:53+00:00 Revert "Debug traces" This reverts commit 6d409089abb02ea4cf6b3334206d0eb37b3550fd. - - - - - 51c5c4eb by Rodrigo Mesquita at 2024-03-27T18:00:53+00:00 Attempt refactor ObjsLoaded instead of LinkableSet - - - - - 311fe061 by Rodrigo Mesquita at 2024-03-27T18:00:53+00:00 Revert "Attempt refactor ObjsLoaded instead of LinkableSet" This reverts commit f66191bea1e0218faefe2ce748ff604d1e549817. - - - - - d8da843f by Rodrigo Mesquita at 2024-03-27T18:02:13+00:00 Write Note [Symbols may not be found in pkgs_loaded] - - - - - 29 changed files: - + T23415/Makefile - + T23415/main.hs - + T23415/make_shared_libs.sh - + T23415/new-main.hs - + T23415/run_test.sh - compiler/GHC.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/ObjLink.hs - libraries/ghci/GHCi/Run.hs - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/include/rts/Linker.h - rts/linker/Elf.c - rts/linker/Elf.h - + rts/linker/LoadNativeObjPosix.c - + rts/linker/LoadNativeObjPosix.h - rts/linker/PEi386.c - rts/rts.cabal - testsuite/tests/ghci/linking/dyn/T3372.hs Changes: ===================================== T23415/Makefile ===================================== @@ -0,0 +1,10 @@ +.PHONY: run build clean + +run: + sh run_test.sh + +build: + sh make_shared_libs.sh + +clean: + rm -f lib*.out main main.o main.hi test.o tags ===================================== T23415/main.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +hsLoadObjs = do + cwd <- getCurrentDirectory + forM_ [0..499] $ \i -> + loadDLL (cwd "lib" ++ show i ++ ".out") + +hsLoadSymbols = do + forM_ [0..99] $ \j -> + forM_ [0..499] $ \i -> + lookupSymbol ("lib" ++ show i ++ "_" ++ show j) + +main = do + initObjLinker RetainCAFs + hsLoadObjs + hsLoadSymbols + ===================================== T23415/make_shared_libs.sh ===================================== @@ -0,0 +1,20 @@ +#!/bin/sh + +example_dylib=$(basename -- $(find $(ghc --print-libdir) -name libHS* -not -name *.a | head -n1)) +dylib_ext="${example_dylib##*.}" +# we try .out instead of using the correct extension. + +i=0 +while [ $i -lt 500 ]; do + j=0 + while [ $j -lt 100 ]; do + echo "int lib${i}_$j(void) { return $i; }" >> "lib$i.c" + j=$(( j + 1 )) + done + cc -o "lib$i.o" -c "lib$i.c" -fPIC + cc -shared "lib$i.o" -o "lib$i.out" # "lib$i.$dylib_ext" + rm "lib$i.c" "lib$i.o" + i=$(( i + 1 )) +done + + ===================================== T23415/new-main.hs ===================================== @@ -0,0 +1,29 @@ +import Data.Either +import Data.Foldable +import Data.Map as M +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +libname i = "lib" ++ show i + +hsLoadObjs = do + cwd <- getCurrentDirectory + foldrM (\i acc -> do + Right handle <- loadDLL (cwd libname i ++ ".out") + return $ M.insert (libname i) handle acc + ) + M.empty [0..499] + +hsLoadSymbols handles = do + forM_ [0..499] $ \i -> + forM_ [0..99] $ \j -> do + let symbolname = libname i ++ "_" ++ show j + lookupSymbolInDLL (handles M.! libname i) symbolname + +main = do + initObjLinker RetainCAFs + handles <- hsLoadObjs + hsLoadSymbols handles + print "hi" ===================================== T23415/run_test.sh ===================================== @@ -0,0 +1,8 @@ +#!/bin/sh + +GHC1=/Users/romes/ghc-dev/ghc/_build/stage1/bin/ghc +GHC2=/Users/romes/ghc-dev/23415/_build/stage1/bin/ghc + +# $GHC1 --interactive main.hs -package directory -package ghci -package filepath +$GHC2 --interactive new-main.hs -package directory -package ghci -package filepath -package containers + ===================================== compiler/GHC.hs ===================================== @@ -394,6 +394,7 @@ import GHC.Types.Name.Ppr import GHC.Types.TypeEnv import GHC.Types.BreakInfo import GHC.Types.PkgQual +import GHC.Types.Unique.FM import GHC.Unit import GHC.Unit.Env @@ -673,6 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger + lookup_cache <- liftIO $ newMVar emptyUFM -- Interpreter interp <- if @@ -702,7 +704,7 @@ setTopSessionDynFlags dflags = do } s <- liftIO $ newMVar InterpPending loader <- liftIO Loader.uninitializedLoader - return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader)) + return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) -- JavaScript interpreter | ArchJavaScript <- platformArch (targetPlatform dflags) @@ -720,7 +722,7 @@ setTopSessionDynFlags dflags = do , jsInterpFinderOpts = initFinderOpts dflags , jsInterpFinderCache = hsc_FC hsc_env } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader)) + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) -- Internal interpreter | otherwise @@ -728,7 +730,7 @@ setTopSessionDynFlags dflags = do #if defined(HAVE_INTERNAL_INTERPRETER) do loader <- liftIO Loader.uninitializedLoader - return (Just (Interp InternalInterp loader)) + return (Just (Interp InternalInterp loader lookup_cache)) #else return Nothing #endif ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -24,6 +24,7 @@ import GHCi.RemoteTypes import GHCi.ResolvedBCO import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Ids import GHC.Builtin.Names import GHC.Unit.Types @@ -38,6 +39,8 @@ import GHC.Utils.Outputable import GHC.Types.Name import GHC.Types.Name.Env +import qualified GHC.Types.Id as Id +import GHC.Types.Unique.DFM import Language.Haskell.Syntax.Module.Name @@ -52,31 +55,32 @@ import GHC.Exts linkBCO :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> UnlinkedBCO -> IO ResolvedBCO -linkBCO interp le bco_ix +linkBCO interp pkgs_loaded le bco_ix (UnlinkedBCO _ arity insns bitmap lits0 ptrs0) = do -- fromIntegral Word -> Word64 should be a no op if Word is Word64 -- otherwise it will result in a cast to longlong on 32bit systems. - lits <- mapM (fmap fromIntegral . lookupLiteral interp le) (ssElts lits0) - ptrs <- mapM (resolvePtr interp le bco_ix) (ssElts ptrs0) + lits <- mapM (fmap fromIntegral . lookupLiteral interp pkgs_loaded le) (ssElts lits0) + ptrs <- mapM (resolvePtr interp pkgs_loaded le bco_ix) (ssElts ptrs0) return (ResolvedBCO isLittleEndian arity insns bitmap (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) -lookupLiteral :: Interp -> LinkerEnv -> BCONPtr -> IO Word -lookupLiteral interp le ptr = case ptr of +lookupLiteral :: Interp -> PkgsLoaded -> LinkerEnv -> BCONPtr -> IO Word +lookupLiteral interp pkgs_loaded le ptr = case ptr of BCONPtrWord lit -> return lit BCONPtrLbl sym -> do Ptr a# <- lookupStaticPtr interp sym return (W# (int2Word# (addr2Int# a#))) BCONPtrItbl nm -> do - Ptr a# <- lookupIE interp (itbl_env le) nm + Ptr a# <- lookupIE interp pkgs_loaded (itbl_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrAddr nm -> do - Ptr a# <- lookupAddr interp (addr_env le) nm + Ptr a# <- lookupAddr interp pkgs_loaded (addr_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrStr _ -> -- should be eliminated during assembleBCOs @@ -90,19 +94,19 @@ lookupStaticPtr interp addr_of_label_string = do Nothing -> linkFail "GHC.ByteCode.Linker: can't find label" (unpackFS addr_of_label_string) -lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) -lookupIE interp ie con_nm = +lookupIE :: Interp -> PkgsLoaded -> ItblEnv -> Name -> IO (Ptr ()) +lookupIE interp pkgs_loaded ie con_nm = case lookupNameEnv ie con_nm of Just (_, ItblPtr a) -> return (fromRemotePtr (castRemotePtr a)) Nothing -> do -- try looking up in the object files. let sym_to_find1 = nameToCLabel con_nm "con_info" - m <- lookupSymbol interp sym_to_find1 + m <- lookupHsSymbol interp pkgs_loaded con_nm "con_info" case m of Just addr -> return addr Nothing -> do -- perhaps a nullary constructor? let sym_to_find2 = nameToCLabel con_nm "static_info" - n <- lookupSymbol interp sym_to_find2 + n <- lookupHsSymbol interp pkgs_loaded con_nm "static_info" case n of Just addr -> return addr Nothing -> linkFail "GHC.ByteCode.Linker.lookupIE" @@ -110,34 +114,35 @@ lookupIE interp ie con_nm = unpackFS sym_to_find2) -- see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode -lookupAddr :: Interp -> AddrEnv -> Name -> IO (Ptr ()) -lookupAddr interp ae addr_nm = do +lookupAddr :: Interp -> PkgsLoaded -> AddrEnv -> Name -> IO (Ptr ()) +lookupAddr interp pkgs_loaded ae addr_nm = do case lookupNameEnv ae addr_nm of Just (_, AddrPtr ptr) -> return (fromRemotePtr ptr) Nothing -> do -- try looking up in the object files. let sym_to_find = nameToCLabel addr_nm "bytes" -- see Note [Bytes label] in GHC.Cmm.CLabel - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded addr_nm "bytes" case m of Just ptr -> return ptr Nothing -> linkFail "GHC.ByteCode.Linker.lookupAddr" (unpackFS sym_to_find) -lookupPrimOp :: Interp -> PrimOp -> IO (RemotePtr ()) -lookupPrimOp interp primop = do +lookupPrimOp :: Interp -> PkgsLoaded -> PrimOp -> IO (RemotePtr ()) +lookupPrimOp interp pkgs_loaded primop = do let sym_to_find = primopToCLabel primop "closure" - m <- lookupSymbol interp (mkFastString sym_to_find) + m <- lookupHsSymbol interp pkgs_loaded (Id.idName $ primOpId primop) "closure" case m of Just p -> return (toRemotePtr p) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE(primop)" sym_to_find resolvePtr :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> BCOPtr -> IO ResolvedBCOPtr -resolvePtr interp le bco_ix ptr = case ptr of +resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of BCOPtrName nm | Just ix <- lookupNameEnv bco_ix nm -> return (ResolvedBCORef ix) -- ref to another BCO in this group @@ -149,20 +154,38 @@ resolvePtr interp le bco_ix ptr = case ptr of -> assertPpr (isExternalName nm) (ppr nm) $ do let sym_to_find = nameToCLabel nm "closure" - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded nm "closure" case m of Just p -> return (ResolvedBCOStaticPtr (toRemotePtr p)) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE" (unpackFS sym_to_find) BCOPtrPrimOp op - -> ResolvedBCOStaticPtr <$> lookupPrimOp interp op + -> ResolvedBCOStaticPtr <$> lookupPrimOp interp pkgs_loaded op BCOPtrBCO bco - -> ResolvedBCOPtrBCO <$> linkBCO interp le bco_ix bco + -> ResolvedBCOPtrBCO <$> linkBCO interp pkgs_loaded le bco_ix bco BCOPtrBreakArray breakarray -> withForeignRef breakarray $ \ba -> return (ResolvedBCOPtrBreakArray ba) +lookupHsSymbol :: Interp -> PkgsLoaded -> Name -> String -> IO (Maybe (Ptr ())) +lookupHsSymbol interp pkgs_loaded nm sym_suffix = do + massertPpr (isExternalName nm) (ppr nm) + let sym_to_find = nameToCLabel nm sym_suffix + pkg_id = moduleUnitId $ nameModule nm + loaded_dlls = maybe [] loaded_pkg_hs_dlls $ lookupUDFM pkgs_loaded pkg_id + + go (dll:dlls) = do + mb_ptr <- lookupSymbolInDLL interp dll sym_to_find + case mb_ptr of + Just ptr -> pure (Just ptr) + Nothing -> go dlls + go [] = + -- See Note [Symbols may not be found in pkgs_loaded] in GHC.Linker.Types + lookupSymbol interp sym_to_find + + go loaded_dlls + linkFail :: String -> String -> IO a linkFail who what = throwGhcExceptionIO (ProgramError $ ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -2665,7 +2665,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do case interp of -- always generate JS code for the JS interpreter (no bytecode!) - Interp (ExternalInterp (ExtJS i)) _ -> + Interp (ExternalInterp (ExtJS i)) _ _ -> jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id _ -> do ===================================== compiler/GHC/Driver/Plugins.hs ===================================== @@ -420,12 +420,12 @@ loadExternalPluginLib :: FilePath -> IO () loadExternalPluginLib path = do -- load library loadDLL path >>= \case - Just errmsg -> pprPanic "loadExternalPluginLib" - (vcat [ text "Can't load plugin library" - , text " Library path: " <> text path - , text " Error : " <> text errmsg - ]) - Nothing -> do + Left errmsg -> pprPanic "loadExternalPluginLib" + (vcat [ text "Can't load plugin library" + , text " Library path: " <> text path + , text " Error : " <> text errmsg + ]) + Right _ -> do -- TODO: use returned LoadedDLL? -- resolve objects resolveObjs >>= \case True -> return () ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -55,6 +55,7 @@ import GHC.Tc.Utils.Monad import GHC.Runtime.Interpreter import GHCi.RemoteTypes import GHC.Iface.Load +import GHCi.Message (LoadedDLL) import GHC.ByteCode.Linker import GHC.ByteCode.Asm @@ -73,6 +74,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Error import GHC.Utils.Logger +import GHC.Utils.Misc import GHC.Utils.TmpFs import GHC.Unit.Env @@ -172,7 +174,7 @@ emptyLoaderState = LoaderState -- -- The linker's symbol table is populated with RTS symbols using an -- explicit list. See rts/Linker.c for details. - where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] emptyUniqDSet) + where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] [] emptyUniqDSet) extendLoadedEnv :: Interp -> [(Name,ForeignHValue)] -> IO () extendLoadedEnv interp new_bindings = @@ -221,8 +223,8 @@ loadDependencies -> SrcSpan -> [Module] -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required +-- When called, the loader state must have been initialized (see `initLoaderState`) loadDependencies interp hsc_env pls span needed_mods = do --- initLoaderState (hsc_dflags hsc_env) dl let opts = initLinkDepsOpts hsc_env -- Find what packages and linkables are required @@ -512,25 +514,25 @@ preloadLib interp hsc_env lib_paths framework_paths pls lib_spec = do DLL dll_unadorned -> do maybe_errstr <- loadDLL interp (platformSOName platform dll_unadorned) case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm | platformOS platform /= OSDarwin -> + Right _ -> maybePutStrLn logger "done" + Left mm | platformOS platform /= OSDarwin -> preloadFailed mm lib_paths lib_spec - Just mm | otherwise -> do + Left mm | otherwise -> do -- As a backup, on Darwin, try to also load a .so file -- since (apparently) some things install that way - see -- ticket #8770. let libfile = ("lib" ++ dll_unadorned) <.> "so" err2 <- loadDLL interp libfile case err2 of - Nothing -> maybePutStrLn logger "done" - Just _ -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left _ -> preloadFailed mm lib_paths lib_spec return pls DLLPath dll_path -> do do maybe_errstr <- loadDLL interp dll_path case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left mm -> preloadFailed mm lib_paths lib_spec return pls Framework framework -> @@ -614,13 +616,14 @@ loadExpr interp hsc_env span root_ul_bco = do -- Load the necessary packages and linkables let le = linker_env pls bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)] - resolved <- linkBCO interp le bco_ix root_ul_bco + resolved <- linkBCO interp (pkgs_loaded pls) le bco_ix root_ul_bco [root_hvref] <- createBCOs interp [resolved] fhv <- mkFinalizedHValue interp root_hvref return (pls, fhv) where free_names = uniqDSetToList (bcoFreeNames root_ul_bco) + -- TODO(24600): We should be using a Set-like datatype, as this may contain lots of duplicates. needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, isExternalName n, -- Names from other modules @@ -677,7 +680,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do , addr_env = plusNameEnv (addr_env le) bc_strs } -- Link the necessary packages and linkables - new_bindings <- linkSomeBCOs interp le2 [cbc] + new_bindings <- linkSomeBCOs interp (pkgs_loaded pls) le2 [cbc] nms_fhvs <- makeForeignNamedHValueRefs interp new_bindings let ce2 = extendClosureEnv (closure_env le2) nms_fhvs !pls2 = pls { linker_env = le2 { closure_env = ce2 } } @@ -686,6 +689,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do free_names = uniqDSetToList $ foldr (unionUniqDSets . bcoFreeNames) emptyUniqDSet bc_bcos + -- TODO(24600): We should be using a Set-like datatype, as this may contain lots of duplicates. needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, isExternalName n, -- Names from other modules @@ -858,8 +862,8 @@ dynLoadObjs interp hsc_env pls at LoaderState{..} objs = do changeTempFilesLifetime tmpfs TFL_GhcSession [soFile] m <- loadDLL interp soFile case m of - Nothing -> return $! pls { temp_sos = (libPath, libName) : temp_sos } - Just err -> linkFail msg err + Right _ -> return $! pls { temp_sos = (libPath, libName) : temp_sos } + Left err -> linkFail msg err where msg = "GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed" @@ -899,7 +903,7 @@ dynLinkBCOs interp pls bcos = do ae2 = foldr plusNameEnv (addr_env le1) (map bc_strs cbcs) le2 = le1 { itbl_env = ie2, addr_env = ae2 } - names_and_refs <- linkSomeBCOs interp le2 cbcs + names_and_refs <- linkSomeBCOs interp (pkgs_loaded pls) le2 cbcs -- We only want to add the external ones to the ClosureEnv let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs @@ -914,6 +918,7 @@ dynLinkBCOs interp pls bcos = do -- Link a bunch of BCOs and return references to their values linkSomeBCOs :: Interp + -> PkgsLoaded -> LinkerEnv -> [CompiledByteCode] -> IO [(Name,HValueRef)] @@ -921,7 +926,7 @@ linkSomeBCOs :: Interp -- the incoming unlinked BCOs. Each gives the -- value of the corresponding unlinked BCO -linkSomeBCOs interp le mods = foldr fun do_link mods [] +linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] where fun CompiledByteCode{..} inner accum = inner (bc_bcos : accum) @@ -930,7 +935,8 @@ linkSomeBCOs interp le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) - resolved <- sequence [ linkBCO interp le bco_ix bco | bco <- flat ] + -- ROMES:TODO: Can we do this linkBCO sequence concurrently?! + resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) @@ -1092,18 +1098,18 @@ loadPackages' interp hsc_env new_pks pls = do -- Link dependents first ; pkgs' <- link pkgs deps -- Now link the package itself - ; (hs_cls, extra_cls) <- loadPackage interp hsc_env pkg_cfg + ; (hs_cls, extra_cls, loaded_dlls) <- loadPackage interp hsc_env pkg_cfg ; let trans_deps = unionManyUniqDSets [ addOneToUniqDSet (loaded_pkg_trans_deps loaded_pkg_info) dep_pkg | dep_pkg <- deps , Just loaded_pkg_info <- pure (lookupUDFM pkgs' dep_pkg) ] - ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls trans_deps)) } + ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls loaded_dlls trans_deps)) } | otherwise = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unpackFS (unitIdFS new_pkg))) -loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec]) +loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec], [RemotePtr LoadedDLL]) loadPackage interp hsc_env pkg = do let dflags = hsc_dflags hsc_env @@ -1145,7 +1151,9 @@ loadPackage interp hsc_env pkg let classifieds = hs_classifieds ++ extra_classifieds -- Complication: all the .so's must be loaded before any of the .o's. - let known_dlls = [ dll | DLLPath dll <- classifieds ] + let known_hs_dlls = [ dll | DLLPath dll <- hs_classifieds ] + known_extra_dlls = [ dll | DLLPath dll <- extra_classifieds ] + known_dlls = known_hs_dlls ++ known_extra_dlls #if defined(CAN_LOAD_DLL) dlls = [ dll | DLL dll <- classifieds ] #endif @@ -1166,10 +1174,13 @@ loadPackage interp hsc_env pkg loadFrameworks interp platform pkg -- See Note [Crash early load_dyn and locateLib] -- Crash early if can't load any of `known_dlls` - mapM_ (load_dyn interp hsc_env True) known_dlls + mapM_ (load_dyn interp hsc_env True) known_extra_dlls + loaded_dlls <- mapMaybeM (load_dyn interp hsc_env True) known_hs_dlls -- For remaining `dlls` crash early only when there is surely -- no package's DLL around ... (not is_dyn) mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls +#else + let loaded_dlls = [] #endif -- After loading all the DLLs, we can load the static objects. -- Ordering isn't important here, because we do one final link @@ -1189,7 +1200,7 @@ loadPackage interp hsc_env pkg if succeeded ok then do maybePutStrLn logger "done." - return (hs_classifieds, extra_classifieds) + return (hs_classifieds, extra_classifieds, loaded_dlls) else let errmsg = text "unable to load unit `" <> pprUnitInfoForUser pkg <> text "'" in throwGhcExceptionIO (InstallationError (showSDoc dflags errmsg)) @@ -1242,19 +1253,20 @@ restriction very easily. -- can be passed directly to loadDLL. They are either fully-qualified -- ("/usr/lib/libfoo.so"), or unqualified ("libfoo.so"). In the latter case, -- loadDLL is going to search the system paths to find the library. -load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO () +load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO (Maybe (RemotePtr LoadedDLL)) load_dyn interp hsc_env crash_early dll = do r <- loadDLL interp dll case r of - Nothing -> return () - Just err -> + Right loaded_dll -> pure (Just loaded_dll) + Left err -> if crash_early then cmdLineErrorIO err - else + else do when (diag_wopt Opt_WarnMissedExtraSharedLib diag_opts) $ logMsg logger (mkMCDiagnostic diag_opts (WarningWithFlag Opt_WarnMissedExtraSharedLib) Nothing) noSrcSpan $ withPprStyle defaultUserStyle (note err) + pure Nothing where diag_opts = initDiagOpts (hsc_dflags hsc_env) logger = hsc_logger hsc_env ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -172,6 +172,6 @@ loadFramework interp extraPaths rootname findLoadDLL (p:ps) errs = do { dll <- loadDLL interp (p fwk_file) ; case dll of - Nothing -> return Nothing - Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) + Right _ -> return Nothing + Left err -> findLoadDLL ps ((p ++ ": " ++ err):errs) } ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE StrictData #-} ----------------------------------------------------------------------------- -- -- Types for the linkers and the loader @@ -40,7 +41,8 @@ import GHC.Prelude import GHC.Unit ( UnitId, Module ) import GHC.ByteCode.Types ( ItblEnv, AddrEnv, CompiledByteCode ) import GHC.Fingerprint.Type ( Fingerprint ) -import GHCi.RemoteTypes ( ForeignHValue ) +import GHCi.RemoteTypes ( ForeignHValue, RemotePtr ) +import GHCi.Message ( LoadedDLL ) import GHC.Types.Var ( Id ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnvList, filterNameEnv ) @@ -75,6 +77,57 @@ initialised. The LinkerEnv maps Names to actual closures (for interpreted code only), for use during linking. + +Note [Looking up symbols in the relevant objects] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #23415, we determined that a lot of time (>10s, or even up to >35s!) was +being spent on dynamically loading symbols before actually interpreting code +when `:main` was run in GHCi. The root cause was that for each symbol we wanted +to lookup, we would traverse the list of loaded objects and try find the symbol +in each of them with dlsym (i.e. looking up a symbol was, worst case, linear in +the amount of loaded objects). + +To drastically improve load time (XXX(TODO:get better measure against 10s +baseline rather than 35second one) to <3s), we now: + +1. For every of the native objects loaded for a given unit, store the handles returned by `dlopen`. + - In `pkgs_loaded` of the `LoaderState`, which maps `UnitId`s to + `LoadedPkgInfo`s, where the handles live in its field `loaded_pkg_hs_dlls`. + +2. When looking up a Name (e.g. `lookupHsSymbol`), find that name's `UnitId` in + the `pkgs_loaded` mapping, + +3. And only look for the symbol (with `dlsym`) on the /handles relevant to that + unit/, rather than in every loaded object. + +Note [Symbols may not be found in pkgs_loaded] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Despite storing and looking for symbols in the relevant loaded libraries +handles for a given unit-id, as described in the note above, we may still have +to fallback to the "slow" `lookupSymbol` function (see its "fallback" call in +`lookupHsSymbol`). + +TODO: Ben: my understanding here is flawed; could you make this clearer?. + +This fallback is still needed because a given unit may be associated with +static objects (`loaded_pkg_hs_objs`) only and no dynamic libraries, but we +only `lookupSymbolInDLL` for loaded dynamic libraries. In that case, +`lookupSymbol` will do the right thing because, besides looking up the symbol +in every loaded dylib, it will end up searching the static name table and find those symbols. + +Arguably, we should rather generalise `lookupSymbolInDLL` to +`lookupSymbolInObject`, where an object may be a DLL/native object (as in +`loadNativeObj`), or e.g. a static archive, instead of having a special case +for dynamic libraries. + +This fallback is further needed because we don't look in the haskell objects +loaded for the home units (see the call to `loadModuleLinkables` in +`loadDependencies`, as opposed to the call to `loadPackages'` in the same +function which updates `pkgs_loaded`). We should ultimately keep track of the +objects loaded (probably in `objs_loaded`, for which `LinkableSet` is a bit +unsatisfactory, see a suggestion in 51c5c4eb1f2a33e4dc88e6a37b7b7c135234ce9b) +and be able to lookup symbols specifically in them too (similarly to +`lookupSymbolInDLL`). -} newtype Loader = Loader { loader_state :: MVar (Maybe LoaderState) } @@ -146,11 +199,13 @@ data LoadedPkgInfo { loaded_pkg_uid :: !UnitId , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] + , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] + -- ^ See Note [Looking up symbols in the relevant objects] , loaded_pkg_trans_deps :: UniqDSet UnitId } instance Outputable LoadedPkgInfo where - ppr (LoadedPkgInfo uid hs_objs non_hs_objs trans_deps) = + ppr (LoadedPkgInfo uid hs_objs non_hs_objs _ trans_deps) = vcat [ppr uid , ppr hs_objs , ppr non_hs_objs @@ -159,10 +214,10 @@ instance Outputable LoadedPkgInfo where -- | Information we can use to dynamically link modules into the compiler data Linkable = LM { - linkableTime :: !UTCTime, -- ^ Time at which this linkable was built + linkableTime :: !UTCTime, -- ^ Time at which this linkable was built -- (i.e. when the bytecodes were produced, -- or the mod date on the files) - linkableModule :: !Module, -- ^ The linkable module itself + linkableModule :: !Module, -- ^ The linkable module itself linkableUnlinked :: [Unlinked] -- ^ Those files and chunks of code we have yet to link. -- ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Runtime.Interpreter -- * The object-code linker , initObjLinker , lookupSymbol + , lookupSymbolInDLL , lookupClosure , loadDLL , loadArchive @@ -151,22 +152,22 @@ The main pieces are: - implementation of Template Haskell (GHCi.TH) - a few other things needed to run interpreted code -- top-level iserv directory, containing the codefor the external - server. This is a fairly simple wrapper, most of the functionality +- top-level iserv directory, containing the code for the external + server. This is a fairly simple wrapper, most of the functionality is provided by modules in libraries/ghci. - This module which provides the interface to the server used by the rest of GHC. -GHC works with and without -fexternal-interpreter. With the flag, all -interpreted code is run by the iserv binary. Without the flag, +GHC works with and without -fexternal-interpreter. With the flag, all +interpreted code is run by the iserv binary. Without the flag, interpreted code is run in the same process as GHC. Things that do not work with -fexternal-interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dynCompileExpr cannot work, because we have no way to run code of an -unknown type in the remote process. This API fails with an error +unknown type in the remote process. This API fails with an error message if it is used with -fexternal-interpreter. Other Notes on Remote GHCi @@ -440,57 +441,78 @@ initObjLinker :: Interp -> IO () initObjLinker interp = interpCmd interp InitLinker lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) -lookupSymbol interp str = case interpInstance interp of +lookupSymbol interp str = withSymbolCache interp str $ + case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) #endif - - ExternalInterp ext -> case ext of - ExtIServ i -> withIServ i $ \inst -> do - -- Profiling of GHCi showed a lot of time and allocation spent - -- making cross-process LookupSymbol calls, so I added a GHC-side - -- cache which sped things up quite a lot. We have to be careful - -- to purge this cache when unloading code though. - cache <- readMVar (instLookupSymbolCache inst) - case lookupUFM cache str of - Just p -> return (Just p) - Nothing -> do - m <- uninterruptibleMask_ $ - sendMessage inst (LookupSymbol (unpackFS str)) - case m of - Nothing -> return Nothing - Just r -> do - let p = fromRemotePtr r - cache' = addToUFM cache str p - modifyMVar_ (instLookupSymbolCache inst) (const (pure cache')) - return (Just p) - - ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbol (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + +lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) +lookupSymbolInDLL interp dll str = withSymbolCache interp str $ + case interpInstance interp of +#if defined(HAVE_INTERNAL_INTERPRETER) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) +#endif + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbolInDLL dll (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = interpCmd interp (LookupClosure str) +-- | 'withSymbolCache' tries to find a symbol in the 'interpLookupSymbolCache' +-- which maps symbols to the address where they are loaded. +-- When there's a cache hit we simply return the cached address, when there is +-- a miss we run the action which determines the symbol's address and populate +-- the cache with the answer. +withSymbolCache :: Interp + -> FastString + -- ^ The symbol we are looking up in the cache + -> IO (Maybe (Ptr ())) + -- ^ An action which determines the address of the symbol we + -- are looking up in the cache, which is run if there is a + -- cache miss. The result will be cached. + -> IO (Maybe (Ptr ())) +withSymbolCache interp str determine_addr = do + + -- Profiling of GHCi showed a lot of time and allocation spent + -- making cross-process LookupSymbol calls, so I added a GHC-side + -- cache which sped things up quite a lot. We have to be careful + -- to purge this cache when unloading code though. + -- + -- The analysis in #23415 further showed this cache should also benefit the + -- internal interpreter's loading times, and needn't be used by the external + -- interpreter only. + cache <- readMVar (interpLookupSymbolCache interp) + case lookupUFM cache str of + Just p -> return (Just p) + Nothing -> do + + maddr <- determine_addr + case maddr of + Nothing -> return Nothing + Just p -> do + let upd_cache cache' = addToUFM cache' str p + modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache) + return (Just p) + purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = case interpInstance interp of -#if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> pure () -#endif - ExternalInterp ext -> withExtInterpMaybe ext $ \case - Nothing -> pure () -- interpreter stopped, nothing to do - Just inst -> modifyMVar_ (instLookupSymbolCache inst) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either -- an absolute pathname to the file, or a relative filename -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. --- --- Returns: --- --- Nothing => success --- Just err_msg => failure -loadDLL :: Interp -> String -> IO (Maybe String) +loadDLL :: Interp -> String -> IO (Either String (RemotePtr LoadedDLL)) loadDLL interp str = interpCmd interp (LoadDLL str) loadArchive :: Interp -> String -> IO () @@ -549,11 +571,9 @@ spawnIServ conf = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = process , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = () } pure inst ===================================== compiler/GHC/Runtime/Interpreter/JS.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Utils.Panic import GHC.Utils.Error (logInfo) import GHC.Utils.Outputable (text) import GHC.Data.FastString -import GHC.Types.Unique.FM import Control.Concurrent import Control.Monad @@ -178,11 +177,9 @@ spawnJSInterp cfg = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = proc , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = extra } ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -51,6 +51,9 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader + + , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + -- ^ LookupSymbol cache } data InterpInstance @@ -108,9 +111,6 @@ data ExtInterpInstance c = ExtInterpInstance -- Finalizers for ForeignRefs can append values to this list -- asynchronously. - , instLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) - -- ^ LookupSymbol cache - , instExtra :: !c -- ^ Instance specific extra fields } ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -23,6 +23,7 @@ module GHCi.Message , getMessage, putMessage, getTHMessage, putTHMessage , Pipe(..), remoteCall, remoteTHCall, readPipe, writePipe , BreakModule + , LoadedDLL ) where import Prelude -- See note [Why do we import Prelude here?] @@ -73,8 +74,9 @@ data Message a where -- These all invoke the corresponding functions in the RTS Linker API. InitLinker :: Message () LookupSymbol :: String -> Message (Maybe (RemotePtr ())) + LookupSymbolInDLL :: RemotePtr LoadedDLL -> String -> Message (Maybe (RemotePtr ())) LookupClosure :: String -> Message (Maybe HValueRef) - LoadDLL :: String -> Message (Maybe String) + LoadDLL :: String -> Message (Either String (RemotePtr LoadedDLL)) LoadArchive :: String -> Message () -- error? LoadObj :: String -> Message () -- error? UnloadObj :: String -> Message () -- error? @@ -415,6 +417,9 @@ instance Binary a => Binary (EvalResult a) -- that type isn't available here. data BreakModule +-- | A dummy type that tags pointers returned by 'LoadDLL'. +data LoadedDLL + -- SomeException can't be serialized because it contains dynamic -- types. However, we do very limited things with the exceptions that -- are thrown by interpreted computations: @@ -544,6 +549,7 @@ getMessage = do 37 -> Msg <$> return RtsRevertCAFs 38 -> Msg <$> (ResumeSeq <$> get) 39 -> Msg <$> (NewBreakModule <$> get) + 40 -> Msg <$> (LookupSymbolInDLL <$> get <*> get) _ -> error $ "Unknown Message code " ++ (show b) putMessage :: Message a -> Put @@ -588,7 +594,8 @@ putMessage m = case m of Seq a -> putWord8 36 >> put a RtsRevertCAFs -> putWord8 37 ResumeSeq a -> putWord8 38 >> put a - NewBreakModule name -> putWord8 39 >> put name + NewBreakModule name -> putWord8 39 >> put name + LookupSymbolInDLL dll str -> putWord8 40 >> put dll >> put str {- Note [Parallelize CreateBCOs serialization] ===================================== libraries/ghci/GHCi/ObjLink.hs ===================================== @@ -18,6 +18,7 @@ module GHCi.ObjLink , unloadObj , purgeObj , lookupSymbol + , lookupSymbolInDLL , lookupClosure , resolveObjs , addLibrarySearchPath @@ -27,18 +28,17 @@ module GHCi.ObjLink import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes +import GHCi.Message (LoadedDLL) import Control.Exception (throwIO, ErrorCall(..)) import Control.Monad ( when ) import Foreign.C -import Foreign.Marshal.Alloc ( free ) -import Foreign ( nullPtr ) +import Foreign.Marshal.Alloc ( alloca, free ) +import Foreign ( nullPtr, peek ) import GHC.Exts import System.Posix.Internals ( CFilePath, withFilePath, peekFilePath ) import System.FilePath ( dropExtension, normalise ) - - -- --------------------------------------------------------------------------- -- RTS Linker Interface -- --------------------------------------------------------------------------- @@ -70,6 +70,15 @@ lookupSymbol str_in = do then return Nothing else return (Just addr) +lookupSymbolInDLL :: Ptr LoadedDLL -> String -> IO (Maybe (Ptr a)) +lookupSymbolInDLL dll str_in = do + let str = prefixUnderscore str_in + withCAString str $ \c_str -> do + addr <- c_lookupSymbolInNativeObj dll c_str + if addr == nullPtr + then return Nothing + else return (Just addr) + lookupClosure :: String -> IO (Maybe HValueRef) lookupClosure str = do m <- lookupSymbol str @@ -89,7 +98,7 @@ prefixUnderscore -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. -- -loadDLL :: String -> IO (Maybe String) +loadDLL :: String -> IO (Either String (Ptr LoadedDLL)) -- Nothing => success -- Just err_msg => failure loadDLL str0 = do @@ -101,12 +110,16 @@ loadDLL str0 = do str | isWindowsHost = dropExtension str0 | otherwise = str0 -- - maybe_errmsg <- withFilePath (normalise str) $ \dll -> c_addDLL dll - if maybe_errmsg == nullPtr - then return Nothing - else do str <- peekCString maybe_errmsg - free maybe_errmsg - return (Just str) + (maybe_handle, maybe_errmsg) <- withFilePath (normalise str) $ \dll -> + alloca $ \errmsg_ptr -> (,) + <$> c_loadNativeObj dll errmsg_ptr + <*> peek errmsg_ptr + + if maybe_handle == nullPtr + then do str <- peekCString maybe_errmsg + free maybe_errmsg + return (Left str) + else return (Right maybe_handle) loadArchive :: String -> IO () loadArchive str = do @@ -163,7 +176,8 @@ resolveObjs = do -- Foreign declarations to RTS entry points which does the real work; -- --------------------------------------------------------------------------- -foreign import ccall unsafe "addDLL" c_addDLL :: CFilePath -> IO CString +foreign import ccall unsafe "loadNativeObj" c_loadNativeObj :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) +foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInNativeObj :: Ptr LoadedDLL -> CString -> IO (Ptr a) foreign import ccall unsafe "initLinker_" c_initLinker_ :: CInt -> IO () foreign import ccall unsafe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) foreign import ccall unsafe "loadArchive" c_loadArchive :: CFilePath -> IO Int ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -66,7 +66,7 @@ run m = case m of LookupClosure str -> lookupJSClosure str #else InitLinker -> initObjLinker RetainCAFs - LoadDLL str -> loadDLL str + LoadDLL str -> fmap toRemotePtr <$> loadDLL str LoadArchive str -> loadArchive str LoadObj str -> loadObj str UnloadObj str -> unloadObj str @@ -81,6 +81,8 @@ run m = case m of #endif RtsRevertCAFs -> rts_revertCAFs LookupSymbol str -> fmap toRemotePtr <$> lookupSymbol str + LookupSymbolInDLL dll str -> + fmap toRemotePtr <$> lookupSymbolInDLL (fromRemotePtr dll) str FreeHValueRefs rs -> mapM_ freeRemoteRef rs AddSptEntry fpr r -> localRef r >>= sptAddEntry fpr EvalStmt opts r -> evalStmt opts r ===================================== rts/Linker.c ===================================== @@ -77,6 +77,10 @@ # include #endif +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) +# include "linker/LoadNativeObjPosix.h" +#endif + #if defined(dragonfly_HOST_OS) #include #endif @@ -130,7 +134,7 @@ extern void iconv(); - Indexing (e.g. ocVerifyImage and ocGetNames) - Initialization (e.g. ocResolve) - RunInit (e.g. ocRunInit) - - Lookup (e.g. lookupSymbol) + - Lookup (e.g. lookupSymbol/lookupSymbolInDLL) This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will @@ -419,9 +423,6 @@ static int linker_init_done = 0 ; static void *dl_prog_handle; static regex_t re_invalid; static regex_t re_realso; -#if defined(THREADED_RTS) -Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section -#endif #endif void initLinker (void) @@ -455,9 +456,6 @@ initLinker_ (int retain_cafs) #if defined(THREADED_RTS) initMutex(&linker_mutex); -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - initMutex(&dl_mutex); -#endif #endif symhash = allocStrHashTable(); @@ -520,9 +518,6 @@ exitLinker( void ) { if (linker_init_done == 1) { regfree(&re_invalid); regfree(&re_realso); -#if defined(THREADED_RTS) - closeMutex(&dl_mutex); -#endif } #endif if (linker_init_done == 1) { @@ -556,90 +551,6 @@ exitLinker( void ) { # if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -/* Suppose in ghci we load a temporary SO for a module containing - f = 1 - and then modify the module, recompile, and load another temporary - SO with - f = 2 - Then as we don't unload the first SO, dlsym will find the - f = 1 - symbol whereas we want the - f = 2 - symbol. We therefore need to keep our own SO handle list, and - try SOs in the right order. */ - -typedef - struct _OpenedSO { - struct _OpenedSO* next; - void *handle; - } - OpenedSO; - -/* A list thereof. */ -static OpenedSO* openedSOs = NULL; - -static const char * -internal_dlopen(const char *dll_name) -{ - OpenedSO* o_so; - void *hdl; - const char *errmsg; - char *errmsg_copy; - - // omitted: RTLD_NOW - // see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html - IF_DEBUG(linker, - debugBelch("internal_dlopen: dll_name = '%s'\n", dll_name)); - - //-------------- Begin critical section ------------------ - // This critical section is necessary because dlerror() is not - // required to be reentrant (see POSIX -- IEEE Std 1003.1-2008) - // Also, the error message returned must be copied to preserve it - // (see POSIX also) - - ACQUIRE_LOCK(&dl_mutex); - - // When dlopen() loads a profiled dynamic library, it calls the - // ctors which will call registerCcsList() to append the defined - // CostCentreStacks to CCS_LIST. This execution path starting from - // addDLL() was only protected by dl_mutex previously. However, - // another thread may be doing other things with the RTS linker - // that transitively calls refreshProfilingCCSs() which also - // accesses CCS_LIST, and those execution paths are protected by - // linker_mutex. So there's a risk of data race that may lead to - // segfaults (#24423), and we need to ensure the ctors are also - // protected by ccs_mutex. -#if defined(PROFILING) - ACQUIRE_LOCK(&ccs_mutex); -#endif - - hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ - -#if defined(PROFILING) - RELEASE_LOCK(&ccs_mutex); -#endif - - errmsg = NULL; - if (hdl == NULL) { - /* dlopen failed; return a ptr to the error msg. */ - errmsg = dlerror(); - if (errmsg == NULL) errmsg = "addDLL: unknown error"; - errmsg_copy = stgMallocBytes(strlen(errmsg)+1, "addDLL"); - strcpy(errmsg_copy, errmsg); - errmsg = errmsg_copy; - } else { - o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); - o_so->handle = hdl; - o_so->next = openedSOs; - openedSOs = o_so; - } - - RELEASE_LOCK(&dl_mutex); - //--------------- End critical section ------------------- - - return errmsg; -} - /* Note [RTLD_LOCAL] ~~~~~~~~~~~~~~~~~ @@ -660,11 +571,10 @@ internal_dlopen(const char *dll_name) static void * internal_dlsym(const char *symbol) { - OpenedSO* o_so; void *v; - // We acquire dl_mutex as concurrent dl* calls may alter dlerror - ACQUIRE_LOCK(&dl_mutex); + // concurrent dl* calls may alter dlerror + ASSERT_LOCK_HELD(&linker_mutex); // clears dlerror dlerror(); @@ -672,20 +582,19 @@ internal_dlsym(const char *symbol) { // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } - for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { - v = dlsym(o_so->handle, symbol); - if (dlerror() == NULL) { + for (ObjectCode *nc = loaded_objects; nc; nc = nc->next_loaded_object) { + if (nc->type == DYNAMIC_OBJECT) { + v = dlsym(nc->dlopen_handle, symbol); + if (dlerror() == NULL) { IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); - RELEASE_LOCK(&dl_mutex); return v; + } } } - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); # define SPECIAL_SYMBOL(sym) \ @@ -725,79 +634,33 @@ internal_dlsym(const char *symbol) { // we failed to find the symbol return NULL; } -# endif -const char * -addDLL( pathchar *dll_name ) +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name) { -# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - /* ------------------- ELF DLL loader ------------------- */ - -#define NMATCH 5 - regmatch_t match[NMATCH]; - const char *errmsg; - FILE* fp; - size_t match_length; -#define MAXLINE 1000 - char line[MAXLINE]; - int result; - - IF_DEBUG(linker, debugBelch("addDLL: dll_name = '%s'\n", dll_name)); - errmsg = internal_dlopen(dll_name); + ASSERT_LOCK_HELD(&linker_mutex); - if (errmsg == NULL) { - return NULL; - } +#if defined(OBJFORMAT_MACHO) + CHECK(symbol_name[0] == '_'); + symbol_name = symbol_name+1; +#endif + void *result = dlsym(handle, symbol_name); + return result; +} +# endif - // GHC #2615 - // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) - // contain linker scripts rather than ELF-format object code. This - // code handles the situation by recognizing the real object code - // file name given in the linker script. - // - // If an "invalid ELF header" error occurs, it is assumed that the - // .so file contains a linker script instead of ELF object code. - // In this case, the code looks for the GROUP ( ... ) linker - // directive. If one is found, the first file name inside the - // parentheses is treated as the name of a dynamic library and the - // code attempts to dlopen that file. If this is also unsuccessful, - // an error message is returned. - - // see if the error message is due to an invalid ELF header - IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", errmsg)); - result = regexec(&re_invalid, errmsg, (size_t) NMATCH, match, 0); - IF_DEBUG(linker, debugBelch("result = %i\n", result)); - if (result == 0) { - // success -- try to read the named file as a linker script - match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), - MAXLINE-1); - strncpy(line, (errmsg+(match[1].rm_so)),match_length); - line[match_length] = '\0'; // make sure string is null-terminated - IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); - if ((fp = __rts_fopen(line, "r")) == NULL) { - return errmsg; // return original error if open fails - } - // try to find a GROUP or INPUT ( ... ) command - while (fgets(line, MAXLINE, fp) != NULL) { - IF_DEBUG(linker, debugBelch("input line = %s", line)); - if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { - // success -- try to dlopen the first named file - IF_DEBUG(linker, debugBelch("match%s\n","")); - line[match[2].rm_eo] = '\0'; - stgFree((void*)errmsg); // Free old message before creating new one - errmsg = internal_dlopen(line+match[2].rm_so); - break; - } - // if control reaches here, no GROUP or INPUT ( ... ) directive - // was found and the original error message is returned to the - // caller - } - fclose(fp); +const char *addDLL(pathchar* dll_name) +{ +# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) + char *errmsg; + if (loadNativeObj(dll_name, &errmsg)) { + return NULL; + } else { + ASSERT(errmsg != NULL); + return errmsg; } - return errmsg; # elif defined(OBJFORMAT_PEi386) - return addDLL_PEi386(dll_name, NULL); + return addDLL_PEi386(dll_name); # else barf("addDLL: not implemented on this platform"); @@ -1229,9 +1092,10 @@ void freeObjectCode (ObjectCode *oc) if (oc->type == DYNAMIC_OBJECT) { #if defined(OBJFORMAT_ELF) - ACQUIRE_LOCK(&dl_mutex); - freeNativeCode_ELF(oc); - RELEASE_LOCK(&dl_mutex); + // ROMES:TODO: This previously acquired dl_mutex. Check that acquiring linker_mutex here is fine. + ACQUIRE_LOCK(&linker_mutex); + freeNativeCode_POSIX(oc); + RELEASE_LOCK(&linker_mutex); #else barf("freeObjectCode: This shouldn't happen"); #endif @@ -1896,12 +1760,20 @@ HsInt purgeObj (pathchar *path) return r; } +ObjectCode *lookupObjectByPath(pathchar *path) { + for (ObjectCode *o = objects; o; o = o->next) { + if (0 == pathcmp(o->fileName, path)) { + return o; + } + } + return NULL; +} + OStatus getObjectLoadStatus_ (pathchar *path) { - for (ObjectCode *o = objects; o; o = o->next) { - if (0 == pathcmp(o->fileName, path)) { - return o->status; - } + ObjectCode *oc = lookupObjectByPath(path); + if (oc) { + return oc->status; } return OBJECT_NOT_LOADED; } @@ -1988,11 +1860,21 @@ addSection (Section *s, SectionKind kind, SectionAlloc alloc, #define UNUSED(x) (void)(x) -#if defined(OBJFORMAT_ELF) +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) void * loadNativeObj (pathchar *path, char **errmsg) { + IF_DEBUG(linker, debugBelch("loadNativeObj: path = '%s'\n", path)); ACQUIRE_LOCK(&linker_mutex); - void *r = loadNativeObj_ELF(path, errmsg); + void *r = loadNativeObj_POSIX(path, errmsg); + +#if defined(OBJFORMAT_ELF) + if (!r) { + // Check if native object may be a linker script and try loading a native + // object from it + r = loadNativeObjFromLinkerScript_ELF(errmsg); + } +#endif + RELEASE_LOCK(&linker_mutex); return r; } @@ -2006,7 +1888,7 @@ loadNativeObj (pathchar *path, char **errmsg) } #endif -HsInt unloadNativeObj (void *handle) +static HsInt unloadNativeObj_(void *handle) { bool unloadedAnyObj = false; @@ -2044,6 +1926,13 @@ HsInt unloadNativeObj (void *handle) } } +HsInt unloadNativeObj(void *handle) { + ACQUIRE_LOCK(&linker_mutex); + HsInt r = unloadNativeObj_(handle); + RELEASE_LOCK(&linker_mutex); + return r; +} + /* ----------------------------------------------------------------------------- * Segment management */ ===================================== rts/LinkerInternals.h ===================================== @@ -412,10 +412,6 @@ extern Elf_Word shndx_table_uninit_label; #if defined(THREADED_RTS) extern Mutex linker_mutex; - -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -extern Mutex dl_mutex; -#endif #endif /* THREADED_RTS */ /* Type of an initializer */ @@ -515,9 +511,9 @@ HsInt loadArchive_ (pathchar *path); #define USE_CONTIGUOUS_MMAP 0 #endif - HsInt isAlreadyLoaded( pathchar *path ); OStatus getObjectLoadStatus_ (pathchar *path); +ObjectCode *lookupObjectByPath(pathchar *path); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( ObjectType type, pathchar *path, char *image, int imageSize, bool mapped, pathchar *archiveMemberName, ===================================== rts/RtsSymbols.c ===================================== @@ -619,6 +619,7 @@ extern char **environ; SymI_HasProto(purgeObj) \ SymI_HasProto(insertSymbol) \ SymI_HasProto(lookupSymbol) \ + SymI_HasProto(lookupSymbolInNativeObj) \ SymI_HasDataProto(stg_makeStablePtrzh) \ SymI_HasDataProto(stg_mkApUpd0zh) \ SymI_HasDataProto(stg_labelThreadzh) \ ===================================== rts/include/rts/Linker.h ===================================== @@ -90,8 +90,12 @@ void *loadNativeObj( pathchar *path, char **errmsg ); Takes the handle returned from loadNativeObj() as an argument. */ HsInt unloadNativeObj( void *handle ); +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name); + /* load a dynamic library */ -const char *addDLL( pathchar* dll_name ); +const char *addDLL(pathchar* dll_name); + +void *lookupSymbolInDLL(void *handle, const char *symbol_name); /* add a path to the library search path */ HsPtr addLibrarySearchPath(pathchar* dll_path); ===================================== rts/linker/Elf.c ===================================== @@ -2069,159 +2069,6 @@ int ocRunFini_ELF( ObjectCode *oc ) return true; } -/* - * Shared object loading - */ - -#if defined(HAVE_DLINFO) -struct piterate_cb_info { - ObjectCode *nc; - void *l_addr; /* base virtual address of the loaded code */ -}; - -static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size STG_UNUSED, void *data) { - struct piterate_cb_info *s = (struct piterate_cb_info *) data; - - // This logic mimicks _dl_addr_inside_object from glibc - // For reference: - // int - // internal_function - // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) - // { - // int n = l->l_phnum; - // const ElfW(Addr) reladdr = addr - l->l_addr; - // - // while (--n >= 0) - // if (l->l_phdr[n].p_type == PT_LOAD - // && reladdr - l->l_phdr[n].p_vaddr >= 0 - // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) - // return 1; - // return 0; - // } - - if ((void*) info->dlpi_addr == s->l_addr) { - int n = info->dlpi_phnum; - while (--n >= 0) { - if (info->dlpi_phdr[n].p_type == PT_LOAD) { - NativeCodeRange* ncr = - stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); - ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); - ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); - - ncr->next = s->nc->nc_ranges; - s->nc->nc_ranges = ncr; - } - } - } - return 0; -} -#endif /* defined(HAVE_DLINFO) */ - -static void copyErrmsg(char** errmsg_dest, char* errmsg) { - if (errmsg == NULL) errmsg = "loadNativeObj_ELF: unknown error"; - *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_ELF"); - strcpy(*errmsg_dest, errmsg); -} - -// need dl_mutex -void freeNativeCode_ELF (ObjectCode *nc) { - dlclose(nc->dlopen_handle); - - NativeCodeRange *ncr = nc->nc_ranges; - while (ncr) { - NativeCodeRange* last_ncr = ncr; - ncr = ncr->next; - stgFree(last_ncr); - } -} - -void * loadNativeObj_ELF (pathchar *path, char **errmsg) -{ - ObjectCode* nc; - void *hdl, *retval; - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF %" PATH_FMT "\n", path)); - - retval = NULL; - ACQUIRE_LOCK(&dl_mutex); - - /* Loading the same object multiple times will lead to chaos - * as we will have two ObjectCodes but one underlying dlopen - * handle. Fail if this happens. - */ - if (getObjectLoadStatus_(path) != OBJECT_NOT_LOADED) { - copyErrmsg(errmsg, "loadNativeObj_ELF: Already loaded"); - goto dlopen_fail; - } - - nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); - - foreignExportsLoadingObject(nc); - hdl = dlopen(path, RTLD_NOW|RTLD_LOCAL); - nc->dlopen_handle = hdl; - foreignExportsFinishedLoadingObject(); - if (hdl == NULL) { - /* dlopen failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlopen_fail; - } - -#if defined(HAVE_DLINFO) - struct link_map *map; - if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { - /* dlinfo failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlinfo_fail; - } - - hdl = NULL; // pass handle ownership to nc - - struct piterate_cb_info piterate_info = { - .nc = nc, - .l_addr = (void *) map->l_addr - }; - dl_iterate_phdr(loadNativeObjCb_, &piterate_info); - if (!nc->nc_ranges) { - copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); - goto dl_iterate_phdr_fail; - } - nc->unloadable = true; -#else - nc->nc_ranges = NULL; - nc->unloadable = false; -#endif /* defined (HAVE_DLINFO) */ - - insertOCSectionIndices(nc); - - nc->next_loaded_object = loaded_objects; - loaded_objects = nc; - - retval = nc->dlopen_handle; - -#if defined(PROFILING) - // collect any new cost centres that were defined in the loaded object. - refreshProfilingCCSs(); -#endif - - goto success; - -dl_iterate_phdr_fail: - // already have dl_mutex - freeNativeCode_ELF(nc); -dlinfo_fail: - if (hdl) dlclose(hdl); -dlopen_fail: -success: - - RELEASE_LOCK(&dl_mutex); - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF result=%p\n", retval)); - - return retval; -} - - /* * PowerPC & X86_64 ELF specifics */ @@ -2271,4 +2118,70 @@ int ocAllocateExtras_ELF( ObjectCode *oc ) #endif /* NEED_SYMBOL_EXTRAS */ +void * loadNativeObjFromLinkerScript_ELF(char **errmsg) +{ + // GHC #2615 + // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) + // contain linker scripts rather than ELF-format object code. This + // code handles the situation by recognizing the real object code + // file name given in the linker script. + // + // If an "invalid ELF header" error occurs, it is assumed that the + // .so file contains a linker script instead of ELF object code. + // In this case, the code looks for the GROUP ( ... ) linker + // directive. If one is found, the first file name inside the + // parentheses is treated as the name of a dynamic library and the + // code attempts to dlopen that file. If this is also unsuccessful, + // an error message is returned. + +#define NMATCH 5 + regmatch_t match[NMATCH]; + FILE* fp; + size_t match_length; +#define MAXLINE 1000 + char line[MAXLINE]; + int result; + void* r = NULL; + + ASSERT_LOCK_HELD(&linker_mutex) + + // see if the error message is due to an invalid ELF header + IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); + result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); + IF_DEBUG(linker, debugBelch("result = %i\n", result)); + if (result == 0) { + // success -- try to read the named file as a linker script + match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), + MAXLINE-1); + strncpy(line, (*errmsg+(match[1].rm_so)),match_length); + line[match_length] = '\0'; // make sure string is null-terminated + IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); + if ((fp = __rts_fopen(line, "r")) == NULL) { + // return original error if open fails + return NULL; + } + // try to find a GROUP or INPUT ( ... ) command + while (fgets(line, MAXLINE, fp) != NULL) { + IF_DEBUG(linker, debugBelch("input line = %s", line)); + if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { + // success -- try to dlopen the first named file + IF_DEBUG(linker, debugBelch("match%s\n","")); + line[match[2].rm_eo] = '\0'; + stgFree((void*)*errmsg); // Free old message before creating new one + // ROMES:TODO: NO GOOD, this is almost recursive? no, as long we + // move the loadNativeObj_ELF to a shared impl + r = loadNativeObj_POSIX(line+match[2].rm_so, errmsg); + break; + } + // if control reaches here, no GROUP or INPUT ( ... ) directive + // was found and the original error message is returned to the + // caller + } + fclose(fp); + } + + return r; +} + + #endif /* elf */ ===================================== rts/linker/Elf.h ===================================== @@ -14,7 +14,6 @@ int ocResolve_ELF ( ObjectCode* oc ); int ocRunInit_ELF ( ObjectCode* oc ); int ocRunFini_ELF ( ObjectCode* oc ); int ocAllocateExtras_ELF ( ObjectCode *oc ); -void freeNativeCode_ELF ( ObjectCode *nc ); -void *loadNativeObj_ELF ( pathchar *path, char **errmsg ); +void *loadNativeObjFromLinkerScript_ELF( char **errmsg ); #include "EndPrivate.h" ===================================== rts/linker/LoadNativeObjPosix.c ===================================== @@ -0,0 +1,211 @@ +#include "CheckUnload.h" +#include "ForeignExports.h" +#include "LinkerInternals.h" +#include "Rts.h" +#include "RtsUtils.h" +#include "Profiling.h" + +#include "linker/LoadNativeObjPosix.h" + +#if defined(HAVE_DLFCN_H) +#include +#endif + +#include + +#if defined(THREADED_RTS) +extern Mutex linker_mutex; +#endif + +/* + * Shared object loading + */ + +#if defined(HAVE_DLINFO) +struct piterate_cb_info { + ObjectCode *nc; + void *l_addr; /* base virtual address of the loaded code */ +}; + +static int loadNativeObjCb_(struct dl_phdr_info *info, + size_t _size STG_UNUSED, void *data) { + struct piterate_cb_info *s = (struct piterate_cb_info *) data; + + // This logic mimicks _dl_addr_inside_object from glibc + // For reference: + // int + // internal_function + // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) + // { + // int n = l->l_phnum; + // const ElfW(Addr) reladdr = addr - l->l_addr; + // + // while (--n >= 0) + // if (l->l_phdr[n].p_type == PT_LOAD + // && reladdr - l->l_phdr[n].p_vaddr >= 0 + // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) + // return 1; + // return 0; + // } + + if ((void*) info->dlpi_addr == s->l_addr) { + int n = info->dlpi_phnum; + while (--n >= 0) { + if (info->dlpi_phdr[n].p_type == PT_LOAD) { + NativeCodeRange* ncr = + stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); + ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); + ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); + + ncr->next = s->nc->nc_ranges; + s->nc->nc_ranges = ncr; + } + } + } + return 0; +} +#endif /* defined(HAVE_DLINFO) */ + +static void copyErrmsg(char** errmsg_dest, char* errmsg) { + if (errmsg == NULL) errmsg = "loadNativeObj_POSIX: unknown error"; + *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_POSIX"); + strcpy(*errmsg_dest, errmsg); +} + +void freeNativeCode_POSIX (ObjectCode *nc) { + ASSERT_LOCK_HELD(&linker_mutex); + + dlclose(nc->dlopen_handle); + + NativeCodeRange *ncr = nc->nc_ranges; + while (ncr) { + NativeCodeRange* last_ncr = ncr; + ncr = ncr->next; + stgFree(last_ncr); + } +} + +void * loadNativeObj_POSIX (pathchar *path, char **errmsg) +{ + ObjectCode* nc; + void *hdl, *retval; + + ASSERT_LOCK_HELD(&linker_mutex); + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX %" PATH_FMT "\n", path)); + + retval = NULL; + + + /* If we load the same object multiple times, just return the + * already-loaded handle. Note that this is broken if unloadNativeObj + * is used, as we don’t do any reference counting; see #24345. + */ + ObjectCode *existing_oc = lookupObjectByPath(path); + if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { + if (existing_oc->type == DYNAMIC_OBJECT) { + retval = existing_oc->dlopen_handle; + goto success; + } + copyErrmsg(errmsg, "loadNativeObj_POSIX: already loaded as non-dynamic object"); + goto dlopen_fail; + } + + nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); + + foreignExportsLoadingObject(nc); + + // When dlopen() loads a profiled dynamic library, it calls the ctors which + // will call registerCcsList() to append the defined CostCentreStacks to + // CCS_LIST. However, another thread may be doing other things with the RTS + // linker that transitively calls refreshProfilingCCSs() which also accesses + // CCS_LIST. So there's a risk of data race that may lead to segfaults + // (#24423), and we need to ensure the ctors are also protected by + // ccs_mutex. +#if defined(PROFILING) + ACQUIRE_LOCK(&ccs_mutex); +#endif + + // If we HAVE_DLINFO, we use RTLD_NOW rather than RTLD_LAZY because we want + // to learn eagerly about all external functions. Otherwise, there is no + // additional advantage to being eager, so it is better to be lazy and only bind + // functions when needed for better performance. + int dlopen_mode; +#if defined(HAVE_DLINFO) + dlopen_mode = RTLD_NOW; +#else + dlopen_mode = RTLD_LAZY; +#endif + + hdl = dlopen(path, dlopen_mode|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + nc->dlopen_handle = hdl; + nc->status = OBJECT_READY; + +#if defined(PROFILING) + RELEASE_LOCK(&ccs_mutex); +#endif + + foreignExportsFinishedLoadingObject(); + + if (hdl == NULL) { + /* dlopen failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlopen_fail; + } + +#if defined(HAVE_DLINFO) + struct link_map *map; + if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { + /* dlinfo failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlinfo_fail; + } + + hdl = NULL; // pass handle ownership to nc + + struct piterate_cb_info piterate_info = { + .nc = nc, + .l_addr = (void *) map->l_addr + }; + dl_iterate_phdr(loadNativeObjCb_, &piterate_info); + if (!nc->nc_ranges) { + copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); + goto dl_iterate_phdr_fail; + } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; +#endif /* defined (HAVE_DLINFO) */ + + insertOCSectionIndices(nc); + + nc->next_loaded_object = loaded_objects; + loaded_objects = nc; + + retval = nc->dlopen_handle; + +#if defined(PROFILING) + // collect any new cost centres that were defined in the loaded object. + refreshProfilingCCSs(); +#endif + + goto success; + +#if defined(HAVE_DLINFO) +dl_iterate_phdr_fail: +#endif + freeNativeCode_POSIX(nc); +#if defined(HAVE_DLINFO) +dlinfo_fail: +#endif + if (hdl) dlclose(hdl); +dlopen_fail: +success: + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX result=%p\n", retval)); + + return retval; +} + + ===================================== rts/linker/LoadNativeObjPosix.h ===================================== @@ -0,0 +1,11 @@ +#pragma once + +#include "Rts.h" +#include "LinkerInternals.h" + +#include "BeginPrivate.h" + +void freeNativeCode_POSIX ( ObjectCode *nc ); +void *loadNativeObj_POSIX ( pathchar *path, char **errmsg ); + +#include "EndPrivate.h" ===================================== rts/linker/PEi386.c ===================================== @@ -1865,6 +1865,7 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if (result != NULL || dllInstance == 0) { errorBelch("Could not load `%s'. Reason: %s\n", (char*)dllName, result); + stgFree((void*)result); return false; } ===================================== rts/rts.cabal ===================================== @@ -458,6 +458,7 @@ library linker/Elf.c linker/InitFini.c linker/LoadArchive.c + linker/LoadNativeObjPosix.c linker/M32Alloc.c linker/MMap.c linker/MachO.c ===================================== testsuite/tests/ghci/linking/dyn/T3372.hs ===================================== @@ -1,3 +1,6 @@ +-- Note: This test exercises running concurrent GHCi sessions, but +-- although this test is expected to pass, running concurrent GHCi +-- sessions is currently broken in other ways; see #24345. {-# LANGUAGE MagicHash #-} module Main where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fdab3e60cb3cce2b154928c29ca136cbb4f15131...d8da843f4b167e0a90bf874f505251c472a04b56 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fdab3e60cb3cce2b154928c29ca136cbb4f15131...d8da843f4b167e0a90bf874f505251c472a04b56 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 18:37:23 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 27 Mar 2024 14:37:23 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 10 commits: wip: avoid linear search when looking up Haskell symbols via dlsym Message-ID: <6604676317870_2615939caf89c1270cb@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 011538c0 by Alexis King at 2024-03-27T18:35:12+00:00 wip: avoid linear search when looking up Haskell symbols via dlsym Write Note [Looking up symbols in the relevant objects] Write Note [Symbols may not be found in pkgs_loaded] - - - - - 95dc356e by Rodrigo Mesquita at 2024-03-27T18:35:16+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - 837811a7 by Alexis King at 2024-03-27T18:35:40+00:00 wip: use loadNativeObj to implement addDLL - - - - - 38c69118 by Rodrigo Mesquita at 2024-03-27T18:35:41+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - 8366bd0d by Rodrigo Mesquita at 2024-03-27T18:36:00+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - 8aee5c5e by Rodrigo Mesquita at 2024-03-27T18:36:00+00:00 Use lookupHsSymbol for PrimOps too - - - - - 6d6ba9d9 by Rodrigo Mesquita at 2024-03-27T18:36:00+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - 974427c5 by Rodrigo Mesquita at 2024-03-27T18:36:00+00:00 This makes Main instantaneous, but needs investigation - - - - - 039a51f4 by Rodrigo Mesquita at 2024-03-27T18:36:00+00:00 Debug traces - - - - - b3de3654 by Rodrigo Mesquita at 2024-03-27T18:36:00+00:00 Revert "Debug traces" This reverts commit 6d409089abb02ea4cf6b3334206d0eb37b3550fd. - - - - - 23 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/ObjLink.hs - libraries/ghci/GHCi/Run.hs - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/include/rts/Linker.h - rts/linker/Elf.c - rts/linker/Elf.h - + rts/linker/LoadNativeObjPosix.c - + rts/linker/LoadNativeObjPosix.h - rts/rts.cabal - testsuite/tests/ghci/linking/dyn/T3372.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -394,6 +394,7 @@ import GHC.Types.Name.Ppr import GHC.Types.TypeEnv import GHC.Types.BreakInfo import GHC.Types.PkgQual +import GHC.Types.Unique.FM import GHC.Unit import GHC.Unit.Env @@ -673,6 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger + lookup_cache <- liftIO $ newMVar emptyUFM -- Interpreter interp <- if @@ -702,7 +704,7 @@ setTopSessionDynFlags dflags = do } s <- liftIO $ newMVar InterpPending loader <- liftIO Loader.uninitializedLoader - return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader)) + return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) -- JavaScript interpreter | ArchJavaScript <- platformArch (targetPlatform dflags) @@ -720,7 +722,7 @@ setTopSessionDynFlags dflags = do , jsInterpFinderOpts = initFinderOpts dflags , jsInterpFinderCache = hsc_FC hsc_env } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader)) + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) -- Internal interpreter | otherwise @@ -728,7 +730,7 @@ setTopSessionDynFlags dflags = do #if defined(HAVE_INTERNAL_INTERPRETER) do loader <- liftIO Loader.uninitializedLoader - return (Just (Interp InternalInterp loader)) + return (Just (Interp InternalInterp loader lookup_cache)) #else return Nothing #endif ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -24,6 +24,7 @@ import GHCi.RemoteTypes import GHCi.ResolvedBCO import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Ids import GHC.Builtin.Names import GHC.Unit.Types @@ -38,6 +39,8 @@ import GHC.Utils.Outputable import GHC.Types.Name import GHC.Types.Name.Env +import qualified GHC.Types.Id as Id +import GHC.Types.Unique.DFM import Language.Haskell.Syntax.Module.Name @@ -52,31 +55,32 @@ import GHC.Exts linkBCO :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> UnlinkedBCO -> IO ResolvedBCO -linkBCO interp le bco_ix +linkBCO interp pkgs_loaded le bco_ix (UnlinkedBCO _ arity insns bitmap lits0 ptrs0) = do -- fromIntegral Word -> Word64 should be a no op if Word is Word64 -- otherwise it will result in a cast to longlong on 32bit systems. - lits <- mapM (fmap fromIntegral . lookupLiteral interp le) (ssElts lits0) - ptrs <- mapM (resolvePtr interp le bco_ix) (ssElts ptrs0) + lits <- mapM (fmap fromIntegral . lookupLiteral interp pkgs_loaded le) (ssElts lits0) + ptrs <- mapM (resolvePtr interp pkgs_loaded le bco_ix) (ssElts ptrs0) return (ResolvedBCO isLittleEndian arity insns bitmap (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) -lookupLiteral :: Interp -> LinkerEnv -> BCONPtr -> IO Word -lookupLiteral interp le ptr = case ptr of +lookupLiteral :: Interp -> PkgsLoaded -> LinkerEnv -> BCONPtr -> IO Word +lookupLiteral interp pkgs_loaded le ptr = case ptr of BCONPtrWord lit -> return lit BCONPtrLbl sym -> do Ptr a# <- lookupStaticPtr interp sym return (W# (int2Word# (addr2Int# a#))) BCONPtrItbl nm -> do - Ptr a# <- lookupIE interp (itbl_env le) nm + Ptr a# <- lookupIE interp pkgs_loaded (itbl_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrAddr nm -> do - Ptr a# <- lookupAddr interp (addr_env le) nm + Ptr a# <- lookupAddr interp pkgs_loaded (addr_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrStr _ -> -- should be eliminated during assembleBCOs @@ -90,19 +94,19 @@ lookupStaticPtr interp addr_of_label_string = do Nothing -> linkFail "GHC.ByteCode.Linker: can't find label" (unpackFS addr_of_label_string) -lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) -lookupIE interp ie con_nm = +lookupIE :: Interp -> PkgsLoaded -> ItblEnv -> Name -> IO (Ptr ()) +lookupIE interp pkgs_loaded ie con_nm = case lookupNameEnv ie con_nm of Just (_, ItblPtr a) -> return (fromRemotePtr (castRemotePtr a)) Nothing -> do -- try looking up in the object files. let sym_to_find1 = nameToCLabel con_nm "con_info" - m <- lookupSymbol interp sym_to_find1 + m <- lookupHsSymbol interp pkgs_loaded con_nm "con_info" case m of Just addr -> return addr Nothing -> do -- perhaps a nullary constructor? let sym_to_find2 = nameToCLabel con_nm "static_info" - n <- lookupSymbol interp sym_to_find2 + n <- lookupHsSymbol interp pkgs_loaded con_nm "static_info" case n of Just addr -> return addr Nothing -> linkFail "GHC.ByteCode.Linker.lookupIE" @@ -110,34 +114,35 @@ lookupIE interp ie con_nm = unpackFS sym_to_find2) -- see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode -lookupAddr :: Interp -> AddrEnv -> Name -> IO (Ptr ()) -lookupAddr interp ae addr_nm = do +lookupAddr :: Interp -> PkgsLoaded -> AddrEnv -> Name -> IO (Ptr ()) +lookupAddr interp pkgs_loaded ae addr_nm = do case lookupNameEnv ae addr_nm of Just (_, AddrPtr ptr) -> return (fromRemotePtr ptr) Nothing -> do -- try looking up in the object files. let sym_to_find = nameToCLabel addr_nm "bytes" -- see Note [Bytes label] in GHC.Cmm.CLabel - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded addr_nm "bytes" case m of Just ptr -> return ptr Nothing -> linkFail "GHC.ByteCode.Linker.lookupAddr" (unpackFS sym_to_find) -lookupPrimOp :: Interp -> PrimOp -> IO (RemotePtr ()) -lookupPrimOp interp primop = do +lookupPrimOp :: Interp -> PkgsLoaded -> PrimOp -> IO (RemotePtr ()) +lookupPrimOp interp pkgs_loaded primop = do let sym_to_find = primopToCLabel primop "closure" - m <- lookupSymbol interp (mkFastString sym_to_find) + m <- lookupHsSymbol interp pkgs_loaded (Id.idName $ primOpId primop) "closure" case m of Just p -> return (toRemotePtr p) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE(primop)" sym_to_find resolvePtr :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> BCOPtr -> IO ResolvedBCOPtr -resolvePtr interp le bco_ix ptr = case ptr of +resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of BCOPtrName nm | Just ix <- lookupNameEnv bco_ix nm -> return (ResolvedBCORef ix) -- ref to another BCO in this group @@ -149,20 +154,38 @@ resolvePtr interp le bco_ix ptr = case ptr of -> assertPpr (isExternalName nm) (ppr nm) $ do let sym_to_find = nameToCLabel nm "closure" - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded nm "closure" case m of Just p -> return (ResolvedBCOStaticPtr (toRemotePtr p)) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE" (unpackFS sym_to_find) BCOPtrPrimOp op - -> ResolvedBCOStaticPtr <$> lookupPrimOp interp op + -> ResolvedBCOStaticPtr <$> lookupPrimOp interp pkgs_loaded op BCOPtrBCO bco - -> ResolvedBCOPtrBCO <$> linkBCO interp le bco_ix bco + -> ResolvedBCOPtrBCO <$> linkBCO interp pkgs_loaded le bco_ix bco BCOPtrBreakArray breakarray -> withForeignRef breakarray $ \ba -> return (ResolvedBCOPtrBreakArray ba) +lookupHsSymbol :: Interp -> PkgsLoaded -> Name -> String -> IO (Maybe (Ptr ())) +lookupHsSymbol interp pkgs_loaded nm sym_suffix = do + massertPpr (isExternalName nm) (ppr nm) + let sym_to_find = nameToCLabel nm sym_suffix + pkg_id = moduleUnitId $ nameModule nm + loaded_dlls = maybe [] loaded_pkg_hs_dlls $ lookupUDFM pkgs_loaded pkg_id + + go (dll:dlls) = do + mb_ptr <- lookupSymbolInDLL interp dll sym_to_find + case mb_ptr of + Just ptr -> pure (Just ptr) + Nothing -> go dlls + go [] = + -- See Note [Symbols may not be found in pkgs_loaded] in GHC.Linker.Types + lookupSymbol interp sym_to_find + + go loaded_dlls + linkFail :: String -> String -> IO a linkFail who what = throwGhcExceptionIO (ProgramError $ ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -2665,7 +2665,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do case interp of -- always generate JS code for the JS interpreter (no bytecode!) - Interp (ExternalInterp (ExtJS i)) _ -> + Interp (ExternalInterp (ExtJS i)) _ _ -> jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id _ -> do ===================================== compiler/GHC/Driver/Plugins.hs ===================================== @@ -420,12 +420,12 @@ loadExternalPluginLib :: FilePath -> IO () loadExternalPluginLib path = do -- load library loadDLL path >>= \case - Just errmsg -> pprPanic "loadExternalPluginLib" - (vcat [ text "Can't load plugin library" - , text " Library path: " <> text path - , text " Error : " <> text errmsg - ]) - Nothing -> do + Left errmsg -> pprPanic "loadExternalPluginLib" + (vcat [ text "Can't load plugin library" + , text " Library path: " <> text path + , text " Error : " <> text errmsg + ]) + Right _ -> do -- TODO: use returned LoadedDLL? -- resolve objects resolveObjs >>= \case True -> return () ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -55,6 +55,7 @@ import GHC.Tc.Utils.Monad import GHC.Runtime.Interpreter import GHCi.RemoteTypes import GHC.Iface.Load +import GHCi.Message (LoadedDLL) import GHC.ByteCode.Linker import GHC.ByteCode.Asm @@ -172,7 +173,7 @@ emptyLoaderState = LoaderState -- -- The linker's symbol table is populated with RTS symbols using an -- explicit list. See rts/Linker.c for details. - where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] emptyUniqDSet) + where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] [] emptyUniqDSet) extendLoadedEnv :: Interp -> [(Name,ForeignHValue)] -> IO () extendLoadedEnv interp new_bindings = @@ -221,8 +222,8 @@ loadDependencies -> SrcSpan -> [Module] -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required +-- When called, the loader state must have been initialized (see `initLoaderState`) loadDependencies interp hsc_env pls span needed_mods = do --- initLoaderState (hsc_dflags hsc_env) dl let opts = initLinkDepsOpts hsc_env -- Find what packages and linkables are required @@ -512,25 +513,25 @@ preloadLib interp hsc_env lib_paths framework_paths pls lib_spec = do DLL dll_unadorned -> do maybe_errstr <- loadDLL interp (platformSOName platform dll_unadorned) case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm | platformOS platform /= OSDarwin -> + Right _ -> maybePutStrLn logger "done" + Left mm | platformOS platform /= OSDarwin -> preloadFailed mm lib_paths lib_spec - Just mm | otherwise -> do + Left mm | otherwise -> do -- As a backup, on Darwin, try to also load a .so file -- since (apparently) some things install that way - see -- ticket #8770. let libfile = ("lib" ++ dll_unadorned) <.> "so" err2 <- loadDLL interp libfile case err2 of - Nothing -> maybePutStrLn logger "done" - Just _ -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left _ -> preloadFailed mm lib_paths lib_spec return pls DLLPath dll_path -> do do maybe_errstr <- loadDLL interp dll_path case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left mm -> preloadFailed mm lib_paths lib_spec return pls Framework framework -> @@ -614,7 +615,7 @@ loadExpr interp hsc_env span root_ul_bco = do -- Load the necessary packages and linkables let le = linker_env pls bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)] - resolved <- linkBCO interp le bco_ix root_ul_bco + resolved <- linkBCO interp (pkgs_loaded pls) le bco_ix root_ul_bco [root_hvref] <- createBCOs interp [resolved] fhv <- mkFinalizedHValue interp root_hvref return (pls, fhv) @@ -678,7 +679,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do , addr_env = plusNameEnv (addr_env le) bc_strs } -- Link the necessary packages and linkables - new_bindings <- linkSomeBCOs interp le2 [cbc] + new_bindings <- linkSomeBCOs interp (pkgs_loaded pls) le2 [cbc] nms_fhvs <- makeForeignNamedHValueRefs interp new_bindings let ce2 = extendClosureEnv (closure_env le2) nms_fhvs !pls2 = pls { linker_env = le2 { closure_env = ce2 } } @@ -860,8 +861,8 @@ dynLoadObjs interp hsc_env pls at LoaderState{..} objs = do changeTempFilesLifetime tmpfs TFL_GhcSession [soFile] m <- loadDLL interp soFile case m of - Nothing -> return $! pls { temp_sos = (libPath, libName) : temp_sos } - Just err -> linkFail msg err + Right _ -> return $! pls { temp_sos = (libPath, libName) : temp_sos } + Left err -> linkFail msg err where msg = "GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed" @@ -901,7 +902,7 @@ dynLinkBCOs interp pls bcos = do ae2 = foldr plusNameEnv (addr_env le1) (map bc_strs cbcs) le2 = le1 { itbl_env = ie2, addr_env = ae2 } - names_and_refs <- linkSomeBCOs interp le2 cbcs + names_and_refs <- linkSomeBCOs interp (pkgs_loaded pls) le2 cbcs -- We only want to add the external ones to the ClosureEnv let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs @@ -916,6 +917,7 @@ dynLinkBCOs interp pls bcos = do -- Link a bunch of BCOs and return references to their values linkSomeBCOs :: Interp + -> PkgsLoaded -> LinkerEnv -> [CompiledByteCode] -> IO [(Name,HValueRef)] @@ -923,7 +925,7 @@ linkSomeBCOs :: Interp -- the incoming unlinked BCOs. Each gives the -- value of the corresponding unlinked BCO -linkSomeBCOs interp le mods = foldr fun do_link mods [] +linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] where fun CompiledByteCode{..} inner accum = inner (bc_bcos : accum) @@ -932,7 +934,7 @@ linkSomeBCOs interp le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) - resolved <- sequence [ linkBCO interp le bco_ix bco | bco <- flat ] + resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) @@ -1094,18 +1096,18 @@ loadPackages' interp hsc_env new_pks pls = do -- Link dependents first ; pkgs' <- link pkgs deps -- Now link the package itself - ; (hs_cls, extra_cls) <- loadPackage interp hsc_env pkg_cfg + ; (hs_cls, extra_cls, loaded_dlls) <- loadPackage interp hsc_env pkg_cfg ; let trans_deps = unionManyUniqDSets [ addOneToUniqDSet (loaded_pkg_trans_deps loaded_pkg_info) dep_pkg | dep_pkg <- deps , Just loaded_pkg_info <- pure (lookupUDFM pkgs' dep_pkg) ] - ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls trans_deps)) } + ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls loaded_dlls trans_deps)) } | otherwise = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unpackFS (unitIdFS new_pkg))) -loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec]) +loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec], [RemotePtr LoadedDLL]) loadPackage interp hsc_env pkg = do let dflags = hsc_dflags hsc_env @@ -1147,7 +1149,9 @@ loadPackage interp hsc_env pkg let classifieds = hs_classifieds ++ extra_classifieds -- Complication: all the .so's must be loaded before any of the .o's. - let known_dlls = [ dll | DLLPath dll <- classifieds ] + let known_hs_dlls = [ dll | DLLPath dll <- hs_classifieds ] + known_extra_dlls = [ dll | DLLPath dll <- extra_classifieds ] + known_dlls = known_hs_dlls ++ known_extra_dlls #if defined(CAN_LOAD_DLL) dlls = [ dll | DLL dll <- classifieds ] #endif @@ -1168,10 +1172,13 @@ loadPackage interp hsc_env pkg loadFrameworks interp platform pkg -- See Note [Crash early load_dyn and locateLib] -- Crash early if can't load any of `known_dlls` - mapM_ (load_dyn interp hsc_env True) known_dlls + mapM_ (load_dyn interp hsc_env True) known_extra_dlls + loaded_dlls <- mapMaybeM (load_dyn interp hsc_env True) known_hs_dlls -- For remaining `dlls` crash early only when there is surely -- no package's DLL around ... (not is_dyn) mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls +#else + let loaded_dlls = [] #endif -- After loading all the DLLs, we can load the static objects. -- Ordering isn't important here, because we do one final link @@ -1191,7 +1198,7 @@ loadPackage interp hsc_env pkg if succeeded ok then do maybePutStrLn logger "done." - return (hs_classifieds, extra_classifieds) + return (hs_classifieds, extra_classifieds, loaded_dlls) else let errmsg = text "unable to load unit `" <> pprUnitInfoForUser pkg <> text "'" in throwGhcExceptionIO (InstallationError (showSDoc dflags errmsg)) @@ -1244,19 +1251,20 @@ restriction very easily. -- can be passed directly to loadDLL. They are either fully-qualified -- ("/usr/lib/libfoo.so"), or unqualified ("libfoo.so"). In the latter case, -- loadDLL is going to search the system paths to find the library. -load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO () +load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO (Maybe (RemotePtr LoadedDLL)) load_dyn interp hsc_env crash_early dll = do r <- loadDLL interp dll case r of - Nothing -> return () - Just err -> + Right loaded_dll -> pure (Just loaded_dll) + Left err -> if crash_early then cmdLineErrorIO err - else + else do when (diag_wopt Opt_WarnMissedExtraSharedLib diag_opts) $ logMsg logger (mkMCDiagnostic diag_opts (WarningWithFlag Opt_WarnMissedExtraSharedLib) Nothing) noSrcSpan $ withPprStyle defaultUserStyle (note err) + pure Nothing where diag_opts = initDiagOpts (hsc_dflags hsc_env) logger = hsc_logger hsc_env ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -172,6 +172,6 @@ loadFramework interp extraPaths rootname findLoadDLL (p:ps) errs = do { dll <- loadDLL interp (p fwk_file) ; case dll of - Nothing -> return Nothing - Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) + Right _ -> return Nothing + Left err -> findLoadDLL ps ((p ++ ": " ++ err):errs) } ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE StrictData #-} ----------------------------------------------------------------------------- -- -- Types for the linkers and the loader @@ -40,7 +41,8 @@ import GHC.Prelude import GHC.Unit ( UnitId, Module ) import GHC.ByteCode.Types ( ItblEnv, AddrEnv, CompiledByteCode ) import GHC.Fingerprint.Type ( Fingerprint ) -import GHCi.RemoteTypes ( ForeignHValue ) +import GHCi.RemoteTypes ( ForeignHValue, RemotePtr ) +import GHCi.Message ( LoadedDLL ) import GHC.Types.Var ( Id ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnvList, filterNameEnv ) @@ -75,6 +77,57 @@ initialised. The LinkerEnv maps Names to actual closures (for interpreted code only), for use during linking. + +Note [Looking up symbols in the relevant objects] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #23415, we determined that a lot of time (>10s, or even up to >35s!) was +being spent on dynamically loading symbols before actually interpreting code +when `:main` was run in GHCi. The root cause was that for each symbol we wanted +to lookup, we would traverse the list of loaded objects and try find the symbol +in each of them with dlsym (i.e. looking up a symbol was, worst case, linear in +the amount of loaded objects). + +To drastically improve load time (XXX(TODO:get better measure against 10s +baseline rather than 35second one) to <3s), we now: + +1. For every of the native objects loaded for a given unit, store the handles returned by `dlopen`. + - In `pkgs_loaded` of the `LoaderState`, which maps `UnitId`s to + `LoadedPkgInfo`s, where the handles live in its field `loaded_pkg_hs_dlls`. + +2. When looking up a Name (e.g. `lookupHsSymbol`), find that name's `UnitId` in + the `pkgs_loaded` mapping, + +3. And only look for the symbol (with `dlsym`) on the /handles relevant to that + unit/, rather than in every loaded object. + +Note [Symbols may not be found in pkgs_loaded] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Despite storing and looking for symbols in the relevant loaded libraries +handles for a given unit-id, as described in the note above, we may still have +to fallback to the "slow" `lookupSymbol` function (see its "fallback" call in +`lookupHsSymbol`). + +TODO: Ben: my understanding here is flawed; could you make this clearer?. + +This fallback is still needed because a given unit may be associated with +static objects (`loaded_pkg_hs_objs`) only and no dynamic libraries, but we +only `lookupSymbolInDLL` for loaded dynamic libraries. In that case, +`lookupSymbol` will do the right thing because, besides looking up the symbol +in every loaded dylib, it will end up searching the static name table and find those symbols. + +Arguably, we should rather generalise `lookupSymbolInDLL` to +`lookupSymbolInObject`, where an object may be a DLL/native object (as in +`loadNativeObj`), or e.g. a static archive, instead of having a special case +for dynamic libraries. + +This fallback is further needed because we don't look in the haskell objects +loaded for the home units (see the call to `loadModuleLinkables` in +`loadDependencies`, as opposed to the call to `loadPackages'` in the same +function which updates `pkgs_loaded`). We should ultimately keep track of the +objects loaded (probably in `objs_loaded`, for which `LinkableSet` is a bit +unsatisfactory, see a suggestion in 51c5c4eb1f2a33e4dc88e6a37b7b7c135234ce9b) +and be able to lookup symbols specifically in them too (similarly to +`lookupSymbolInDLL`). -} newtype Loader = Loader { loader_state :: MVar (Maybe LoaderState) } @@ -146,11 +199,13 @@ data LoadedPkgInfo { loaded_pkg_uid :: !UnitId , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] + , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] + -- ^ See Note [Looking up symbols in the relevant objects] , loaded_pkg_trans_deps :: UniqDSet UnitId } instance Outputable LoadedPkgInfo where - ppr (LoadedPkgInfo uid hs_objs non_hs_objs trans_deps) = + ppr (LoadedPkgInfo uid hs_objs non_hs_objs _ trans_deps) = vcat [ppr uid , ppr hs_objs , ppr non_hs_objs @@ -159,10 +214,10 @@ instance Outputable LoadedPkgInfo where -- | Information we can use to dynamically link modules into the compiler data Linkable = LM { - linkableTime :: !UTCTime, -- ^ Time at which this linkable was built + linkableTime :: !UTCTime, -- ^ Time at which this linkable was built -- (i.e. when the bytecodes were produced, -- or the mod date on the files) - linkableModule :: !Module, -- ^ The linkable module itself + linkableModule :: !Module, -- ^ The linkable module itself linkableUnlinked :: [Unlinked] -- ^ Those files and chunks of code we have yet to link. -- ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Runtime.Interpreter -- * The object-code linker , initObjLinker , lookupSymbol + , lookupSymbolInDLL , lookupClosure , loadDLL , loadArchive @@ -151,22 +152,22 @@ The main pieces are: - implementation of Template Haskell (GHCi.TH) - a few other things needed to run interpreted code -- top-level iserv directory, containing the codefor the external - server. This is a fairly simple wrapper, most of the functionality +- top-level iserv directory, containing the code for the external + server. This is a fairly simple wrapper, most of the functionality is provided by modules in libraries/ghci. - This module which provides the interface to the server used by the rest of GHC. -GHC works with and without -fexternal-interpreter. With the flag, all -interpreted code is run by the iserv binary. Without the flag, +GHC works with and without -fexternal-interpreter. With the flag, all +interpreted code is run by the iserv binary. Without the flag, interpreted code is run in the same process as GHC. Things that do not work with -fexternal-interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dynCompileExpr cannot work, because we have no way to run code of an -unknown type in the remote process. This API fails with an error +unknown type in the remote process. This API fails with an error message if it is used with -fexternal-interpreter. Other Notes on Remote GHCi @@ -440,57 +441,78 @@ initObjLinker :: Interp -> IO () initObjLinker interp = interpCmd interp InitLinker lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) -lookupSymbol interp str = case interpInstance interp of +lookupSymbol interp str = withSymbolCache interp str $ + case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) #endif - - ExternalInterp ext -> case ext of - ExtIServ i -> withIServ i $ \inst -> do - -- Profiling of GHCi showed a lot of time and allocation spent - -- making cross-process LookupSymbol calls, so I added a GHC-side - -- cache which sped things up quite a lot. We have to be careful - -- to purge this cache when unloading code though. - cache <- readMVar (instLookupSymbolCache inst) - case lookupUFM cache str of - Just p -> return (Just p) - Nothing -> do - m <- uninterruptibleMask_ $ - sendMessage inst (LookupSymbol (unpackFS str)) - case m of - Nothing -> return Nothing - Just r -> do - let p = fromRemotePtr r - cache' = addToUFM cache str p - modifyMVar_ (instLookupSymbolCache inst) (const (pure cache')) - return (Just p) - - ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbol (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + +lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) +lookupSymbolInDLL interp dll str = withSymbolCache interp str $ + case interpInstance interp of +#if defined(HAVE_INTERNAL_INTERPRETER) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) +#endif + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbolInDLL dll (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = interpCmd interp (LookupClosure str) +-- | 'withSymbolCache' tries to find a symbol in the 'interpLookupSymbolCache' +-- which maps symbols to the address where they are loaded. +-- When there's a cache hit we simply return the cached address, when there is +-- a miss we run the action which determines the symbol's address and populate +-- the cache with the answer. +withSymbolCache :: Interp + -> FastString + -- ^ The symbol we are looking up in the cache + -> IO (Maybe (Ptr ())) + -- ^ An action which determines the address of the symbol we + -- are looking up in the cache, which is run if there is a + -- cache miss. The result will be cached. + -> IO (Maybe (Ptr ())) +withSymbolCache interp str determine_addr = do + + -- Profiling of GHCi showed a lot of time and allocation spent + -- making cross-process LookupSymbol calls, so I added a GHC-side + -- cache which sped things up quite a lot. We have to be careful + -- to purge this cache when unloading code though. + -- + -- The analysis in #23415 further showed this cache should also benefit the + -- internal interpreter's loading times, and needn't be used by the external + -- interpreter only. + cache <- readMVar (interpLookupSymbolCache interp) + case lookupUFM cache str of + Just p -> return (Just p) + Nothing -> do + + maddr <- determine_addr + case maddr of + Nothing -> return Nothing + Just p -> do + let upd_cache cache' = addToUFM cache' str p + modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache) + return (Just p) + purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = case interpInstance interp of -#if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> pure () -#endif - ExternalInterp ext -> withExtInterpMaybe ext $ \case - Nothing -> pure () -- interpreter stopped, nothing to do - Just inst -> modifyMVar_ (instLookupSymbolCache inst) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either -- an absolute pathname to the file, or a relative filename -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. --- --- Returns: --- --- Nothing => success --- Just err_msg => failure -loadDLL :: Interp -> String -> IO (Maybe String) +loadDLL :: Interp -> String -> IO (Either String (RemotePtr LoadedDLL)) loadDLL interp str = interpCmd interp (LoadDLL str) loadArchive :: Interp -> String -> IO () @@ -549,11 +571,9 @@ spawnIServ conf = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = process , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = () } pure inst ===================================== compiler/GHC/Runtime/Interpreter/JS.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Utils.Panic import GHC.Utils.Error (logInfo) import GHC.Utils.Outputable (text) import GHC.Data.FastString -import GHC.Types.Unique.FM import Control.Concurrent import Control.Monad @@ -178,11 +177,9 @@ spawnJSInterp cfg = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = proc , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = extra } ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -51,6 +51,9 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader + + , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + -- ^ LookupSymbol cache } data InterpInstance @@ -108,9 +111,6 @@ data ExtInterpInstance c = ExtInterpInstance -- Finalizers for ForeignRefs can append values to this list -- asynchronously. - , instLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) - -- ^ LookupSymbol cache - , instExtra :: !c -- ^ Instance specific extra fields } ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -23,6 +23,7 @@ module GHCi.Message , getMessage, putMessage, getTHMessage, putTHMessage , Pipe(..), remoteCall, remoteTHCall, readPipe, writePipe , BreakModule + , LoadedDLL ) where import Prelude -- See note [Why do we import Prelude here?] @@ -73,8 +74,9 @@ data Message a where -- These all invoke the corresponding functions in the RTS Linker API. InitLinker :: Message () LookupSymbol :: String -> Message (Maybe (RemotePtr ())) + LookupSymbolInDLL :: RemotePtr LoadedDLL -> String -> Message (Maybe (RemotePtr ())) LookupClosure :: String -> Message (Maybe HValueRef) - LoadDLL :: String -> Message (Maybe String) + LoadDLL :: String -> Message (Either String (RemotePtr LoadedDLL)) LoadArchive :: String -> Message () -- error? LoadObj :: String -> Message () -- error? UnloadObj :: String -> Message () -- error? @@ -415,6 +417,9 @@ instance Binary a => Binary (EvalResult a) -- that type isn't available here. data BreakModule +-- | A dummy type that tags pointers returned by 'LoadDLL'. +data LoadedDLL + -- SomeException can't be serialized because it contains dynamic -- types. However, we do very limited things with the exceptions that -- are thrown by interpreted computations: @@ -544,6 +549,7 @@ getMessage = do 37 -> Msg <$> return RtsRevertCAFs 38 -> Msg <$> (ResumeSeq <$> get) 39 -> Msg <$> (NewBreakModule <$> get) + 40 -> Msg <$> (LookupSymbolInDLL <$> get <*> get) _ -> error $ "Unknown Message code " ++ (show b) putMessage :: Message a -> Put @@ -588,7 +594,8 @@ putMessage m = case m of Seq a -> putWord8 36 >> put a RtsRevertCAFs -> putWord8 37 ResumeSeq a -> putWord8 38 >> put a - NewBreakModule name -> putWord8 39 >> put name + NewBreakModule name -> putWord8 39 >> put name + LookupSymbolInDLL dll str -> putWord8 40 >> put dll >> put str {- Note [Parallelize CreateBCOs serialization] ===================================== libraries/ghci/GHCi/ObjLink.hs ===================================== @@ -18,6 +18,7 @@ module GHCi.ObjLink , unloadObj , purgeObj , lookupSymbol + , lookupSymbolInDLL , lookupClosure , resolveObjs , addLibrarySearchPath @@ -27,18 +28,17 @@ module GHCi.ObjLink import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes +import GHCi.Message (LoadedDLL) import Control.Exception (throwIO, ErrorCall(..)) import Control.Monad ( when ) import Foreign.C -import Foreign.Marshal.Alloc ( free ) -import Foreign ( nullPtr ) +import Foreign.Marshal.Alloc ( alloca, free ) +import Foreign ( nullPtr, peek ) import GHC.Exts import System.Posix.Internals ( CFilePath, withFilePath, peekFilePath ) import System.FilePath ( dropExtension, normalise ) - - -- --------------------------------------------------------------------------- -- RTS Linker Interface -- --------------------------------------------------------------------------- @@ -70,6 +70,15 @@ lookupSymbol str_in = do then return Nothing else return (Just addr) +lookupSymbolInDLL :: Ptr LoadedDLL -> String -> IO (Maybe (Ptr a)) +lookupSymbolInDLL dll str_in = do + let str = prefixUnderscore str_in + withCAString str $ \c_str -> do + addr <- c_lookupSymbolInNativeObj dll c_str + if addr == nullPtr + then return Nothing + else return (Just addr) + lookupClosure :: String -> IO (Maybe HValueRef) lookupClosure str = do m <- lookupSymbol str @@ -89,7 +98,7 @@ prefixUnderscore -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. -- -loadDLL :: String -> IO (Maybe String) +loadDLL :: String -> IO (Either String (Ptr LoadedDLL)) -- Nothing => success -- Just err_msg => failure loadDLL str0 = do @@ -101,12 +110,16 @@ loadDLL str0 = do str | isWindowsHost = dropExtension str0 | otherwise = str0 -- - maybe_errmsg <- withFilePath (normalise str) $ \dll -> c_addDLL dll - if maybe_errmsg == nullPtr - then return Nothing - else do str <- peekCString maybe_errmsg - free maybe_errmsg - return (Just str) + (maybe_handle, maybe_errmsg) <- withFilePath (normalise str) $ \dll -> + alloca $ \errmsg_ptr -> (,) + <$> c_loadNativeObj dll errmsg_ptr + <*> peek errmsg_ptr + + if maybe_handle == nullPtr + then do str <- peekCString maybe_errmsg + free maybe_errmsg + return (Left str) + else return (Right maybe_handle) loadArchive :: String -> IO () loadArchive str = do @@ -163,7 +176,8 @@ resolveObjs = do -- Foreign declarations to RTS entry points which does the real work; -- --------------------------------------------------------------------------- -foreign import ccall unsafe "addDLL" c_addDLL :: CFilePath -> IO CString +foreign import ccall unsafe "loadNativeObj" c_loadNativeObj :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) +foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInNativeObj :: Ptr LoadedDLL -> CString -> IO (Ptr a) foreign import ccall unsafe "initLinker_" c_initLinker_ :: CInt -> IO () foreign import ccall unsafe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) foreign import ccall unsafe "loadArchive" c_loadArchive :: CFilePath -> IO Int ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -66,7 +66,7 @@ run m = case m of LookupClosure str -> lookupJSClosure str #else InitLinker -> initObjLinker RetainCAFs - LoadDLL str -> loadDLL str + LoadDLL str -> fmap toRemotePtr <$> loadDLL str LoadArchive str -> loadArchive str LoadObj str -> loadObj str UnloadObj str -> unloadObj str @@ -81,6 +81,8 @@ run m = case m of #endif RtsRevertCAFs -> rts_revertCAFs LookupSymbol str -> fmap toRemotePtr <$> lookupSymbol str + LookupSymbolInDLL dll str -> + fmap toRemotePtr <$> lookupSymbolInDLL (fromRemotePtr dll) str FreeHValueRefs rs -> mapM_ freeRemoteRef rs AddSptEntry fpr r -> localRef r >>= sptAddEntry fpr EvalStmt opts r -> evalStmt opts r ===================================== rts/Linker.c ===================================== @@ -77,6 +77,10 @@ # include #endif +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) +# include "linker/LoadNativeObjPosix.h" +#endif + #if defined(dragonfly_HOST_OS) #include #endif @@ -130,7 +134,7 @@ extern void iconv(); - Indexing (e.g. ocVerifyImage and ocGetNames) - Initialization (e.g. ocResolve) - RunInit (e.g. ocRunInit) - - Lookup (e.g. lookupSymbol) + - Lookup (e.g. lookupSymbol/lookupSymbolInDLL) This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will @@ -419,9 +423,6 @@ static int linker_init_done = 0 ; static void *dl_prog_handle; static regex_t re_invalid; static regex_t re_realso; -#if defined(THREADED_RTS) -Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section -#endif #endif void initLinker (void) @@ -455,9 +456,6 @@ initLinker_ (int retain_cafs) #if defined(THREADED_RTS) initMutex(&linker_mutex); -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - initMutex(&dl_mutex); -#endif #endif symhash = allocStrHashTable(); @@ -520,9 +518,6 @@ exitLinker( void ) { if (linker_init_done == 1) { regfree(&re_invalid); regfree(&re_realso); -#if defined(THREADED_RTS) - closeMutex(&dl_mutex); -#endif } #endif if (linker_init_done == 1) { @@ -556,90 +551,6 @@ exitLinker( void ) { # if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -/* Suppose in ghci we load a temporary SO for a module containing - f = 1 - and then modify the module, recompile, and load another temporary - SO with - f = 2 - Then as we don't unload the first SO, dlsym will find the - f = 1 - symbol whereas we want the - f = 2 - symbol. We therefore need to keep our own SO handle list, and - try SOs in the right order. */ - -typedef - struct _OpenedSO { - struct _OpenedSO* next; - void *handle; - } - OpenedSO; - -/* A list thereof. */ -static OpenedSO* openedSOs = NULL; - -static const char * -internal_dlopen(const char *dll_name) -{ - OpenedSO* o_so; - void *hdl; - const char *errmsg; - char *errmsg_copy; - - // omitted: RTLD_NOW - // see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html - IF_DEBUG(linker, - debugBelch("internal_dlopen: dll_name = '%s'\n", dll_name)); - - //-------------- Begin critical section ------------------ - // This critical section is necessary because dlerror() is not - // required to be reentrant (see POSIX -- IEEE Std 1003.1-2008) - // Also, the error message returned must be copied to preserve it - // (see POSIX also) - - ACQUIRE_LOCK(&dl_mutex); - - // When dlopen() loads a profiled dynamic library, it calls the - // ctors which will call registerCcsList() to append the defined - // CostCentreStacks to CCS_LIST. This execution path starting from - // addDLL() was only protected by dl_mutex previously. However, - // another thread may be doing other things with the RTS linker - // that transitively calls refreshProfilingCCSs() which also - // accesses CCS_LIST, and those execution paths are protected by - // linker_mutex. So there's a risk of data race that may lead to - // segfaults (#24423), and we need to ensure the ctors are also - // protected by ccs_mutex. -#if defined(PROFILING) - ACQUIRE_LOCK(&ccs_mutex); -#endif - - hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ - -#if defined(PROFILING) - RELEASE_LOCK(&ccs_mutex); -#endif - - errmsg = NULL; - if (hdl == NULL) { - /* dlopen failed; return a ptr to the error msg. */ - errmsg = dlerror(); - if (errmsg == NULL) errmsg = "addDLL: unknown error"; - errmsg_copy = stgMallocBytes(strlen(errmsg)+1, "addDLL"); - strcpy(errmsg_copy, errmsg); - errmsg = errmsg_copy; - } else { - o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); - o_so->handle = hdl; - o_so->next = openedSOs; - openedSOs = o_so; - } - - RELEASE_LOCK(&dl_mutex); - //--------------- End critical section ------------------- - - return errmsg; -} - /* Note [RTLD_LOCAL] ~~~~~~~~~~~~~~~~~ @@ -660,11 +571,10 @@ internal_dlopen(const char *dll_name) static void * internal_dlsym(const char *symbol) { - OpenedSO* o_so; void *v; - // We acquire dl_mutex as concurrent dl* calls may alter dlerror - ACQUIRE_LOCK(&dl_mutex); + // concurrent dl* calls may alter dlerror + ASSERT_LOCK_HELD(&linker_mutex); // clears dlerror dlerror(); @@ -672,20 +582,19 @@ internal_dlsym(const char *symbol) { // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } - for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { - v = dlsym(o_so->handle, symbol); - if (dlerror() == NULL) { + for (ObjectCode *nc = loaded_objects; nc; nc = nc->next_loaded_object) { + if (nc->type == DYNAMIC_OBJECT) { + v = dlsym(nc->dlopen_handle, symbol); + if (dlerror() == NULL) { IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); - RELEASE_LOCK(&dl_mutex); return v; + } } } - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); # define SPECIAL_SYMBOL(sym) \ @@ -725,79 +634,33 @@ internal_dlsym(const char *symbol) { // we failed to find the symbol return NULL; } -# endif -const char * -addDLL( pathchar *dll_name ) +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name) { -# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - /* ------------------- ELF DLL loader ------------------- */ - -#define NMATCH 5 - regmatch_t match[NMATCH]; - const char *errmsg; - FILE* fp; - size_t match_length; -#define MAXLINE 1000 - char line[MAXLINE]; - int result; - - IF_DEBUG(linker, debugBelch("addDLL: dll_name = '%s'\n", dll_name)); - errmsg = internal_dlopen(dll_name); + ASSERT_LOCK_HELD(&linker_mutex); - if (errmsg == NULL) { - return NULL; - } +#if defined(OBJFORMAT_MACHO) + CHECK(symbol_name[0] == '_'); + symbol_name = symbol_name+1; +#endif + void *result = dlsym(handle, symbol_name); + return result; +} +# endif - // GHC #2615 - // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) - // contain linker scripts rather than ELF-format object code. This - // code handles the situation by recognizing the real object code - // file name given in the linker script. - // - // If an "invalid ELF header" error occurs, it is assumed that the - // .so file contains a linker script instead of ELF object code. - // In this case, the code looks for the GROUP ( ... ) linker - // directive. If one is found, the first file name inside the - // parentheses is treated as the name of a dynamic library and the - // code attempts to dlopen that file. If this is also unsuccessful, - // an error message is returned. - - // see if the error message is due to an invalid ELF header - IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", errmsg)); - result = regexec(&re_invalid, errmsg, (size_t) NMATCH, match, 0); - IF_DEBUG(linker, debugBelch("result = %i\n", result)); - if (result == 0) { - // success -- try to read the named file as a linker script - match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), - MAXLINE-1); - strncpy(line, (errmsg+(match[1].rm_so)),match_length); - line[match_length] = '\0'; // make sure string is null-terminated - IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); - if ((fp = __rts_fopen(line, "r")) == NULL) { - return errmsg; // return original error if open fails - } - // try to find a GROUP or INPUT ( ... ) command - while (fgets(line, MAXLINE, fp) != NULL) { - IF_DEBUG(linker, debugBelch("input line = %s", line)); - if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { - // success -- try to dlopen the first named file - IF_DEBUG(linker, debugBelch("match%s\n","")); - line[match[2].rm_eo] = '\0'; - stgFree((void*)errmsg); // Free old message before creating new one - errmsg = internal_dlopen(line+match[2].rm_so); - break; - } - // if control reaches here, no GROUP or INPUT ( ... ) directive - // was found and the original error message is returned to the - // caller - } - fclose(fp); +const char *addDLL(pathchar* dll_name) +{ +# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) + char *errmsg; + if (loadNativeObj(dll_name, &errmsg)) { + return NULL; + } else { + ASSERT(errmsg != NULL); + return errmsg; } - return errmsg; # elif defined(OBJFORMAT_PEi386) - return addDLL_PEi386(dll_name, NULL); + return addDLL_PEi386(dll_name); # else barf("addDLL: not implemented on this platform"); @@ -1229,9 +1092,10 @@ void freeObjectCode (ObjectCode *oc) if (oc->type == DYNAMIC_OBJECT) { #if defined(OBJFORMAT_ELF) - ACQUIRE_LOCK(&dl_mutex); - freeNativeCode_ELF(oc); - RELEASE_LOCK(&dl_mutex); + // ROMES:TODO: This previously acquired dl_mutex. Check that acquiring linker_mutex here is fine. + ACQUIRE_LOCK(&linker_mutex); + freeNativeCode_POSIX(oc); + RELEASE_LOCK(&linker_mutex); #else barf("freeObjectCode: This shouldn't happen"); #endif @@ -1896,12 +1760,20 @@ HsInt purgeObj (pathchar *path) return r; } +ObjectCode *lookupObjectByPath(pathchar *path) { + for (ObjectCode *o = objects; o; o = o->next) { + if (0 == pathcmp(o->fileName, path)) { + return o; + } + } + return NULL; +} + OStatus getObjectLoadStatus_ (pathchar *path) { - for (ObjectCode *o = objects; o; o = o->next) { - if (0 == pathcmp(o->fileName, path)) { - return o->status; - } + ObjectCode *oc = lookupObjectByPath(path); + if (oc) { + return oc->status; } return OBJECT_NOT_LOADED; } @@ -1988,11 +1860,21 @@ addSection (Section *s, SectionKind kind, SectionAlloc alloc, #define UNUSED(x) (void)(x) -#if defined(OBJFORMAT_ELF) +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) void * loadNativeObj (pathchar *path, char **errmsg) { + IF_DEBUG(linker, debugBelch("loadNativeObj: path = '%s'\n", path)); ACQUIRE_LOCK(&linker_mutex); - void *r = loadNativeObj_ELF(path, errmsg); + void *r = loadNativeObj_POSIX(path, errmsg); + +#if defined(OBJFORMAT_ELF) + if (!r) { + // Check if native object may be a linker script and try loading a native + // object from it + r = loadNativeObjFromLinkerScript_ELF(errmsg); + } +#endif + RELEASE_LOCK(&linker_mutex); return r; } @@ -2006,7 +1888,7 @@ loadNativeObj (pathchar *path, char **errmsg) } #endif -HsInt unloadNativeObj (void *handle) +static HsInt unloadNativeObj_(void *handle) { bool unloadedAnyObj = false; @@ -2044,6 +1926,13 @@ HsInt unloadNativeObj (void *handle) } } +HsInt unloadNativeObj(void *handle) { + ACQUIRE_LOCK(&linker_mutex); + HsInt r = unloadNativeObj_(handle); + RELEASE_LOCK(&linker_mutex); + return r; +} + /* ----------------------------------------------------------------------------- * Segment management */ ===================================== rts/LinkerInternals.h ===================================== @@ -412,10 +412,6 @@ extern Elf_Word shndx_table_uninit_label; #if defined(THREADED_RTS) extern Mutex linker_mutex; - -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -extern Mutex dl_mutex; -#endif #endif /* THREADED_RTS */ /* Type of an initializer */ @@ -515,9 +511,9 @@ HsInt loadArchive_ (pathchar *path); #define USE_CONTIGUOUS_MMAP 0 #endif - HsInt isAlreadyLoaded( pathchar *path ); OStatus getObjectLoadStatus_ (pathchar *path); +ObjectCode *lookupObjectByPath(pathchar *path); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( ObjectType type, pathchar *path, char *image, int imageSize, bool mapped, pathchar *archiveMemberName, ===================================== rts/RtsSymbols.c ===================================== @@ -619,6 +619,7 @@ extern char **environ; SymI_HasProto(purgeObj) \ SymI_HasProto(insertSymbol) \ SymI_HasProto(lookupSymbol) \ + SymI_HasProto(lookupSymbolInNativeObj) \ SymI_HasDataProto(stg_makeStablePtrzh) \ SymI_HasDataProto(stg_mkApUpd0zh) \ SymI_HasDataProto(stg_labelThreadzh) \ ===================================== rts/include/rts/Linker.h ===================================== @@ -90,8 +90,12 @@ void *loadNativeObj( pathchar *path, char **errmsg ); Takes the handle returned from loadNativeObj() as an argument. */ HsInt unloadNativeObj( void *handle ); +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name); + /* load a dynamic library */ -const char *addDLL( pathchar* dll_name ); +const char *addDLL(pathchar* dll_name); + +void *lookupSymbolInDLL(void *handle, const char *symbol_name); /* add a path to the library search path */ HsPtr addLibrarySearchPath(pathchar* dll_path); ===================================== rts/linker/Elf.c ===================================== @@ -2069,159 +2069,6 @@ int ocRunFini_ELF( ObjectCode *oc ) return true; } -/* - * Shared object loading - */ - -#if defined(HAVE_DLINFO) -struct piterate_cb_info { - ObjectCode *nc; - void *l_addr; /* base virtual address of the loaded code */ -}; - -static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size STG_UNUSED, void *data) { - struct piterate_cb_info *s = (struct piterate_cb_info *) data; - - // This logic mimicks _dl_addr_inside_object from glibc - // For reference: - // int - // internal_function - // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) - // { - // int n = l->l_phnum; - // const ElfW(Addr) reladdr = addr - l->l_addr; - // - // while (--n >= 0) - // if (l->l_phdr[n].p_type == PT_LOAD - // && reladdr - l->l_phdr[n].p_vaddr >= 0 - // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) - // return 1; - // return 0; - // } - - if ((void*) info->dlpi_addr == s->l_addr) { - int n = info->dlpi_phnum; - while (--n >= 0) { - if (info->dlpi_phdr[n].p_type == PT_LOAD) { - NativeCodeRange* ncr = - stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); - ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); - ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); - - ncr->next = s->nc->nc_ranges; - s->nc->nc_ranges = ncr; - } - } - } - return 0; -} -#endif /* defined(HAVE_DLINFO) */ - -static void copyErrmsg(char** errmsg_dest, char* errmsg) { - if (errmsg == NULL) errmsg = "loadNativeObj_ELF: unknown error"; - *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_ELF"); - strcpy(*errmsg_dest, errmsg); -} - -// need dl_mutex -void freeNativeCode_ELF (ObjectCode *nc) { - dlclose(nc->dlopen_handle); - - NativeCodeRange *ncr = nc->nc_ranges; - while (ncr) { - NativeCodeRange* last_ncr = ncr; - ncr = ncr->next; - stgFree(last_ncr); - } -} - -void * loadNativeObj_ELF (pathchar *path, char **errmsg) -{ - ObjectCode* nc; - void *hdl, *retval; - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF %" PATH_FMT "\n", path)); - - retval = NULL; - ACQUIRE_LOCK(&dl_mutex); - - /* Loading the same object multiple times will lead to chaos - * as we will have two ObjectCodes but one underlying dlopen - * handle. Fail if this happens. - */ - if (getObjectLoadStatus_(path) != OBJECT_NOT_LOADED) { - copyErrmsg(errmsg, "loadNativeObj_ELF: Already loaded"); - goto dlopen_fail; - } - - nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); - - foreignExportsLoadingObject(nc); - hdl = dlopen(path, RTLD_NOW|RTLD_LOCAL); - nc->dlopen_handle = hdl; - foreignExportsFinishedLoadingObject(); - if (hdl == NULL) { - /* dlopen failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlopen_fail; - } - -#if defined(HAVE_DLINFO) - struct link_map *map; - if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { - /* dlinfo failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlinfo_fail; - } - - hdl = NULL; // pass handle ownership to nc - - struct piterate_cb_info piterate_info = { - .nc = nc, - .l_addr = (void *) map->l_addr - }; - dl_iterate_phdr(loadNativeObjCb_, &piterate_info); - if (!nc->nc_ranges) { - copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); - goto dl_iterate_phdr_fail; - } - nc->unloadable = true; -#else - nc->nc_ranges = NULL; - nc->unloadable = false; -#endif /* defined (HAVE_DLINFO) */ - - insertOCSectionIndices(nc); - - nc->next_loaded_object = loaded_objects; - loaded_objects = nc; - - retval = nc->dlopen_handle; - -#if defined(PROFILING) - // collect any new cost centres that were defined in the loaded object. - refreshProfilingCCSs(); -#endif - - goto success; - -dl_iterate_phdr_fail: - // already have dl_mutex - freeNativeCode_ELF(nc); -dlinfo_fail: - if (hdl) dlclose(hdl); -dlopen_fail: -success: - - RELEASE_LOCK(&dl_mutex); - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF result=%p\n", retval)); - - return retval; -} - - /* * PowerPC & X86_64 ELF specifics */ @@ -2271,4 +2118,70 @@ int ocAllocateExtras_ELF( ObjectCode *oc ) #endif /* NEED_SYMBOL_EXTRAS */ +void * loadNativeObjFromLinkerScript_ELF(char **errmsg) +{ + // GHC #2615 + // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) + // contain linker scripts rather than ELF-format object code. This + // code handles the situation by recognizing the real object code + // file name given in the linker script. + // + // If an "invalid ELF header" error occurs, it is assumed that the + // .so file contains a linker script instead of ELF object code. + // In this case, the code looks for the GROUP ( ... ) linker + // directive. If one is found, the first file name inside the + // parentheses is treated as the name of a dynamic library and the + // code attempts to dlopen that file. If this is also unsuccessful, + // an error message is returned. + +#define NMATCH 5 + regmatch_t match[NMATCH]; + FILE* fp; + size_t match_length; +#define MAXLINE 1000 + char line[MAXLINE]; + int result; + void* r = NULL; + + ASSERT_LOCK_HELD(&linker_mutex) + + // see if the error message is due to an invalid ELF header + IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); + result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); + IF_DEBUG(linker, debugBelch("result = %i\n", result)); + if (result == 0) { + // success -- try to read the named file as a linker script + match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), + MAXLINE-1); + strncpy(line, (*errmsg+(match[1].rm_so)),match_length); + line[match_length] = '\0'; // make sure string is null-terminated + IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); + if ((fp = __rts_fopen(line, "r")) == NULL) { + // return original error if open fails + return NULL; + } + // try to find a GROUP or INPUT ( ... ) command + while (fgets(line, MAXLINE, fp) != NULL) { + IF_DEBUG(linker, debugBelch("input line = %s", line)); + if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { + // success -- try to dlopen the first named file + IF_DEBUG(linker, debugBelch("match%s\n","")); + line[match[2].rm_eo] = '\0'; + stgFree((void*)*errmsg); // Free old message before creating new one + // ROMES:TODO: NO GOOD, this is almost recursive? no, as long we + // move the loadNativeObj_ELF to a shared impl + r = loadNativeObj_POSIX(line+match[2].rm_so, errmsg); + break; + } + // if control reaches here, no GROUP or INPUT ( ... ) directive + // was found and the original error message is returned to the + // caller + } + fclose(fp); + } + + return r; +} + + #endif /* elf */ ===================================== rts/linker/Elf.h ===================================== @@ -14,7 +14,6 @@ int ocResolve_ELF ( ObjectCode* oc ); int ocRunInit_ELF ( ObjectCode* oc ); int ocRunFini_ELF ( ObjectCode* oc ); int ocAllocateExtras_ELF ( ObjectCode *oc ); -void freeNativeCode_ELF ( ObjectCode *nc ); -void *loadNativeObj_ELF ( pathchar *path, char **errmsg ); +void *loadNativeObjFromLinkerScript_ELF( char **errmsg ); #include "EndPrivate.h" ===================================== rts/linker/LoadNativeObjPosix.c ===================================== @@ -0,0 +1,211 @@ +#include "CheckUnload.h" +#include "ForeignExports.h" +#include "LinkerInternals.h" +#include "Rts.h" +#include "RtsUtils.h" +#include "Profiling.h" + +#include "linker/LoadNativeObjPosix.h" + +#if defined(HAVE_DLFCN_H) +#include +#endif + +#include + +#if defined(THREADED_RTS) +extern Mutex linker_mutex; +#endif + +/* + * Shared object loading + */ + +#if defined(HAVE_DLINFO) +struct piterate_cb_info { + ObjectCode *nc; + void *l_addr; /* base virtual address of the loaded code */ +}; + +static int loadNativeObjCb_(struct dl_phdr_info *info, + size_t _size STG_UNUSED, void *data) { + struct piterate_cb_info *s = (struct piterate_cb_info *) data; + + // This logic mimicks _dl_addr_inside_object from glibc + // For reference: + // int + // internal_function + // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) + // { + // int n = l->l_phnum; + // const ElfW(Addr) reladdr = addr - l->l_addr; + // + // while (--n >= 0) + // if (l->l_phdr[n].p_type == PT_LOAD + // && reladdr - l->l_phdr[n].p_vaddr >= 0 + // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) + // return 1; + // return 0; + // } + + if ((void*) info->dlpi_addr == s->l_addr) { + int n = info->dlpi_phnum; + while (--n >= 0) { + if (info->dlpi_phdr[n].p_type == PT_LOAD) { + NativeCodeRange* ncr = + stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); + ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); + ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); + + ncr->next = s->nc->nc_ranges; + s->nc->nc_ranges = ncr; + } + } + } + return 0; +} +#endif /* defined(HAVE_DLINFO) */ + +static void copyErrmsg(char** errmsg_dest, char* errmsg) { + if (errmsg == NULL) errmsg = "loadNativeObj_POSIX: unknown error"; + *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_POSIX"); + strcpy(*errmsg_dest, errmsg); +} + +void freeNativeCode_POSIX (ObjectCode *nc) { + ASSERT_LOCK_HELD(&linker_mutex); + + dlclose(nc->dlopen_handle); + + NativeCodeRange *ncr = nc->nc_ranges; + while (ncr) { + NativeCodeRange* last_ncr = ncr; + ncr = ncr->next; + stgFree(last_ncr); + } +} + +void * loadNativeObj_POSIX (pathchar *path, char **errmsg) +{ + ObjectCode* nc; + void *hdl, *retval; + + ASSERT_LOCK_HELD(&linker_mutex); + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX %" PATH_FMT "\n", path)); + + retval = NULL; + + + /* If we load the same object multiple times, just return the + * already-loaded handle. Note that this is broken if unloadNativeObj + * is used, as we don’t do any reference counting; see #24345. + */ + ObjectCode *existing_oc = lookupObjectByPath(path); + if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { + if (existing_oc->type == DYNAMIC_OBJECT) { + retval = existing_oc->dlopen_handle; + goto success; + } + copyErrmsg(errmsg, "loadNativeObj_POSIX: already loaded as non-dynamic object"); + goto dlopen_fail; + } + + nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); + + foreignExportsLoadingObject(nc); + + // When dlopen() loads a profiled dynamic library, it calls the ctors which + // will call registerCcsList() to append the defined CostCentreStacks to + // CCS_LIST. However, another thread may be doing other things with the RTS + // linker that transitively calls refreshProfilingCCSs() which also accesses + // CCS_LIST. So there's a risk of data race that may lead to segfaults + // (#24423), and we need to ensure the ctors are also protected by + // ccs_mutex. +#if defined(PROFILING) + ACQUIRE_LOCK(&ccs_mutex); +#endif + + // If we HAVE_DLINFO, we use RTLD_NOW rather than RTLD_LAZY because we want + // to learn eagerly about all external functions. Otherwise, there is no + // additional advantage to being eager, so it is better to be lazy and only bind + // functions when needed for better performance. + int dlopen_mode; +#if defined(HAVE_DLINFO) + dlopen_mode = RTLD_NOW; +#else + dlopen_mode = RTLD_LAZY; +#endif + + hdl = dlopen(path, dlopen_mode|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + nc->dlopen_handle = hdl; + nc->status = OBJECT_READY; + +#if defined(PROFILING) + RELEASE_LOCK(&ccs_mutex); +#endif + + foreignExportsFinishedLoadingObject(); + + if (hdl == NULL) { + /* dlopen failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlopen_fail; + } + +#if defined(HAVE_DLINFO) + struct link_map *map; + if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { + /* dlinfo failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlinfo_fail; + } + + hdl = NULL; // pass handle ownership to nc + + struct piterate_cb_info piterate_info = { + .nc = nc, + .l_addr = (void *) map->l_addr + }; + dl_iterate_phdr(loadNativeObjCb_, &piterate_info); + if (!nc->nc_ranges) { + copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); + goto dl_iterate_phdr_fail; + } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; +#endif /* defined (HAVE_DLINFO) */ + + insertOCSectionIndices(nc); + + nc->next_loaded_object = loaded_objects; + loaded_objects = nc; + + retval = nc->dlopen_handle; + +#if defined(PROFILING) + // collect any new cost centres that were defined in the loaded object. + refreshProfilingCCSs(); +#endif + + goto success; + +#if defined(HAVE_DLINFO) +dl_iterate_phdr_fail: +#endif + freeNativeCode_POSIX(nc); +#if defined(HAVE_DLINFO) +dlinfo_fail: +#endif + if (hdl) dlclose(hdl); +dlopen_fail: +success: + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX result=%p\n", retval)); + + return retval; +} + + ===================================== rts/linker/LoadNativeObjPosix.h ===================================== @@ -0,0 +1,11 @@ +#pragma once + +#include "Rts.h" +#include "LinkerInternals.h" + +#include "BeginPrivate.h" + +void freeNativeCode_POSIX ( ObjectCode *nc ); +void *loadNativeObj_POSIX ( pathchar *path, char **errmsg ); + +#include "EndPrivate.h" ===================================== rts/rts.cabal ===================================== @@ -458,6 +458,7 @@ library linker/Elf.c linker/InitFini.c linker/LoadArchive.c + linker/LoadNativeObjPosix.c linker/M32Alloc.c linker/MMap.c linker/MachO.c ===================================== testsuite/tests/ghci/linking/dyn/T3372.hs ===================================== @@ -1,3 +1,6 @@ +-- Note: This test exercises running concurrent GHCi sessions, but +-- although this test is expected to pass, running concurrent GHCi +-- sessions is currently broken in other ways; see #24345. {-# LANGUAGE MagicHash #-} module Main where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8da843f4b167e0a90bf874f505251c472a04b56...b3de3654dfdf9851658f5ba011a82b062558d12f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8da843f4b167e0a90bf874f505251c472a04b56...b3de3654dfdf9851658f5ba011a82b062558d12f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 18:39:26 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 27 Mar 2024 14:39:26 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 9 commits: linker: Avoid linear search when looking up Haskell symbols via dlsym Message-ID: <660467de2e9_2615939f9753c1274ee@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 0c063581 by Alexis King at 2024-03-27T18:37:32+00:00 linker: Avoid linear search when looking up Haskell symbols via dlsym Write Note [Looking up symbols in the relevant objects] Write Note [Symbols may not be found in pkgs_loaded] Use lookupHsSymbol for PrimOps too - - - - - 90235de5 by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - a42bf56b by Alexis King at 2024-03-27T18:37:40+00:00 wip: use loadNativeObj to implement addDLL - - - - - 120b9d9c by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - b861d58d by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - 9a7128d1 by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - ad1dac8b by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 This makes Main instantaneous, but needs investigation - - - - - b0861ada by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 Debug traces - - - - - f6998277 by Rodrigo Mesquita at 2024-03-27T18:37:40+00:00 Revert "Debug traces" This reverts commit 6d409089abb02ea4cf6b3334206d0eb37b3550fd. - - - - - 23 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/ObjLink.hs - libraries/ghci/GHCi/Run.hs - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/include/rts/Linker.h - rts/linker/Elf.c - rts/linker/Elf.h - + rts/linker/LoadNativeObjPosix.c - + rts/linker/LoadNativeObjPosix.h - rts/rts.cabal - testsuite/tests/ghci/linking/dyn/T3372.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -394,6 +394,7 @@ import GHC.Types.Name.Ppr import GHC.Types.TypeEnv import GHC.Types.BreakInfo import GHC.Types.PkgQual +import GHC.Types.Unique.FM import GHC.Unit import GHC.Unit.Env @@ -673,6 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger + lookup_cache <- liftIO $ newMVar emptyUFM -- Interpreter interp <- if @@ -702,7 +704,7 @@ setTopSessionDynFlags dflags = do } s <- liftIO $ newMVar InterpPending loader <- liftIO Loader.uninitializedLoader - return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader)) + return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) -- JavaScript interpreter | ArchJavaScript <- platformArch (targetPlatform dflags) @@ -720,7 +722,7 @@ setTopSessionDynFlags dflags = do , jsInterpFinderOpts = initFinderOpts dflags , jsInterpFinderCache = hsc_FC hsc_env } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader)) + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) -- Internal interpreter | otherwise @@ -728,7 +730,7 @@ setTopSessionDynFlags dflags = do #if defined(HAVE_INTERNAL_INTERPRETER) do loader <- liftIO Loader.uninitializedLoader - return (Just (Interp InternalInterp loader)) + return (Just (Interp InternalInterp loader lookup_cache)) #else return Nothing #endif ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -24,6 +24,7 @@ import GHCi.RemoteTypes import GHCi.ResolvedBCO import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Ids import GHC.Builtin.Names import GHC.Unit.Types @@ -38,6 +39,8 @@ import GHC.Utils.Outputable import GHC.Types.Name import GHC.Types.Name.Env +import qualified GHC.Types.Id as Id +import GHC.Types.Unique.DFM import Language.Haskell.Syntax.Module.Name @@ -52,31 +55,32 @@ import GHC.Exts linkBCO :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> UnlinkedBCO -> IO ResolvedBCO -linkBCO interp le bco_ix +linkBCO interp pkgs_loaded le bco_ix (UnlinkedBCO _ arity insns bitmap lits0 ptrs0) = do -- fromIntegral Word -> Word64 should be a no op if Word is Word64 -- otherwise it will result in a cast to longlong on 32bit systems. - lits <- mapM (fmap fromIntegral . lookupLiteral interp le) (ssElts lits0) - ptrs <- mapM (resolvePtr interp le bco_ix) (ssElts ptrs0) + lits <- mapM (fmap fromIntegral . lookupLiteral interp pkgs_loaded le) (ssElts lits0) + ptrs <- mapM (resolvePtr interp pkgs_loaded le bco_ix) (ssElts ptrs0) return (ResolvedBCO isLittleEndian arity insns bitmap (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) -lookupLiteral :: Interp -> LinkerEnv -> BCONPtr -> IO Word -lookupLiteral interp le ptr = case ptr of +lookupLiteral :: Interp -> PkgsLoaded -> LinkerEnv -> BCONPtr -> IO Word +lookupLiteral interp pkgs_loaded le ptr = case ptr of BCONPtrWord lit -> return lit BCONPtrLbl sym -> do Ptr a# <- lookupStaticPtr interp sym return (W# (int2Word# (addr2Int# a#))) BCONPtrItbl nm -> do - Ptr a# <- lookupIE interp (itbl_env le) nm + Ptr a# <- lookupIE interp pkgs_loaded (itbl_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrAddr nm -> do - Ptr a# <- lookupAddr interp (addr_env le) nm + Ptr a# <- lookupAddr interp pkgs_loaded (addr_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrStr _ -> -- should be eliminated during assembleBCOs @@ -90,19 +94,19 @@ lookupStaticPtr interp addr_of_label_string = do Nothing -> linkFail "GHC.ByteCode.Linker: can't find label" (unpackFS addr_of_label_string) -lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) -lookupIE interp ie con_nm = +lookupIE :: Interp -> PkgsLoaded -> ItblEnv -> Name -> IO (Ptr ()) +lookupIE interp pkgs_loaded ie con_nm = case lookupNameEnv ie con_nm of Just (_, ItblPtr a) -> return (fromRemotePtr (castRemotePtr a)) Nothing -> do -- try looking up in the object files. let sym_to_find1 = nameToCLabel con_nm "con_info" - m <- lookupSymbol interp sym_to_find1 + m <- lookupHsSymbol interp pkgs_loaded con_nm "con_info" case m of Just addr -> return addr Nothing -> do -- perhaps a nullary constructor? let sym_to_find2 = nameToCLabel con_nm "static_info" - n <- lookupSymbol interp sym_to_find2 + n <- lookupHsSymbol interp pkgs_loaded con_nm "static_info" case n of Just addr -> return addr Nothing -> linkFail "GHC.ByteCode.Linker.lookupIE" @@ -110,34 +114,35 @@ lookupIE interp ie con_nm = unpackFS sym_to_find2) -- see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode -lookupAddr :: Interp -> AddrEnv -> Name -> IO (Ptr ()) -lookupAddr interp ae addr_nm = do +lookupAddr :: Interp -> PkgsLoaded -> AddrEnv -> Name -> IO (Ptr ()) +lookupAddr interp pkgs_loaded ae addr_nm = do case lookupNameEnv ae addr_nm of Just (_, AddrPtr ptr) -> return (fromRemotePtr ptr) Nothing -> do -- try looking up in the object files. let sym_to_find = nameToCLabel addr_nm "bytes" -- see Note [Bytes label] in GHC.Cmm.CLabel - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded addr_nm "bytes" case m of Just ptr -> return ptr Nothing -> linkFail "GHC.ByteCode.Linker.lookupAddr" (unpackFS sym_to_find) -lookupPrimOp :: Interp -> PrimOp -> IO (RemotePtr ()) -lookupPrimOp interp primop = do +lookupPrimOp :: Interp -> PkgsLoaded -> PrimOp -> IO (RemotePtr ()) +lookupPrimOp interp pkgs_loaded primop = do let sym_to_find = primopToCLabel primop "closure" - m <- lookupSymbol interp (mkFastString sym_to_find) + m <- lookupHsSymbol interp pkgs_loaded (Id.idName $ primOpId primop) "closure" case m of Just p -> return (toRemotePtr p) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE(primop)" sym_to_find resolvePtr :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> BCOPtr -> IO ResolvedBCOPtr -resolvePtr interp le bco_ix ptr = case ptr of +resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of BCOPtrName nm | Just ix <- lookupNameEnv bco_ix nm -> return (ResolvedBCORef ix) -- ref to another BCO in this group @@ -149,20 +154,38 @@ resolvePtr interp le bco_ix ptr = case ptr of -> assertPpr (isExternalName nm) (ppr nm) $ do let sym_to_find = nameToCLabel nm "closure" - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded nm "closure" case m of Just p -> return (ResolvedBCOStaticPtr (toRemotePtr p)) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE" (unpackFS sym_to_find) BCOPtrPrimOp op - -> ResolvedBCOStaticPtr <$> lookupPrimOp interp op + -> ResolvedBCOStaticPtr <$> lookupPrimOp interp pkgs_loaded op BCOPtrBCO bco - -> ResolvedBCOPtrBCO <$> linkBCO interp le bco_ix bco + -> ResolvedBCOPtrBCO <$> linkBCO interp pkgs_loaded le bco_ix bco BCOPtrBreakArray breakarray -> withForeignRef breakarray $ \ba -> return (ResolvedBCOPtrBreakArray ba) +lookupHsSymbol :: Interp -> PkgsLoaded -> Name -> String -> IO (Maybe (Ptr ())) +lookupHsSymbol interp pkgs_loaded nm sym_suffix = do + massertPpr (isExternalName nm) (ppr nm) + let sym_to_find = nameToCLabel nm sym_suffix + pkg_id = moduleUnitId $ nameModule nm + loaded_dlls = maybe [] loaded_pkg_hs_dlls $ lookupUDFM pkgs_loaded pkg_id + + go (dll:dlls) = do + mb_ptr <- lookupSymbolInDLL interp dll sym_to_find + case mb_ptr of + Just ptr -> pure (Just ptr) + Nothing -> go dlls + go [] = + -- See Note [Symbols may not be found in pkgs_loaded] in GHC.Linker.Types + lookupSymbol interp sym_to_find + + go loaded_dlls + linkFail :: String -> String -> IO a linkFail who what = throwGhcExceptionIO (ProgramError $ ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -2665,7 +2665,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do case interp of -- always generate JS code for the JS interpreter (no bytecode!) - Interp (ExternalInterp (ExtJS i)) _ -> + Interp (ExternalInterp (ExtJS i)) _ _ -> jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id _ -> do ===================================== compiler/GHC/Driver/Plugins.hs ===================================== @@ -420,12 +420,12 @@ loadExternalPluginLib :: FilePath -> IO () loadExternalPluginLib path = do -- load library loadDLL path >>= \case - Just errmsg -> pprPanic "loadExternalPluginLib" - (vcat [ text "Can't load plugin library" - , text " Library path: " <> text path - , text " Error : " <> text errmsg - ]) - Nothing -> do + Left errmsg -> pprPanic "loadExternalPluginLib" + (vcat [ text "Can't load plugin library" + , text " Library path: " <> text path + , text " Error : " <> text errmsg + ]) + Right _ -> do -- TODO: use returned LoadedDLL? -- resolve objects resolveObjs >>= \case True -> return () ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -55,6 +55,7 @@ import GHC.Tc.Utils.Monad import GHC.Runtime.Interpreter import GHCi.RemoteTypes import GHC.Iface.Load +import GHCi.Message (LoadedDLL) import GHC.ByteCode.Linker import GHC.ByteCode.Asm @@ -172,7 +173,7 @@ emptyLoaderState = LoaderState -- -- The linker's symbol table is populated with RTS symbols using an -- explicit list. See rts/Linker.c for details. - where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] emptyUniqDSet) + where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] [] emptyUniqDSet) extendLoadedEnv :: Interp -> [(Name,ForeignHValue)] -> IO () extendLoadedEnv interp new_bindings = @@ -221,8 +222,8 @@ loadDependencies -> SrcSpan -> [Module] -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required +-- When called, the loader state must have been initialized (see `initLoaderState`) loadDependencies interp hsc_env pls span needed_mods = do --- initLoaderState (hsc_dflags hsc_env) dl let opts = initLinkDepsOpts hsc_env -- Find what packages and linkables are required @@ -512,25 +513,25 @@ preloadLib interp hsc_env lib_paths framework_paths pls lib_spec = do DLL dll_unadorned -> do maybe_errstr <- loadDLL interp (platformSOName platform dll_unadorned) case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm | platformOS platform /= OSDarwin -> + Right _ -> maybePutStrLn logger "done" + Left mm | platformOS platform /= OSDarwin -> preloadFailed mm lib_paths lib_spec - Just mm | otherwise -> do + Left mm | otherwise -> do -- As a backup, on Darwin, try to also load a .so file -- since (apparently) some things install that way - see -- ticket #8770. let libfile = ("lib" ++ dll_unadorned) <.> "so" err2 <- loadDLL interp libfile case err2 of - Nothing -> maybePutStrLn logger "done" - Just _ -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left _ -> preloadFailed mm lib_paths lib_spec return pls DLLPath dll_path -> do do maybe_errstr <- loadDLL interp dll_path case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left mm -> preloadFailed mm lib_paths lib_spec return pls Framework framework -> @@ -614,7 +615,7 @@ loadExpr interp hsc_env span root_ul_bco = do -- Load the necessary packages and linkables let le = linker_env pls bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)] - resolved <- linkBCO interp le bco_ix root_ul_bco + resolved <- linkBCO interp (pkgs_loaded pls) le bco_ix root_ul_bco [root_hvref] <- createBCOs interp [resolved] fhv <- mkFinalizedHValue interp root_hvref return (pls, fhv) @@ -678,7 +679,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do , addr_env = plusNameEnv (addr_env le) bc_strs } -- Link the necessary packages and linkables - new_bindings <- linkSomeBCOs interp le2 [cbc] + new_bindings <- linkSomeBCOs interp (pkgs_loaded pls) le2 [cbc] nms_fhvs <- makeForeignNamedHValueRefs interp new_bindings let ce2 = extendClosureEnv (closure_env le2) nms_fhvs !pls2 = pls { linker_env = le2 { closure_env = ce2 } } @@ -860,8 +861,8 @@ dynLoadObjs interp hsc_env pls at LoaderState{..} objs = do changeTempFilesLifetime tmpfs TFL_GhcSession [soFile] m <- loadDLL interp soFile case m of - Nothing -> return $! pls { temp_sos = (libPath, libName) : temp_sos } - Just err -> linkFail msg err + Right _ -> return $! pls { temp_sos = (libPath, libName) : temp_sos } + Left err -> linkFail msg err where msg = "GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed" @@ -901,7 +902,7 @@ dynLinkBCOs interp pls bcos = do ae2 = foldr plusNameEnv (addr_env le1) (map bc_strs cbcs) le2 = le1 { itbl_env = ie2, addr_env = ae2 } - names_and_refs <- linkSomeBCOs interp le2 cbcs + names_and_refs <- linkSomeBCOs interp (pkgs_loaded pls) le2 cbcs -- We only want to add the external ones to the ClosureEnv let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs @@ -916,6 +917,7 @@ dynLinkBCOs interp pls bcos = do -- Link a bunch of BCOs and return references to their values linkSomeBCOs :: Interp + -> PkgsLoaded -> LinkerEnv -> [CompiledByteCode] -> IO [(Name,HValueRef)] @@ -923,7 +925,7 @@ linkSomeBCOs :: Interp -- the incoming unlinked BCOs. Each gives the -- value of the corresponding unlinked BCO -linkSomeBCOs interp le mods = foldr fun do_link mods [] +linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] where fun CompiledByteCode{..} inner accum = inner (bc_bcos : accum) @@ -932,7 +934,7 @@ linkSomeBCOs interp le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) - resolved <- sequence [ linkBCO interp le bco_ix bco | bco <- flat ] + resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) @@ -1094,18 +1096,18 @@ loadPackages' interp hsc_env new_pks pls = do -- Link dependents first ; pkgs' <- link pkgs deps -- Now link the package itself - ; (hs_cls, extra_cls) <- loadPackage interp hsc_env pkg_cfg + ; (hs_cls, extra_cls, loaded_dlls) <- loadPackage interp hsc_env pkg_cfg ; let trans_deps = unionManyUniqDSets [ addOneToUniqDSet (loaded_pkg_trans_deps loaded_pkg_info) dep_pkg | dep_pkg <- deps , Just loaded_pkg_info <- pure (lookupUDFM pkgs' dep_pkg) ] - ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls trans_deps)) } + ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls loaded_dlls trans_deps)) } | otherwise = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unpackFS (unitIdFS new_pkg))) -loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec]) +loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec], [RemotePtr LoadedDLL]) loadPackage interp hsc_env pkg = do let dflags = hsc_dflags hsc_env @@ -1147,7 +1149,9 @@ loadPackage interp hsc_env pkg let classifieds = hs_classifieds ++ extra_classifieds -- Complication: all the .so's must be loaded before any of the .o's. - let known_dlls = [ dll | DLLPath dll <- classifieds ] + let known_hs_dlls = [ dll | DLLPath dll <- hs_classifieds ] + known_extra_dlls = [ dll | DLLPath dll <- extra_classifieds ] + known_dlls = known_hs_dlls ++ known_extra_dlls #if defined(CAN_LOAD_DLL) dlls = [ dll | DLL dll <- classifieds ] #endif @@ -1168,10 +1172,13 @@ loadPackage interp hsc_env pkg loadFrameworks interp platform pkg -- See Note [Crash early load_dyn and locateLib] -- Crash early if can't load any of `known_dlls` - mapM_ (load_dyn interp hsc_env True) known_dlls + mapM_ (load_dyn interp hsc_env True) known_extra_dlls + loaded_dlls <- mapMaybeM (load_dyn interp hsc_env True) known_hs_dlls -- For remaining `dlls` crash early only when there is surely -- no package's DLL around ... (not is_dyn) mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls +#else + let loaded_dlls = [] #endif -- After loading all the DLLs, we can load the static objects. -- Ordering isn't important here, because we do one final link @@ -1191,7 +1198,7 @@ loadPackage interp hsc_env pkg if succeeded ok then do maybePutStrLn logger "done." - return (hs_classifieds, extra_classifieds) + return (hs_classifieds, extra_classifieds, loaded_dlls) else let errmsg = text "unable to load unit `" <> pprUnitInfoForUser pkg <> text "'" in throwGhcExceptionIO (InstallationError (showSDoc dflags errmsg)) @@ -1244,19 +1251,20 @@ restriction very easily. -- can be passed directly to loadDLL. They are either fully-qualified -- ("/usr/lib/libfoo.so"), or unqualified ("libfoo.so"). In the latter case, -- loadDLL is going to search the system paths to find the library. -load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO () +load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO (Maybe (RemotePtr LoadedDLL)) load_dyn interp hsc_env crash_early dll = do r <- loadDLL interp dll case r of - Nothing -> return () - Just err -> + Right loaded_dll -> pure (Just loaded_dll) + Left err -> if crash_early then cmdLineErrorIO err - else + else do when (diag_wopt Opt_WarnMissedExtraSharedLib diag_opts) $ logMsg logger (mkMCDiagnostic diag_opts (WarningWithFlag Opt_WarnMissedExtraSharedLib) Nothing) noSrcSpan $ withPprStyle defaultUserStyle (note err) + pure Nothing where diag_opts = initDiagOpts (hsc_dflags hsc_env) logger = hsc_logger hsc_env ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -172,6 +172,6 @@ loadFramework interp extraPaths rootname findLoadDLL (p:ps) errs = do { dll <- loadDLL interp (p fwk_file) ; case dll of - Nothing -> return Nothing - Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) + Right _ -> return Nothing + Left err -> findLoadDLL ps ((p ++ ": " ++ err):errs) } ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE StrictData #-} ----------------------------------------------------------------------------- -- -- Types for the linkers and the loader @@ -40,7 +41,8 @@ import GHC.Prelude import GHC.Unit ( UnitId, Module ) import GHC.ByteCode.Types ( ItblEnv, AddrEnv, CompiledByteCode ) import GHC.Fingerprint.Type ( Fingerprint ) -import GHCi.RemoteTypes ( ForeignHValue ) +import GHCi.RemoteTypes ( ForeignHValue, RemotePtr ) +import GHCi.Message ( LoadedDLL ) import GHC.Types.Var ( Id ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnvList, filterNameEnv ) @@ -75,6 +77,57 @@ initialised. The LinkerEnv maps Names to actual closures (for interpreted code only), for use during linking. + +Note [Looking up symbols in the relevant objects] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #23415, we determined that a lot of time (>10s, or even up to >35s!) was +being spent on dynamically loading symbols before actually interpreting code +when `:main` was run in GHCi. The root cause was that for each symbol we wanted +to lookup, we would traverse the list of loaded objects and try find the symbol +in each of them with dlsym (i.e. looking up a symbol was, worst case, linear in +the amount of loaded objects). + +To drastically improve load time (XXX(TODO:get better measure against 10s +baseline rather than 35second one) to <3s), we now: + +1. For every of the native objects loaded for a given unit, store the handles returned by `dlopen`. + - In `pkgs_loaded` of the `LoaderState`, which maps `UnitId`s to + `LoadedPkgInfo`s, where the handles live in its field `loaded_pkg_hs_dlls`. + +2. When looking up a Name (e.g. `lookupHsSymbol`), find that name's `UnitId` in + the `pkgs_loaded` mapping, + +3. And only look for the symbol (with `dlsym`) on the /handles relevant to that + unit/, rather than in every loaded object. + +Note [Symbols may not be found in pkgs_loaded] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Despite storing and looking for symbols in the relevant loaded libraries +handles for a given unit-id, as described in the note above, we may still have +to fallback to the "slow" `lookupSymbol` function (see its "fallback" call in +`lookupHsSymbol`). + +TODO: Ben: my understanding here is flawed; could you make this clearer?. + +This fallback is still needed because a given unit may be associated with +static objects (`loaded_pkg_hs_objs`) only and no dynamic libraries, but we +only `lookupSymbolInDLL` for loaded dynamic libraries. In that case, +`lookupSymbol` will do the right thing because, besides looking up the symbol +in every loaded dylib, it will end up searching the static name table and find those symbols. + +Arguably, we should rather generalise `lookupSymbolInDLL` to +`lookupSymbolInObject`, where an object may be a DLL/native object (as in +`loadNativeObj`), or e.g. a static archive, instead of having a special case +for dynamic libraries. + +This fallback is further needed because we don't look in the haskell objects +loaded for the home units (see the call to `loadModuleLinkables` in +`loadDependencies`, as opposed to the call to `loadPackages'` in the same +function which updates `pkgs_loaded`). We should ultimately keep track of the +objects loaded (probably in `objs_loaded`, for which `LinkableSet` is a bit +unsatisfactory, see a suggestion in 51c5c4eb1f2a33e4dc88e6a37b7b7c135234ce9b) +and be able to lookup symbols specifically in them too (similarly to +`lookupSymbolInDLL`). -} newtype Loader = Loader { loader_state :: MVar (Maybe LoaderState) } @@ -146,11 +199,13 @@ data LoadedPkgInfo { loaded_pkg_uid :: !UnitId , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] + , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] + -- ^ See Note [Looking up symbols in the relevant objects] , loaded_pkg_trans_deps :: UniqDSet UnitId } instance Outputable LoadedPkgInfo where - ppr (LoadedPkgInfo uid hs_objs non_hs_objs trans_deps) = + ppr (LoadedPkgInfo uid hs_objs non_hs_objs _ trans_deps) = vcat [ppr uid , ppr hs_objs , ppr non_hs_objs @@ -159,10 +214,10 @@ instance Outputable LoadedPkgInfo where -- | Information we can use to dynamically link modules into the compiler data Linkable = LM { - linkableTime :: !UTCTime, -- ^ Time at which this linkable was built + linkableTime :: !UTCTime, -- ^ Time at which this linkable was built -- (i.e. when the bytecodes were produced, -- or the mod date on the files) - linkableModule :: !Module, -- ^ The linkable module itself + linkableModule :: !Module, -- ^ The linkable module itself linkableUnlinked :: [Unlinked] -- ^ Those files and chunks of code we have yet to link. -- ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Runtime.Interpreter -- * The object-code linker , initObjLinker , lookupSymbol + , lookupSymbolInDLL , lookupClosure , loadDLL , loadArchive @@ -151,22 +152,22 @@ The main pieces are: - implementation of Template Haskell (GHCi.TH) - a few other things needed to run interpreted code -- top-level iserv directory, containing the codefor the external - server. This is a fairly simple wrapper, most of the functionality +- top-level iserv directory, containing the code for the external + server. This is a fairly simple wrapper, most of the functionality is provided by modules in libraries/ghci. - This module which provides the interface to the server used by the rest of GHC. -GHC works with and without -fexternal-interpreter. With the flag, all -interpreted code is run by the iserv binary. Without the flag, +GHC works with and without -fexternal-interpreter. With the flag, all +interpreted code is run by the iserv binary. Without the flag, interpreted code is run in the same process as GHC. Things that do not work with -fexternal-interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dynCompileExpr cannot work, because we have no way to run code of an -unknown type in the remote process. This API fails with an error +unknown type in the remote process. This API fails with an error message if it is used with -fexternal-interpreter. Other Notes on Remote GHCi @@ -440,57 +441,78 @@ initObjLinker :: Interp -> IO () initObjLinker interp = interpCmd interp InitLinker lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) -lookupSymbol interp str = case interpInstance interp of +lookupSymbol interp str = withSymbolCache interp str $ + case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) #endif - - ExternalInterp ext -> case ext of - ExtIServ i -> withIServ i $ \inst -> do - -- Profiling of GHCi showed a lot of time and allocation spent - -- making cross-process LookupSymbol calls, so I added a GHC-side - -- cache which sped things up quite a lot. We have to be careful - -- to purge this cache when unloading code though. - cache <- readMVar (instLookupSymbolCache inst) - case lookupUFM cache str of - Just p -> return (Just p) - Nothing -> do - m <- uninterruptibleMask_ $ - sendMessage inst (LookupSymbol (unpackFS str)) - case m of - Nothing -> return Nothing - Just r -> do - let p = fromRemotePtr r - cache' = addToUFM cache str p - modifyMVar_ (instLookupSymbolCache inst) (const (pure cache')) - return (Just p) - - ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbol (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + +lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) +lookupSymbolInDLL interp dll str = withSymbolCache interp str $ + case interpInstance interp of +#if defined(HAVE_INTERNAL_INTERPRETER) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) +#endif + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbolInDLL dll (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = interpCmd interp (LookupClosure str) +-- | 'withSymbolCache' tries to find a symbol in the 'interpLookupSymbolCache' +-- which maps symbols to the address where they are loaded. +-- When there's a cache hit we simply return the cached address, when there is +-- a miss we run the action which determines the symbol's address and populate +-- the cache with the answer. +withSymbolCache :: Interp + -> FastString + -- ^ The symbol we are looking up in the cache + -> IO (Maybe (Ptr ())) + -- ^ An action which determines the address of the symbol we + -- are looking up in the cache, which is run if there is a + -- cache miss. The result will be cached. + -> IO (Maybe (Ptr ())) +withSymbolCache interp str determine_addr = do + + -- Profiling of GHCi showed a lot of time and allocation spent + -- making cross-process LookupSymbol calls, so I added a GHC-side + -- cache which sped things up quite a lot. We have to be careful + -- to purge this cache when unloading code though. + -- + -- The analysis in #23415 further showed this cache should also benefit the + -- internal interpreter's loading times, and needn't be used by the external + -- interpreter only. + cache <- readMVar (interpLookupSymbolCache interp) + case lookupUFM cache str of + Just p -> return (Just p) + Nothing -> do + + maddr <- determine_addr + case maddr of + Nothing -> return Nothing + Just p -> do + let upd_cache cache' = addToUFM cache' str p + modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache) + return (Just p) + purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = case interpInstance interp of -#if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> pure () -#endif - ExternalInterp ext -> withExtInterpMaybe ext $ \case - Nothing -> pure () -- interpreter stopped, nothing to do - Just inst -> modifyMVar_ (instLookupSymbolCache inst) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either -- an absolute pathname to the file, or a relative filename -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. --- --- Returns: --- --- Nothing => success --- Just err_msg => failure -loadDLL :: Interp -> String -> IO (Maybe String) +loadDLL :: Interp -> String -> IO (Either String (RemotePtr LoadedDLL)) loadDLL interp str = interpCmd interp (LoadDLL str) loadArchive :: Interp -> String -> IO () @@ -549,11 +571,9 @@ spawnIServ conf = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = process , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = () } pure inst ===================================== compiler/GHC/Runtime/Interpreter/JS.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Utils.Panic import GHC.Utils.Error (logInfo) import GHC.Utils.Outputable (text) import GHC.Data.FastString -import GHC.Types.Unique.FM import Control.Concurrent import Control.Monad @@ -178,11 +177,9 @@ spawnJSInterp cfg = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = proc , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = extra } ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -51,6 +51,9 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader + + , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + -- ^ LookupSymbol cache } data InterpInstance @@ -108,9 +111,6 @@ data ExtInterpInstance c = ExtInterpInstance -- Finalizers for ForeignRefs can append values to this list -- asynchronously. - , instLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) - -- ^ LookupSymbol cache - , instExtra :: !c -- ^ Instance specific extra fields } ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -23,6 +23,7 @@ module GHCi.Message , getMessage, putMessage, getTHMessage, putTHMessage , Pipe(..), remoteCall, remoteTHCall, readPipe, writePipe , BreakModule + , LoadedDLL ) where import Prelude -- See note [Why do we import Prelude here?] @@ -73,8 +74,9 @@ data Message a where -- These all invoke the corresponding functions in the RTS Linker API. InitLinker :: Message () LookupSymbol :: String -> Message (Maybe (RemotePtr ())) + LookupSymbolInDLL :: RemotePtr LoadedDLL -> String -> Message (Maybe (RemotePtr ())) LookupClosure :: String -> Message (Maybe HValueRef) - LoadDLL :: String -> Message (Maybe String) + LoadDLL :: String -> Message (Either String (RemotePtr LoadedDLL)) LoadArchive :: String -> Message () -- error? LoadObj :: String -> Message () -- error? UnloadObj :: String -> Message () -- error? @@ -415,6 +417,9 @@ instance Binary a => Binary (EvalResult a) -- that type isn't available here. data BreakModule +-- | A dummy type that tags pointers returned by 'LoadDLL'. +data LoadedDLL + -- SomeException can't be serialized because it contains dynamic -- types. However, we do very limited things with the exceptions that -- are thrown by interpreted computations: @@ -544,6 +549,7 @@ getMessage = do 37 -> Msg <$> return RtsRevertCAFs 38 -> Msg <$> (ResumeSeq <$> get) 39 -> Msg <$> (NewBreakModule <$> get) + 40 -> Msg <$> (LookupSymbolInDLL <$> get <*> get) _ -> error $ "Unknown Message code " ++ (show b) putMessage :: Message a -> Put @@ -588,7 +594,8 @@ putMessage m = case m of Seq a -> putWord8 36 >> put a RtsRevertCAFs -> putWord8 37 ResumeSeq a -> putWord8 38 >> put a - NewBreakModule name -> putWord8 39 >> put name + NewBreakModule name -> putWord8 39 >> put name + LookupSymbolInDLL dll str -> putWord8 40 >> put dll >> put str {- Note [Parallelize CreateBCOs serialization] ===================================== libraries/ghci/GHCi/ObjLink.hs ===================================== @@ -18,6 +18,7 @@ module GHCi.ObjLink , unloadObj , purgeObj , lookupSymbol + , lookupSymbolInDLL , lookupClosure , resolveObjs , addLibrarySearchPath @@ -27,18 +28,17 @@ module GHCi.ObjLink import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes +import GHCi.Message (LoadedDLL) import Control.Exception (throwIO, ErrorCall(..)) import Control.Monad ( when ) import Foreign.C -import Foreign.Marshal.Alloc ( free ) -import Foreign ( nullPtr ) +import Foreign.Marshal.Alloc ( alloca, free ) +import Foreign ( nullPtr, peek ) import GHC.Exts import System.Posix.Internals ( CFilePath, withFilePath, peekFilePath ) import System.FilePath ( dropExtension, normalise ) - - -- --------------------------------------------------------------------------- -- RTS Linker Interface -- --------------------------------------------------------------------------- @@ -70,6 +70,15 @@ lookupSymbol str_in = do then return Nothing else return (Just addr) +lookupSymbolInDLL :: Ptr LoadedDLL -> String -> IO (Maybe (Ptr a)) +lookupSymbolInDLL dll str_in = do + let str = prefixUnderscore str_in + withCAString str $ \c_str -> do + addr <- c_lookupSymbolInNativeObj dll c_str + if addr == nullPtr + then return Nothing + else return (Just addr) + lookupClosure :: String -> IO (Maybe HValueRef) lookupClosure str = do m <- lookupSymbol str @@ -89,7 +98,7 @@ prefixUnderscore -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. -- -loadDLL :: String -> IO (Maybe String) +loadDLL :: String -> IO (Either String (Ptr LoadedDLL)) -- Nothing => success -- Just err_msg => failure loadDLL str0 = do @@ -101,12 +110,16 @@ loadDLL str0 = do str | isWindowsHost = dropExtension str0 | otherwise = str0 -- - maybe_errmsg <- withFilePath (normalise str) $ \dll -> c_addDLL dll - if maybe_errmsg == nullPtr - then return Nothing - else do str <- peekCString maybe_errmsg - free maybe_errmsg - return (Just str) + (maybe_handle, maybe_errmsg) <- withFilePath (normalise str) $ \dll -> + alloca $ \errmsg_ptr -> (,) + <$> c_loadNativeObj dll errmsg_ptr + <*> peek errmsg_ptr + + if maybe_handle == nullPtr + then do str <- peekCString maybe_errmsg + free maybe_errmsg + return (Left str) + else return (Right maybe_handle) loadArchive :: String -> IO () loadArchive str = do @@ -163,7 +176,8 @@ resolveObjs = do -- Foreign declarations to RTS entry points which does the real work; -- --------------------------------------------------------------------------- -foreign import ccall unsafe "addDLL" c_addDLL :: CFilePath -> IO CString +foreign import ccall unsafe "loadNativeObj" c_loadNativeObj :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) +foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInNativeObj :: Ptr LoadedDLL -> CString -> IO (Ptr a) foreign import ccall unsafe "initLinker_" c_initLinker_ :: CInt -> IO () foreign import ccall unsafe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) foreign import ccall unsafe "loadArchive" c_loadArchive :: CFilePath -> IO Int ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -66,7 +66,7 @@ run m = case m of LookupClosure str -> lookupJSClosure str #else InitLinker -> initObjLinker RetainCAFs - LoadDLL str -> loadDLL str + LoadDLL str -> fmap toRemotePtr <$> loadDLL str LoadArchive str -> loadArchive str LoadObj str -> loadObj str UnloadObj str -> unloadObj str @@ -81,6 +81,8 @@ run m = case m of #endif RtsRevertCAFs -> rts_revertCAFs LookupSymbol str -> fmap toRemotePtr <$> lookupSymbol str + LookupSymbolInDLL dll str -> + fmap toRemotePtr <$> lookupSymbolInDLL (fromRemotePtr dll) str FreeHValueRefs rs -> mapM_ freeRemoteRef rs AddSptEntry fpr r -> localRef r >>= sptAddEntry fpr EvalStmt opts r -> evalStmt opts r ===================================== rts/Linker.c ===================================== @@ -77,6 +77,10 @@ # include #endif +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) +# include "linker/LoadNativeObjPosix.h" +#endif + #if defined(dragonfly_HOST_OS) #include #endif @@ -130,7 +134,7 @@ extern void iconv(); - Indexing (e.g. ocVerifyImage and ocGetNames) - Initialization (e.g. ocResolve) - RunInit (e.g. ocRunInit) - - Lookup (e.g. lookupSymbol) + - Lookup (e.g. lookupSymbol/lookupSymbolInDLL) This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will @@ -419,9 +423,6 @@ static int linker_init_done = 0 ; static void *dl_prog_handle; static regex_t re_invalid; static regex_t re_realso; -#if defined(THREADED_RTS) -Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section -#endif #endif void initLinker (void) @@ -455,9 +456,6 @@ initLinker_ (int retain_cafs) #if defined(THREADED_RTS) initMutex(&linker_mutex); -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - initMutex(&dl_mutex); -#endif #endif symhash = allocStrHashTable(); @@ -520,9 +518,6 @@ exitLinker( void ) { if (linker_init_done == 1) { regfree(&re_invalid); regfree(&re_realso); -#if defined(THREADED_RTS) - closeMutex(&dl_mutex); -#endif } #endif if (linker_init_done == 1) { @@ -556,90 +551,6 @@ exitLinker( void ) { # if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -/* Suppose in ghci we load a temporary SO for a module containing - f = 1 - and then modify the module, recompile, and load another temporary - SO with - f = 2 - Then as we don't unload the first SO, dlsym will find the - f = 1 - symbol whereas we want the - f = 2 - symbol. We therefore need to keep our own SO handle list, and - try SOs in the right order. */ - -typedef - struct _OpenedSO { - struct _OpenedSO* next; - void *handle; - } - OpenedSO; - -/* A list thereof. */ -static OpenedSO* openedSOs = NULL; - -static const char * -internal_dlopen(const char *dll_name) -{ - OpenedSO* o_so; - void *hdl; - const char *errmsg; - char *errmsg_copy; - - // omitted: RTLD_NOW - // see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html - IF_DEBUG(linker, - debugBelch("internal_dlopen: dll_name = '%s'\n", dll_name)); - - //-------------- Begin critical section ------------------ - // This critical section is necessary because dlerror() is not - // required to be reentrant (see POSIX -- IEEE Std 1003.1-2008) - // Also, the error message returned must be copied to preserve it - // (see POSIX also) - - ACQUIRE_LOCK(&dl_mutex); - - // When dlopen() loads a profiled dynamic library, it calls the - // ctors which will call registerCcsList() to append the defined - // CostCentreStacks to CCS_LIST. This execution path starting from - // addDLL() was only protected by dl_mutex previously. However, - // another thread may be doing other things with the RTS linker - // that transitively calls refreshProfilingCCSs() which also - // accesses CCS_LIST, and those execution paths are protected by - // linker_mutex. So there's a risk of data race that may lead to - // segfaults (#24423), and we need to ensure the ctors are also - // protected by ccs_mutex. -#if defined(PROFILING) - ACQUIRE_LOCK(&ccs_mutex); -#endif - - hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ - -#if defined(PROFILING) - RELEASE_LOCK(&ccs_mutex); -#endif - - errmsg = NULL; - if (hdl == NULL) { - /* dlopen failed; return a ptr to the error msg. */ - errmsg = dlerror(); - if (errmsg == NULL) errmsg = "addDLL: unknown error"; - errmsg_copy = stgMallocBytes(strlen(errmsg)+1, "addDLL"); - strcpy(errmsg_copy, errmsg); - errmsg = errmsg_copy; - } else { - o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); - o_so->handle = hdl; - o_so->next = openedSOs; - openedSOs = o_so; - } - - RELEASE_LOCK(&dl_mutex); - //--------------- End critical section ------------------- - - return errmsg; -} - /* Note [RTLD_LOCAL] ~~~~~~~~~~~~~~~~~ @@ -660,11 +571,10 @@ internal_dlopen(const char *dll_name) static void * internal_dlsym(const char *symbol) { - OpenedSO* o_so; void *v; - // We acquire dl_mutex as concurrent dl* calls may alter dlerror - ACQUIRE_LOCK(&dl_mutex); + // concurrent dl* calls may alter dlerror + ASSERT_LOCK_HELD(&linker_mutex); // clears dlerror dlerror(); @@ -672,20 +582,19 @@ internal_dlsym(const char *symbol) { // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } - for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { - v = dlsym(o_so->handle, symbol); - if (dlerror() == NULL) { + for (ObjectCode *nc = loaded_objects; nc; nc = nc->next_loaded_object) { + if (nc->type == DYNAMIC_OBJECT) { + v = dlsym(nc->dlopen_handle, symbol); + if (dlerror() == NULL) { IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); - RELEASE_LOCK(&dl_mutex); return v; + } } } - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); # define SPECIAL_SYMBOL(sym) \ @@ -725,79 +634,33 @@ internal_dlsym(const char *symbol) { // we failed to find the symbol return NULL; } -# endif -const char * -addDLL( pathchar *dll_name ) +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name) { -# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - /* ------------------- ELF DLL loader ------------------- */ - -#define NMATCH 5 - regmatch_t match[NMATCH]; - const char *errmsg; - FILE* fp; - size_t match_length; -#define MAXLINE 1000 - char line[MAXLINE]; - int result; - - IF_DEBUG(linker, debugBelch("addDLL: dll_name = '%s'\n", dll_name)); - errmsg = internal_dlopen(dll_name); + ASSERT_LOCK_HELD(&linker_mutex); - if (errmsg == NULL) { - return NULL; - } +#if defined(OBJFORMAT_MACHO) + CHECK(symbol_name[0] == '_'); + symbol_name = symbol_name+1; +#endif + void *result = dlsym(handle, symbol_name); + return result; +} +# endif - // GHC #2615 - // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) - // contain linker scripts rather than ELF-format object code. This - // code handles the situation by recognizing the real object code - // file name given in the linker script. - // - // If an "invalid ELF header" error occurs, it is assumed that the - // .so file contains a linker script instead of ELF object code. - // In this case, the code looks for the GROUP ( ... ) linker - // directive. If one is found, the first file name inside the - // parentheses is treated as the name of a dynamic library and the - // code attempts to dlopen that file. If this is also unsuccessful, - // an error message is returned. - - // see if the error message is due to an invalid ELF header - IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", errmsg)); - result = regexec(&re_invalid, errmsg, (size_t) NMATCH, match, 0); - IF_DEBUG(linker, debugBelch("result = %i\n", result)); - if (result == 0) { - // success -- try to read the named file as a linker script - match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), - MAXLINE-1); - strncpy(line, (errmsg+(match[1].rm_so)),match_length); - line[match_length] = '\0'; // make sure string is null-terminated - IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); - if ((fp = __rts_fopen(line, "r")) == NULL) { - return errmsg; // return original error if open fails - } - // try to find a GROUP or INPUT ( ... ) command - while (fgets(line, MAXLINE, fp) != NULL) { - IF_DEBUG(linker, debugBelch("input line = %s", line)); - if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { - // success -- try to dlopen the first named file - IF_DEBUG(linker, debugBelch("match%s\n","")); - line[match[2].rm_eo] = '\0'; - stgFree((void*)errmsg); // Free old message before creating new one - errmsg = internal_dlopen(line+match[2].rm_so); - break; - } - // if control reaches here, no GROUP or INPUT ( ... ) directive - // was found and the original error message is returned to the - // caller - } - fclose(fp); +const char *addDLL(pathchar* dll_name) +{ +# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) + char *errmsg; + if (loadNativeObj(dll_name, &errmsg)) { + return NULL; + } else { + ASSERT(errmsg != NULL); + return errmsg; } - return errmsg; # elif defined(OBJFORMAT_PEi386) - return addDLL_PEi386(dll_name, NULL); + return addDLL_PEi386(dll_name); # else barf("addDLL: not implemented on this platform"); @@ -1229,9 +1092,10 @@ void freeObjectCode (ObjectCode *oc) if (oc->type == DYNAMIC_OBJECT) { #if defined(OBJFORMAT_ELF) - ACQUIRE_LOCK(&dl_mutex); - freeNativeCode_ELF(oc); - RELEASE_LOCK(&dl_mutex); + // ROMES:TODO: This previously acquired dl_mutex. Check that acquiring linker_mutex here is fine. + ACQUIRE_LOCK(&linker_mutex); + freeNativeCode_POSIX(oc); + RELEASE_LOCK(&linker_mutex); #else barf("freeObjectCode: This shouldn't happen"); #endif @@ -1896,12 +1760,20 @@ HsInt purgeObj (pathchar *path) return r; } +ObjectCode *lookupObjectByPath(pathchar *path) { + for (ObjectCode *o = objects; o; o = o->next) { + if (0 == pathcmp(o->fileName, path)) { + return o; + } + } + return NULL; +} + OStatus getObjectLoadStatus_ (pathchar *path) { - for (ObjectCode *o = objects; o; o = o->next) { - if (0 == pathcmp(o->fileName, path)) { - return o->status; - } + ObjectCode *oc = lookupObjectByPath(path); + if (oc) { + return oc->status; } return OBJECT_NOT_LOADED; } @@ -1988,11 +1860,21 @@ addSection (Section *s, SectionKind kind, SectionAlloc alloc, #define UNUSED(x) (void)(x) -#if defined(OBJFORMAT_ELF) +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) void * loadNativeObj (pathchar *path, char **errmsg) { + IF_DEBUG(linker, debugBelch("loadNativeObj: path = '%s'\n", path)); ACQUIRE_LOCK(&linker_mutex); - void *r = loadNativeObj_ELF(path, errmsg); + void *r = loadNativeObj_POSIX(path, errmsg); + +#if defined(OBJFORMAT_ELF) + if (!r) { + // Check if native object may be a linker script and try loading a native + // object from it + r = loadNativeObjFromLinkerScript_ELF(errmsg); + } +#endif + RELEASE_LOCK(&linker_mutex); return r; } @@ -2006,7 +1888,7 @@ loadNativeObj (pathchar *path, char **errmsg) } #endif -HsInt unloadNativeObj (void *handle) +static HsInt unloadNativeObj_(void *handle) { bool unloadedAnyObj = false; @@ -2044,6 +1926,13 @@ HsInt unloadNativeObj (void *handle) } } +HsInt unloadNativeObj(void *handle) { + ACQUIRE_LOCK(&linker_mutex); + HsInt r = unloadNativeObj_(handle); + RELEASE_LOCK(&linker_mutex); + return r; +} + /* ----------------------------------------------------------------------------- * Segment management */ ===================================== rts/LinkerInternals.h ===================================== @@ -412,10 +412,6 @@ extern Elf_Word shndx_table_uninit_label; #if defined(THREADED_RTS) extern Mutex linker_mutex; - -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -extern Mutex dl_mutex; -#endif #endif /* THREADED_RTS */ /* Type of an initializer */ @@ -515,9 +511,9 @@ HsInt loadArchive_ (pathchar *path); #define USE_CONTIGUOUS_MMAP 0 #endif - HsInt isAlreadyLoaded( pathchar *path ); OStatus getObjectLoadStatus_ (pathchar *path); +ObjectCode *lookupObjectByPath(pathchar *path); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( ObjectType type, pathchar *path, char *image, int imageSize, bool mapped, pathchar *archiveMemberName, ===================================== rts/RtsSymbols.c ===================================== @@ -619,6 +619,7 @@ extern char **environ; SymI_HasProto(purgeObj) \ SymI_HasProto(insertSymbol) \ SymI_HasProto(lookupSymbol) \ + SymI_HasProto(lookupSymbolInNativeObj) \ SymI_HasDataProto(stg_makeStablePtrzh) \ SymI_HasDataProto(stg_mkApUpd0zh) \ SymI_HasDataProto(stg_labelThreadzh) \ ===================================== rts/include/rts/Linker.h ===================================== @@ -90,8 +90,12 @@ void *loadNativeObj( pathchar *path, char **errmsg ); Takes the handle returned from loadNativeObj() as an argument. */ HsInt unloadNativeObj( void *handle ); +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name); + /* load a dynamic library */ -const char *addDLL( pathchar* dll_name ); +const char *addDLL(pathchar* dll_name); + +void *lookupSymbolInDLL(void *handle, const char *symbol_name); /* add a path to the library search path */ HsPtr addLibrarySearchPath(pathchar* dll_path); ===================================== rts/linker/Elf.c ===================================== @@ -2069,159 +2069,6 @@ int ocRunFini_ELF( ObjectCode *oc ) return true; } -/* - * Shared object loading - */ - -#if defined(HAVE_DLINFO) -struct piterate_cb_info { - ObjectCode *nc; - void *l_addr; /* base virtual address of the loaded code */ -}; - -static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size STG_UNUSED, void *data) { - struct piterate_cb_info *s = (struct piterate_cb_info *) data; - - // This logic mimicks _dl_addr_inside_object from glibc - // For reference: - // int - // internal_function - // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) - // { - // int n = l->l_phnum; - // const ElfW(Addr) reladdr = addr - l->l_addr; - // - // while (--n >= 0) - // if (l->l_phdr[n].p_type == PT_LOAD - // && reladdr - l->l_phdr[n].p_vaddr >= 0 - // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) - // return 1; - // return 0; - // } - - if ((void*) info->dlpi_addr == s->l_addr) { - int n = info->dlpi_phnum; - while (--n >= 0) { - if (info->dlpi_phdr[n].p_type == PT_LOAD) { - NativeCodeRange* ncr = - stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); - ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); - ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); - - ncr->next = s->nc->nc_ranges; - s->nc->nc_ranges = ncr; - } - } - } - return 0; -} -#endif /* defined(HAVE_DLINFO) */ - -static void copyErrmsg(char** errmsg_dest, char* errmsg) { - if (errmsg == NULL) errmsg = "loadNativeObj_ELF: unknown error"; - *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_ELF"); - strcpy(*errmsg_dest, errmsg); -} - -// need dl_mutex -void freeNativeCode_ELF (ObjectCode *nc) { - dlclose(nc->dlopen_handle); - - NativeCodeRange *ncr = nc->nc_ranges; - while (ncr) { - NativeCodeRange* last_ncr = ncr; - ncr = ncr->next; - stgFree(last_ncr); - } -} - -void * loadNativeObj_ELF (pathchar *path, char **errmsg) -{ - ObjectCode* nc; - void *hdl, *retval; - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF %" PATH_FMT "\n", path)); - - retval = NULL; - ACQUIRE_LOCK(&dl_mutex); - - /* Loading the same object multiple times will lead to chaos - * as we will have two ObjectCodes but one underlying dlopen - * handle. Fail if this happens. - */ - if (getObjectLoadStatus_(path) != OBJECT_NOT_LOADED) { - copyErrmsg(errmsg, "loadNativeObj_ELF: Already loaded"); - goto dlopen_fail; - } - - nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); - - foreignExportsLoadingObject(nc); - hdl = dlopen(path, RTLD_NOW|RTLD_LOCAL); - nc->dlopen_handle = hdl; - foreignExportsFinishedLoadingObject(); - if (hdl == NULL) { - /* dlopen failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlopen_fail; - } - -#if defined(HAVE_DLINFO) - struct link_map *map; - if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { - /* dlinfo failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlinfo_fail; - } - - hdl = NULL; // pass handle ownership to nc - - struct piterate_cb_info piterate_info = { - .nc = nc, - .l_addr = (void *) map->l_addr - }; - dl_iterate_phdr(loadNativeObjCb_, &piterate_info); - if (!nc->nc_ranges) { - copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); - goto dl_iterate_phdr_fail; - } - nc->unloadable = true; -#else - nc->nc_ranges = NULL; - nc->unloadable = false; -#endif /* defined (HAVE_DLINFO) */ - - insertOCSectionIndices(nc); - - nc->next_loaded_object = loaded_objects; - loaded_objects = nc; - - retval = nc->dlopen_handle; - -#if defined(PROFILING) - // collect any new cost centres that were defined in the loaded object. - refreshProfilingCCSs(); -#endif - - goto success; - -dl_iterate_phdr_fail: - // already have dl_mutex - freeNativeCode_ELF(nc); -dlinfo_fail: - if (hdl) dlclose(hdl); -dlopen_fail: -success: - - RELEASE_LOCK(&dl_mutex); - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF result=%p\n", retval)); - - return retval; -} - - /* * PowerPC & X86_64 ELF specifics */ @@ -2271,4 +2118,70 @@ int ocAllocateExtras_ELF( ObjectCode *oc ) #endif /* NEED_SYMBOL_EXTRAS */ +void * loadNativeObjFromLinkerScript_ELF(char **errmsg) +{ + // GHC #2615 + // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) + // contain linker scripts rather than ELF-format object code. This + // code handles the situation by recognizing the real object code + // file name given in the linker script. + // + // If an "invalid ELF header" error occurs, it is assumed that the + // .so file contains a linker script instead of ELF object code. + // In this case, the code looks for the GROUP ( ... ) linker + // directive. If one is found, the first file name inside the + // parentheses is treated as the name of a dynamic library and the + // code attempts to dlopen that file. If this is also unsuccessful, + // an error message is returned. + +#define NMATCH 5 + regmatch_t match[NMATCH]; + FILE* fp; + size_t match_length; +#define MAXLINE 1000 + char line[MAXLINE]; + int result; + void* r = NULL; + + ASSERT_LOCK_HELD(&linker_mutex) + + // see if the error message is due to an invalid ELF header + IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); + result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); + IF_DEBUG(linker, debugBelch("result = %i\n", result)); + if (result == 0) { + // success -- try to read the named file as a linker script + match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), + MAXLINE-1); + strncpy(line, (*errmsg+(match[1].rm_so)),match_length); + line[match_length] = '\0'; // make sure string is null-terminated + IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); + if ((fp = __rts_fopen(line, "r")) == NULL) { + // return original error if open fails + return NULL; + } + // try to find a GROUP or INPUT ( ... ) command + while (fgets(line, MAXLINE, fp) != NULL) { + IF_DEBUG(linker, debugBelch("input line = %s", line)); + if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { + // success -- try to dlopen the first named file + IF_DEBUG(linker, debugBelch("match%s\n","")); + line[match[2].rm_eo] = '\0'; + stgFree((void*)*errmsg); // Free old message before creating new one + // ROMES:TODO: NO GOOD, this is almost recursive? no, as long we + // move the loadNativeObj_ELF to a shared impl + r = loadNativeObj_POSIX(line+match[2].rm_so, errmsg); + break; + } + // if control reaches here, no GROUP or INPUT ( ... ) directive + // was found and the original error message is returned to the + // caller + } + fclose(fp); + } + + return r; +} + + #endif /* elf */ ===================================== rts/linker/Elf.h ===================================== @@ -14,7 +14,6 @@ int ocResolve_ELF ( ObjectCode* oc ); int ocRunInit_ELF ( ObjectCode* oc ); int ocRunFini_ELF ( ObjectCode* oc ); int ocAllocateExtras_ELF ( ObjectCode *oc ); -void freeNativeCode_ELF ( ObjectCode *nc ); -void *loadNativeObj_ELF ( pathchar *path, char **errmsg ); +void *loadNativeObjFromLinkerScript_ELF( char **errmsg ); #include "EndPrivate.h" ===================================== rts/linker/LoadNativeObjPosix.c ===================================== @@ -0,0 +1,211 @@ +#include "CheckUnload.h" +#include "ForeignExports.h" +#include "LinkerInternals.h" +#include "Rts.h" +#include "RtsUtils.h" +#include "Profiling.h" + +#include "linker/LoadNativeObjPosix.h" + +#if defined(HAVE_DLFCN_H) +#include +#endif + +#include + +#if defined(THREADED_RTS) +extern Mutex linker_mutex; +#endif + +/* + * Shared object loading + */ + +#if defined(HAVE_DLINFO) +struct piterate_cb_info { + ObjectCode *nc; + void *l_addr; /* base virtual address of the loaded code */ +}; + +static int loadNativeObjCb_(struct dl_phdr_info *info, + size_t _size STG_UNUSED, void *data) { + struct piterate_cb_info *s = (struct piterate_cb_info *) data; + + // This logic mimicks _dl_addr_inside_object from glibc + // For reference: + // int + // internal_function + // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) + // { + // int n = l->l_phnum; + // const ElfW(Addr) reladdr = addr - l->l_addr; + // + // while (--n >= 0) + // if (l->l_phdr[n].p_type == PT_LOAD + // && reladdr - l->l_phdr[n].p_vaddr >= 0 + // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) + // return 1; + // return 0; + // } + + if ((void*) info->dlpi_addr == s->l_addr) { + int n = info->dlpi_phnum; + while (--n >= 0) { + if (info->dlpi_phdr[n].p_type == PT_LOAD) { + NativeCodeRange* ncr = + stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); + ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); + ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); + + ncr->next = s->nc->nc_ranges; + s->nc->nc_ranges = ncr; + } + } + } + return 0; +} +#endif /* defined(HAVE_DLINFO) */ + +static void copyErrmsg(char** errmsg_dest, char* errmsg) { + if (errmsg == NULL) errmsg = "loadNativeObj_POSIX: unknown error"; + *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_POSIX"); + strcpy(*errmsg_dest, errmsg); +} + +void freeNativeCode_POSIX (ObjectCode *nc) { + ASSERT_LOCK_HELD(&linker_mutex); + + dlclose(nc->dlopen_handle); + + NativeCodeRange *ncr = nc->nc_ranges; + while (ncr) { + NativeCodeRange* last_ncr = ncr; + ncr = ncr->next; + stgFree(last_ncr); + } +} + +void * loadNativeObj_POSIX (pathchar *path, char **errmsg) +{ + ObjectCode* nc; + void *hdl, *retval; + + ASSERT_LOCK_HELD(&linker_mutex); + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX %" PATH_FMT "\n", path)); + + retval = NULL; + + + /* If we load the same object multiple times, just return the + * already-loaded handle. Note that this is broken if unloadNativeObj + * is used, as we don’t do any reference counting; see #24345. + */ + ObjectCode *existing_oc = lookupObjectByPath(path); + if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { + if (existing_oc->type == DYNAMIC_OBJECT) { + retval = existing_oc->dlopen_handle; + goto success; + } + copyErrmsg(errmsg, "loadNativeObj_POSIX: already loaded as non-dynamic object"); + goto dlopen_fail; + } + + nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); + + foreignExportsLoadingObject(nc); + + // When dlopen() loads a profiled dynamic library, it calls the ctors which + // will call registerCcsList() to append the defined CostCentreStacks to + // CCS_LIST. However, another thread may be doing other things with the RTS + // linker that transitively calls refreshProfilingCCSs() which also accesses + // CCS_LIST. So there's a risk of data race that may lead to segfaults + // (#24423), and we need to ensure the ctors are also protected by + // ccs_mutex. +#if defined(PROFILING) + ACQUIRE_LOCK(&ccs_mutex); +#endif + + // If we HAVE_DLINFO, we use RTLD_NOW rather than RTLD_LAZY because we want + // to learn eagerly about all external functions. Otherwise, there is no + // additional advantage to being eager, so it is better to be lazy and only bind + // functions when needed for better performance. + int dlopen_mode; +#if defined(HAVE_DLINFO) + dlopen_mode = RTLD_NOW; +#else + dlopen_mode = RTLD_LAZY; +#endif + + hdl = dlopen(path, dlopen_mode|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + nc->dlopen_handle = hdl; + nc->status = OBJECT_READY; + +#if defined(PROFILING) + RELEASE_LOCK(&ccs_mutex); +#endif + + foreignExportsFinishedLoadingObject(); + + if (hdl == NULL) { + /* dlopen failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlopen_fail; + } + +#if defined(HAVE_DLINFO) + struct link_map *map; + if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { + /* dlinfo failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlinfo_fail; + } + + hdl = NULL; // pass handle ownership to nc + + struct piterate_cb_info piterate_info = { + .nc = nc, + .l_addr = (void *) map->l_addr + }; + dl_iterate_phdr(loadNativeObjCb_, &piterate_info); + if (!nc->nc_ranges) { + copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); + goto dl_iterate_phdr_fail; + } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; +#endif /* defined (HAVE_DLINFO) */ + + insertOCSectionIndices(nc); + + nc->next_loaded_object = loaded_objects; + loaded_objects = nc; + + retval = nc->dlopen_handle; + +#if defined(PROFILING) + // collect any new cost centres that were defined in the loaded object. + refreshProfilingCCSs(); +#endif + + goto success; + +#if defined(HAVE_DLINFO) +dl_iterate_phdr_fail: +#endif + freeNativeCode_POSIX(nc); +#if defined(HAVE_DLINFO) +dlinfo_fail: +#endif + if (hdl) dlclose(hdl); +dlopen_fail: +success: + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX result=%p\n", retval)); + + return retval; +} + + ===================================== rts/linker/LoadNativeObjPosix.h ===================================== @@ -0,0 +1,11 @@ +#pragma once + +#include "Rts.h" +#include "LinkerInternals.h" + +#include "BeginPrivate.h" + +void freeNativeCode_POSIX ( ObjectCode *nc ); +void *loadNativeObj_POSIX ( pathchar *path, char **errmsg ); + +#include "EndPrivate.h" ===================================== rts/rts.cabal ===================================== @@ -458,6 +458,7 @@ library linker/Elf.c linker/InitFini.c linker/LoadArchive.c + linker/LoadNativeObjPosix.c linker/M32Alloc.c linker/MMap.c linker/MachO.c ===================================== testsuite/tests/ghci/linking/dyn/T3372.hs ===================================== @@ -1,3 +1,6 @@ +-- Note: This test exercises running concurrent GHCi sessions, but +-- although this test is expected to pass, running concurrent GHCi +-- sessions is currently broken in other ways; see #24345. {-# LANGUAGE MagicHash #-} module Main where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b3de3654dfdf9851658f5ba011a82b062558d12f...f699827724a3e95189fd9ddb7499a6a6abf11522 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b3de3654dfdf9851658f5ba011a82b062558d12f...f699827724a3e95189fd9ddb7499a6a6abf11522 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 19:34:12 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 27 Mar 2024 15:34:12 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-fix-famdecl-range Message-ID: <660474b4e0882_261593b86652c1288ab@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-fix-famdecl-range at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-fix-famdecl-range You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 21:44:38 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 27 Mar 2024 17:44:38 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/ghc-9.10 Message-ID: <660493465db02_261593f1b637c1410f0@gitlab.mail> Ben Gamari deleted branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 21:44:53 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 27 Mar 2024 17:44:53 -0400 Subject: [Git][ghc/ghc][ghc-9.10] 7 commits: mk-ghcup-metadata: Fix directory of testsuite tarball Message-ID: <660493556c957_261593f1e7e40141218@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 6f4b0335 by Ben Gamari at 2024-03-26T21:32:47-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. (cherry picked from commit 9d936c5799daadf96392211b03e38520925aea17) - - - - - 878e8529 by Ben Gamari at 2024-03-26T21:32:49-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. (cherry picked from commit 6d398066b6084a971248da8ce37bc40c53a83525) - - - - - 725343aa by Rodrigo Mesquita at 2024-03-26T22:34:19-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 (cherry picked from commit bf65a7c388b399b7b3c6b97f25d97164390b75f1) - - - - - 5dd67b52 by Alan Zimmerman at 2024-03-27T08:37:54-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. (cherry picked from commit 0acfe391583d77a72051d505f05fab0ada056c49) - - - - - 10829530 by Rodrigo Mesquita at 2024-03-27T08:38:20-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. (cherry picked from commit 32a8103f3b3e22907fdd67b69c919c5251d8cc20) - - - - - 3914808d by Cheng Shao at 2024-03-27T08:38:35-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. (cherry picked from commit 810660b780e1111b36c91326bcd0041e1f62706b) - - - - - 6ecd5f2f by Cheng Shao at 2024-03-27T08:38:49-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. (cherry picked from commit 7db8c9927fae3369fc4ecff68f80c4cb32eea757) - - - - - 10 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC/Parser.y - distrib/configure.ac.in - hadrian/bindist/Makefile - libffi-tarballs - m4/fp_cc_linker_flag_try.m4 - rts/ARMOutlineAtomicsSymbols.h - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PprLetIn.hs - testsuite/tests/printer/all.T Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -36,6 +36,7 @@ import os import yaml import gitlab from urllib.request import urlopen +from urllib.parse import urlparse import hashlib import sys import json @@ -80,7 +81,7 @@ source_artifact = Artifact('source-tarball' test_artifact = Artifact('source-tarball' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' - , 'ghc-{version}' ) + , 'ghc-{version}/testsuite' ) def debian(arch, n): return linux_platform(arch, "{arch}-linux-deb{n}".format(arch=arch, n=n)) @@ -156,13 +157,18 @@ def mk_one_metadata(release_mode, version, job_map, artifact): eprint(f"Bindist URL: {url}") eprint(f"Download URL: {final_url}") - #Download and hash from the release pipeline, this must not change anyway during upload. + # Download and hash from the release pipeline, this must not change anyway during upload. h = download_and_hash(url) res = { "dlUri": final_url , "dlSubdir": artifact.subdir.format(version=version) - , "dlOutput": artifact.output_name.format(version=version) , "dlHash" : h } + + # Only add dlOutput if it is inconsistent with the filename inferred from the URL + output = artifact.output_name.format(version=version) + if Path(urlparse(final_url).path).name != output: + res["dlOutput"] = output + eprint(res) return res ===================================== compiler/GHC/Parser.y ===================================== @@ -1438,10 +1438,10 @@ ty_fam_inst_eqns :: { Located [LTyFamInstEqn GhcPs] } h' <- addTrailingSemiA h (gl $2) return (sLL $1 $> ($3 : h' : t)) } | ty_fam_inst_eqns ';' {% case unLoc $1 of - [] -> return (sLL $1 $> (unLoc $1)) + [] -> return (sLZ $1 $> (unLoc $1)) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | ty_fam_inst_eqn { sLL $1 $> [$1] } | {- empty -} { noLoc [] } @@ -1719,12 +1719,12 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_cls { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1765,12 +1765,12 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_inst { sL1 $1 ([],unLoc $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1806,12 +1806,12 @@ decls :: { Located ([AddEpAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLL $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemiA $2) + then return (sLZ $1 $> (((fst $ unLoc $1) ++ (msemiA $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -3334,11 +3334,11 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs return (sLL $1 $> (fst $ unLoc $1,$3 : h' : t)) } | alts1(PATS) ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (fst $ unLoc $1, h' : t)) } + return (sLZ $1 $> (fst $ unLoc $1, h' : t)) } | alt(PATS) { $1 >>= \ $1 -> return $ sL1 $1 ([],[$1]) } alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) } @@ -3442,7 +3442,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} @@ -3552,7 +3552,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed | dbinds ';' {% case unLoc $1 of (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | dbind { let this = $1 in this `seq` (sL1 $1 [this]) } -- | {- empty -} { [] } @@ -4195,6 +4195,12 @@ sLLAsl :: (HasLoc a) => [a] -> Located b -> c -> Located c sLLAsl [] = sL1 sLLAsl (!x:_) = sLL x +{-# INLINE sLZ #-} +sLZ :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c +sLZ !x !y = if isZeroWidthSpan (getHasLoc y) + then sL (getHasLoc x) + else sL (comb2 x y) + {- Note [Adding location info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== distrib/configure.ac.in ===================================== @@ -105,6 +105,29 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) fi + +if test "$HostOS" = "darwin"; then + # On darwin, we need to clean the extended attributes of the + # ghc-toolchain binary and its dynamic library before we can execute it in the bindist + # (this is a workaround for #24554, for the lack of proper notarisation #17418) + + # The following is the work around suggested by @carter in #17418 during + # install time. This should help us with code signing issues by removing + # extended attributes from all files. + XATTR=${XATTR:-/usr/bin/xattr} + + if [ -e "${XATTR}" ]; then + + # Instead of cleaning the attributes of the ghc-toolchain binary only, + # we clean them from all files in the bin/ and lib/ directories, as it additionally future + # proofs running executables from the bindist besides ghc-toolchain at configure time, and + # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. + /usr/bin/xattr -rc bin/ + /usr/bin/xattr -rc lib/ + + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) ===================================== hadrian/bindist/Makefile ===================================== @@ -19,13 +19,6 @@ default: # TODO : find if a better function exists eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# the following is the work around suggested by @carter in #17418 during install -# time. This should help us with code signing issues by removing extended -# attributes from all files. -ifeq "$(Darwin_Host)" "YES" -XATTR ?= /usr/bin/xattr -endif - # patchpackageconf # # Hacky function to patch up the 'haddock-interfaces' and 'haddock-html' @@ -156,10 +149,6 @@ install_bin_libdir: $(INSTALL_PROGRAM) "$$i" "$(DESTDIR)$(ActualBinsDir)"; \ fi; \ done - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualBinsDir)"; \ - fi .PHONY: install_bin_direct install_bin_direct: @@ -194,10 +183,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ - fi .PHONY: install_docs install_docs: ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } ===================================== testsuite/tests/printer/Makefile ===================================== @@ -821,3 +821,8 @@ AnnotationNoListTuplePuns: Test24533: $(CHECK_PPR) $(LIBDIR) Test24533.hs $(CHECK_EXACT) $(LIBDIR) Test24533.hs + +.PHONY: PprLetIn +PprLetIn: + $(CHECK_PPR) $(LIBDIR) PprLetIn.hs + $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs ===================================== testsuite/tests/printer/PprLetIn.hs ===================================== @@ -0,0 +1,5 @@ +module PprLetIn where + +ff = let + x = 1 + in 4 ===================================== testsuite/tests/printer/all.T ===================================== @@ -197,3 +197,4 @@ test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) +test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/337a5073e23fcb82e6b341ce083708e736c9ea89...6ecd5f2ff97af53c7334f2d8581651203a2c6b7d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/337a5073e23fcb82e6b341ce083708e736c9ea89...6ecd5f2ff97af53c7334f2d8581651203a2c6b7d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Mar 27 23:24:25 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Wed, 27 Mar 2024 19:24:25 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24477 Message-ID: <6604aaa98b9e9_261593121c4f64162163@gitlab.mail> Jade pushed new branch wip/T24477 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24477 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 05:02:40 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 28 Mar 2024 01:02:40 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] 17 commits: rts: fix clang compilation on aarch64 Message-ID: <6604f9f0c7ddd_14cf9f7d44e89572f@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - a0c5b9ad by Apoorv Ingle at 2024-03-28T00:02:25-05:00 make applicative do work with expansions, possibly badly Fixes: #24406 - - - - - d5921c16 by Apoorv Ingle at 2024-03-28T00:02:25-05:00 enable the flow - - - - - dd11a4f1 by Apoorv Ingle at 2024-03-28T00:02:25-05:00 renaming do_or_lc to doFlavour and debugging error contexts - - - - - 3a809ed2 by Apoorv Ingle at 2024-03-28T00:02:25-05:00 testcases - - - - - 1d95b1ef by Apoorv Ingle at 2024-03-28T00:02:25-05:00 make sure app do expression statements location is mapped correctly - - - - - d7010192 by Apoorv Ingle at 2024-03-28T00:02:25-05:00 add flavour into OrigStmt to guide better error messages about qualified do. - - - - - a7b53c4a by Apoorv Ingle at 2024-03-28T00:02:25-05:00 add stmt and do flav info in OrigPat to improve error messages - - - - - 67ee05e6 by Apoorv Ingle at 2024-03-28T00:02:25-05:00 accepting some test cases ado003 and ado002 also fix for #16135 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - distrib/configure.ac.in - hadrian/bindist/Makefile - libffi-tarballs - m4/fp_cc_linker_flag_try.m4 - rts/ARMOutlineAtomicsSymbols.h - rts/js/profiling.js - − testsuite/tests/ado/T16135.stderr - testsuite/tests/ado/ado002.stderr - testsuite/tests/ado/ado003.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0047f94e045a074de02ea1fe61552492d5618153...67ee05e6dc80d67ef2c7b10d9cb8809e19215eae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0047f94e045a074de02ea1fe61552492d5618153...67ee05e6dc80d67ef2c7b10d9cb8809e19215eae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 10:58:52 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 28 Mar 2024 06:58:52 -0400 Subject: [Git][ghc/ghc][wip/mpickering-hannes] putFullBinHandle and shrinkBinBuffer Message-ID: <66054d6c99a86_25bec4a7bf84375d@gitlab.mail> Matthew Pickering pushed to branch wip/mpickering-hannes at Glasgow Haskell Compiler / GHC Commits: b073324a by Matthew Pickering at 2024-03-28T10:56:41+00:00 putFullBinHandle and shrinkBinBuffer - - - - - 4 changed files: - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -162,7 +162,7 @@ shareIface nc mi = do putWithUserData QuietBinIFace bh mi -- Copy out just the part of the buffer which is used, otherwise each interface -- retains a 1mb bytearray - bh' <- withBinBuffer bh (\bs -> unsafeUnpackBinBuffer (BS.copy bs)) + bh' <- shrinkBinBuffer bh res <- getWithUserData nc bh' let resiface = res { mi_src_hash = mi_src_hash mi } forceModIface resiface ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -2484,9 +2484,7 @@ instance Binary IfaceAlt where instance Binary IfaceExpr where - putNoStack_ bh (IfaceSerialisedExpr f) = do - deserialised <- getIfaceExpr =<< thawBinHandle f - putNoStack_ bh deserialised + putNoStack_ bh (IfaceSerialisedExpr f) = putFullBinData bh f putNoStack_ bh (IfaceLcl aa) = do putByte bh 0 put_ bh aa ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -2130,10 +2130,7 @@ instance Binary IfaceType where tbl -> getEntry tbl bh -putIfaceType bh (IfaceSerialisedType fb) = do -- putFullBinData bh fb - deserialised <- getIfaceType =<< thawBinHandle fb - putIfaceType bh deserialised - +putIfaceType bh (IfaceSerialisedType fb) = putFullBinData bh fb putIfaceType _ (IfaceFreeTyVar tv) = pprPanic "Can't serialise IfaceFreeTyVar" (ppr tv) ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Utils.Binary tellBin, castBin, withBinBuffer, + shrinkBinBuffer, foldGet, foldGet', @@ -111,7 +112,7 @@ import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe -import Data.ByteString (ByteString) +import Data.ByteString (ByteString, copy) import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS import Data.IORef @@ -232,6 +233,8 @@ data BinHandle _arr_r :: !(IORef BinArray), -- the array (bounds: (0,size-1)) prof :: {-# UNPACK #-} !BinProf } + -- XXX: should really store a "high water mark" for dumping out + -- the binary data to a file. data ProfKey = StringKey !String | TypeableKey !TypeRep deriving (Eq, Ord) @@ -250,8 +253,6 @@ addStack s (BinProf ss i) = (BinProf (TypeableKey s:ss) i) recordSample :: Int -> BinProf -> IO () recordSample _ _ = return () recordSample weight (BinProf ss i) = modifyIORef i (Map.insertWith (+) ss weight) - -- XXX: should really store a "high water mark" for dumping out - -- the binary data to a file. getUserData :: BinHandle -> UserData getUserData bh = bh_usr bh @@ -282,6 +283,17 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do bp <- initBinProf return (BinMem noUserData ix_r sz_r arr_r bp) +-- Copy the BinBuffer to a new BinBuffer which is exactly the right size. +-- This performs a copy of the underlying buffer. +-- The buffer may be truncated if the offset is not at the end of the written +-- output. +-- +-- UserData is also discarded during the copy +-- You should just use this when translating a Put handle into a Get handle. +shrinkBinBuffer :: BinHandle -> IO BinHandle +shrinkBinBuffer bh = withBinBuffer bh (\bs -> unsafeUnpackBinBuffer (copy bs)) + + --------------------------------------------------------------- -- Bin --------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b073324ae076b60e8cbc6ef411beb51ffc55b1f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b073324ae076b60e8cbc6ef411beb51ffc55b1f5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 11:32:32 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Thu, 28 Mar 2024 07:32:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T23782 Message-ID: <66055550a2356_25bec4ec2ae846812@gitlab.mail> Matthew Craven pushed new branch wip/T23782 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T23782 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 12:09:12 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 28 Mar 2024 08:09:12 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] More changes Message-ID: <66055de8b2cc2_25bec412cd73c5327b@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: b63dc6bb by Simon Peyton Jones at 2024-03-28T12:08:54+00:00 More changes - - - - - 8 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Utils.hs - testsuite/tests/simplCore/should_compile/T12877.hs - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T20040.stderr - testsuite/tests/simplStg/should_compile/T15226b.stderr Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -1641,21 +1641,31 @@ canUnfold (CoreUnfolding { uf_guidance = g }) = not (neverUnfoldGuidance g) canUnfold _ = False isBetterUnfoldingThan :: Unfolding -> Unfolding -> Bool --- Used in inlining checks +-- See Note [Better unfolding] isBetterUnfoldingThan NoUnfolding _ = False isBetterUnfoldingThan BootUnfolding _ = False -isBetterUnfoldingThan (CoreUnfolding {}) (CoreUnfolding {}) = False -isBetterUnfoldingThan (CoreUnfolding {}) _ = True +isBetterUnfoldingThan (CoreUnfolding {uf_cache = uc1}) unf2 + = case unf2 of + CoreUnfolding {uf_cache = uc2} -> uf_is_value uc1 && not (uf_is_value uc2) + OtherCon _ -> uf_is_value uc1 + _ -> True + -- Default case: CoreUnfolding better than NoUnfolding etc + -- Better than DFunUnfolding? I don't care. -isBetterUnfoldingThan (DFunUnfolding {}) (DFunUnfolding {}) = False -isBetterUnfoldingThan (DFunUnfolding {}) _ = True +isBetterUnfoldingThan (DFunUnfolding {}) unf2 + | DFunUnfolding {} <- unf2 = False + | otherwise = True -isBetterUnfoldingThan (OtherCon cs) (OtherCon cs') = not (null cs) && null cs' -- A bit crude -isBetterUnfoldingThan (OtherCon {}) (CoreUnfolding {}) = False -isBetterUnfoldingThan (OtherCon {}) (DFunUnfolding {}) = False -isBetterUnfoldingThan (OtherCon {}) NoUnfolding = True -isBetterUnfoldingThan (OtherCon {}) BootUnfolding = True +isBetterUnfoldingThan (OtherCon cs1) unf2 + = case unf2 of + CoreUnfolding {uf_cache = uc} -- If unf1 is OtherCon and unf2 is + -> not (uf_is_value uc) -- just a thunk, unf1 is better + + OtherCon cs2 -> not (null cs1) && null cs2 -- A bit crude + DFunUnfolding {} -> False + NoUnfolding -> True + BootUnfolding -> True {- Note [Fragile unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1671,6 +1681,20 @@ ones are We consider even a StableUnfolding as fragile, because it needs substitution. +Note [Better unfolding] +~~~~~~~~~~~~~~~~~~~~~~~ +(unf1 `isBetterUnfoldingThan` unf2) is used when we have + let x = in -- unf2 + let $j y = ...x... + in case x of + K a -> ...$j v.... + +At the /call site/ of $j, `x` has a better unfolding than it does at the +/defnition site/ of $j; so we are keener to inline $j. See +Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline for discussion. + +The notion of "better" is encapsulated here. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ When you say ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -3342,7 +3342,7 @@ simplAlts env0 scrut case_bndr alts cont' ; (alt_env', scrut', case_bndr') <- improveSeq fam_envs env2 scrut case_bndr case_bndr2 alts - ; (imposs_deflt_cons, in_alts) <- prepareAlts (seMode env0) scrut' case_bndr alts + ; (imposs_deflt_cons, in_alts) <- prepareAlts scrut' case_bndr alts -- NB: it's possible that the returned in_alts is empty: this is handled -- by the caller (rebuildCase) in the missingAlt function -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2404,17 +2404,15 @@ OutId. Test simplCore/should_compile/simpl013 apparently shows this up, although I'm not sure exactly how.. -} -prepareAlts :: SimplMode -> OutExpr -> InId -> [InAlt] -> SimplM ([AltCon], [InAlt]) +prepareAlts :: OutExpr -> InId -> [InAlt] -> SimplM ([AltCon], [InAlt]) -- The returned alternatives can be empty, none are possible -- -- Note that case_bndr is an InId; see Note [Shadowing in prepareAlts] -prepareAlts mode scrut case_bndr alts +prepareAlts scrut case_bndr alts | Just (tc, tys) <- splitTyConApp_maybe (idType case_bndr) = do { us <- getUniquesM - ; let (yes1, alts1) | sm_case_merge mode = mergeCaseAlts case_bndr alts - | otherwise = (False, alts) - -- See Note [Merging nested cases] - (idcs2, alts2) = filterAlts tc tys imposs_cons alts1 + ; let -- See Note [Merging nested cases] + (idcs2, alts2) = filterAlts tc tys imposs_cons alts (yes3, alts3) = refineDefaultAlt us (idMult case_bndr) tc tys idcs2 alts2 -- The multiplicity on case_bndr's is the multiplicity of the -- case expression The newly introduced patterns in @@ -2422,7 +2420,6 @@ prepareAlts mode scrut case_bndr alts (yes4, idcs4, alts4) = combineIdenticalAlts idcs2 alts3 -- "idcs" stands for "impossible default data constructors" -- i.e. the constructors that can't match the default case - ; when yes1 $ tick (CaseMerge case_bndr) ; when yes3 $ tick (FillInCaseDefault case_bndr) ; when yes4 $ tick (AltMerge case_bndr) ; return (idcs4, alts4) } @@ -2633,7 +2630,7 @@ and now we can do case-merge again, getting the desired -} -mkCase, mkCase2, mkCase3 +mkCase, mkCase1, mkCase2, mkCase3 :: SimplMode -> OutExpr -> OutId -> OutType -> [OutAlt] -- Alternatives in standard (increasing) order @@ -2646,12 +2643,26 @@ mkCase, mkCase2, mkCase3 -- Note [Cascading case merge] -------------------------------------------------- +mkCase mode scrut outer_bndr alts_ty alts + | sm_case_merge mode + , Just (joins, alts') <- mergeCaseAlts outer_bndr alts + = do { tick (CaseMerge outer_bndr) + ; case_expr <- mkCase1 mode scrut outer_bndr alts_ty alts' + ; return (mkLets joins case_expr) } + -- mkCase1: don't call mkCase recursively! + -- Firstly, there's no point, because inner alts have already had + -- mkCase applied to them, so they won't have a case in their default + -- Secondly, if you do, you get an infinite loop, because the bindCaseBndr + -- in munge_rhs may put a case into the DEFAULT branch! + | otherwise + = mkCase1 mode scrut outer_bndr alts_ty alts + -------------------------------------------------- -- 2. Eliminate Identity Case -- See Note [Eliminate Identity Case] -------------------------------------------------- -mkCase _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity case +mkCase1 _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity case | all identity_alt alts = do { tick (CaseIdentity case_bndr) ; return (mkTicks ticks $ re_cast scrut rhs1) } @@ -2690,7 +2701,8 @@ mkCase _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity case re_cast scrut (Cast rhs co) = Cast (re_cast scrut rhs) co re_cast scrut _ = scrut -mkCase mode scrut bndr alts_ty alts = mkCase2 mode scrut bndr alts_ty alts +mkCase1 mode scrut bndr alts_ty alts = mkCase2 mode scrut bndr alts_ty alts + -------------------------------------------------- -- 2. Scrutinee Constant Folding ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -71,6 +71,7 @@ import GHC.Platform import GHC.Core import GHC.Core.Ppr +import GHC.Core.FVs( bindFreeVars ) import GHC.Core.DataCon import GHC.Core.Type as Type import GHC.Core.FamInstEnv @@ -643,13 +644,70 @@ filters down the matching alternatives in GHC.Core.Opt.Simplify.rebuildCase. -} --------------------------------- -mergeCaseAlts :: Id -> [CoreAlt] -> (Bool, [CoreAlt]) --- Result: (yes, alts'); if 'yes' then something actually happened +mergeCaseAlts :: Id -> [CoreAlt] -> Maybe ([CoreBind], [CoreAlt]) -- See Note [Merge Nested Cases] +mergeCaseAlts outer_bndr alts + | (Alt DEFAULT _ deflt_rhs : outer_alts) <- alts + , Just (joins, inner_alts) <- go deflt_rhs + = Just (joins, mergeAlts outer_alts inner_alts) + -- NB: mergeAlts gives priority to the left + -- case x of + -- A -> e1 + -- DEFAULT -> case x of + -- A -> e2 + -- B -> e3 + -- When we merge, we must ensure that e1 takes + -- precedence over e2 as the value for A! + + | otherwise + = Nothing + + where + go :: CoreExpr -> Maybe ([CoreBind], [CoreAlt]) + go (Let bind body) + | any (== outer_bndr) (bindersOf bind) + = Nothing + | isJoinBind bind + , not (outer_bndr `elemVarSet` bindFreeVars bind) + = do { (joins, alts) <- go body + ; return (bind:joins, alts ) } + | otherwise + = Nothing + + -- Whizzo: we can merge! + go (Case (Var inner_scrut_var) inner_bndr _ inner_alts) + | inner_scrut_var == outer_bndr + , not (inner_bndr == outer_bndr) -- Avoid shadowing + , let wrap_let rhs' = Let (NonRec inner_bndr (Var outer_bndr)) rhs' + -- inner_bndr is never dead! It's the scrutinee! + -- The let is OK even for unboxed binders, + do_one (Alt con bndrs rhs) + | any (== outer_bndr) bndrs = Nothing + | otherwise = Just (Alt con bndrs (wrap_let rhs)) + = do { alts' <- mapM do_one inner_alts + ; return ([], alts') } + + -- Deal with tagToEnum# See See Note [Merge Nested Cases] wrinkle (MNC1) + go (App (App (Var f) (Type type_arg)) (Var v)) + | v == outer_bndr + , Just TagToEnumOp <- isPrimOpId_maybe f + , Just tc <- tyConAppTyCon_maybe type_arg + , Just (dc1:dcs) <- tyConDataCons_maybe tc -- At least one data constructor + , dcs `lengthAtMost` 3 -- Arbitrary + = return ( [], mk_alts dc1 dcs) + where + mk_lit dc = mkLitIntUnchecked $ toInteger $ dataConTagZ dc + mk_rhs dc = Var (dataConWorkId dc) + mk_alts dc1 dcs = Alt DEFAULT [] (mk_rhs dc1) + : [Alt (LitAlt (mk_lit dc)) [] (mk_rhs dc) | dc <- dcs] + + go _ = Nothing + +{- mergeCaseAlts outer_bndr alts | (Alt DEFAULT _ deflt_rhs : outer_alts) <- alts , Just inner_alts <- go 5 (\e -> e) emptyVarSet deflt_rhs - = (True, mergeAlts outer_alts inner_alts) + = Just (mergeAlts outer_alts inner_alts) -- NB: mergeAlts gives priority to the left -- case x of -- A -> e1 @@ -660,7 +718,7 @@ mergeCaseAlts outer_bndr alts -- precedence over e2 as the value for A! | otherwise - = (False, alts) + = Nothing where go :: Int -> (OutExpr -> OutExpr) -> VarSet -> OutExpr -> Maybe [OutAlt] -- In the call (go wrap free_bndrs rhs), the `wrap` function has free `free_bndrs`; @@ -714,7 +772,7 @@ mergeCaseAlts outer_bndr alts = go (n-1) (wrap . wrap_case) (free_bndrs `extendVarSet` inner_scrut) rhs go _ _ _ _ = Nothing - +-} --------------------------------- mergeAlts :: [Alt a] -> [Alt a] -> [Alt a] @@ -851,7 +909,7 @@ variable is scrutinised multiple times. Wrinkles -(MC1) `tryMergeCase` "looks though" an inner single-alternative case-on-variable. +(MC1) `mergeCaseAlts` "looks though" an inner single-alternative case-on-variable. For example case x of { ...outer-alts... @@ -880,7 +938,7 @@ Wrinkles IS y2 -> tagToEnum# @Bool (==# x2 y2) }; IP x2 -> ... IN x2 -> ... - We want to merge the outer `case x` with thea inner `case x1`. + We want to merge the outer `case x` with the inner `case x1`. This story is not fully robust; it will be defeated by a let-binding, whih we don't want to duplicate. But accounting for single-alternative ===================================== testsuite/tests/simplCore/should_compile/T12877.hs ===================================== @@ -21,7 +21,7 @@ test x = case x of t -> case t + 1 of 3 -> "0" 4 -> "1" - t -> case t + 1 of + t -> "n" {- case t + 1 of 4 -> "0" 5 -> "1" t -> case t + 1 of @@ -112,3 +112,4 @@ test x = case x of 34 -> "0" 35 -> "1" _ -> "n" +-} ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -165,9 +165,9 @@ mapMaybeRule [InlPrag=[2]] Result s b #))) s1 of - { (# ipv [Occ=Once1], ipv1 [Occ=Once1!] #) -> - case ipv1 of { Result t2 [Occ=Once1] c1 [Occ=Once1] -> - (# ipv, + { (# new_s [Occ=Once1], a2 [Occ=Once1!] #) -> + case a2 of { Result t2 [Occ=Once1] c1 [Occ=Once1] -> + (# new_s, T18013a.Result @s @(Maybe b) t2 (GHC.Internal.Maybe.Just @b c1) #) } } @@ -207,9 +207,9 @@ mapMaybeRule Result s b #))) s1 of - { (# ipv, ipv1 #) -> - case ipv1 of { Result t2 c1 -> - (# ipv, + { (# new_s, a2 #) -> + case a2 of { Result t2 c1 -> + (# new_s, T18013a.Result @s @(Maybe b) t2 (GHC.Internal.Maybe.Just @b c1) #) } } ===================================== testsuite/tests/simplCore/should_compile/T20040.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Final STG: ==================== -$WNil = CCS_DONT_CARE Nil! []; +$WNil = Nil! []; -$WCons = \r [conrep conrep] Cons [conrep conrep]; +$WCons = \r [conrep conrep1] Cons [conrep conrep1]; unSucc1 = \r [ds] ds; @@ -11,12 +11,11 @@ unSucc = \r [eta] unSucc1 eta; Rec { ifoldl' = \r [f z ds] - case ds of { + case ds of wild { Nil -> z; - Cons ipv2 ipv3 -> + Cons x xs -> case z of z1 { - __DEFAULT -> - case f z1 ipv2 of sat { __DEFAULT -> ifoldl' f sat ipv3; }; + __DEFAULT -> case f z1 x of sat { __DEFAULT -> ifoldl' f sat xs; }; }; }; end Rec } @@ -25,7 +24,7 @@ Nil = \r [void] Nil []; Cons = \r [void eta eta] Cons [eta eta]; -Z = CCS_DONT_CARE Z! []; +Z = Z! []; S = \r [eta] S [eta]; ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -20,13 +20,13 @@ T15226b.testFun1 [GblId, Arity=3, Str=, Unf=OtherCon []] = {} \r [x y void] case seq# [x GHC.Prim.void#] of ds1 { - (# #) ipv1 [Occ=Once1] -> + (# #) a1 [Occ=Once1] -> let { sat [Occ=Once1] :: T15226b.StrictPair a b [LclId] = - {ipv1, y} \u [] + {a1, y} \u [] case y of conrep { - __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep]; + __DEFAULT -> T15226b.MkStrictPair [a1 conrep]; }; } in seq# [sat GHC.Prim.void#]; }; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b63dc6bbb1de5f63b6d88253ea42cdf9cea1ce3e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b63dc6bbb1de5f63b6d88253ea42cdf9cea1ce3e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 12:16:16 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 28 Mar 2024 08:16:16 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] Error message wibbles Message-ID: <66055f906bc37_25bec414242345442@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 606a08b5 by Simon Peyton Jones at 2024-03-28T12:15:59+00:00 Error message wibbles - - - - - 2 changed files: - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr Changes: ===================================== testsuite/tests/arityanal/should_compile/Arity01.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 65, types: 41, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 71, types: 43, coercions: 0, joins: 0/0} -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} F1.f2 :: Integer @@ -8,14 +8,18 @@ F1.f2 :: Integer F1.f2 = GHC.Num.Integer.IS 1# Rec { --- RHS size: {terms: 18, types: 4, coercions: 0, joins: 0/0} +-- RHS size: {terms: 24, types: 6, coercions: 0, joins: 0/0} F1.f1_h1 [Occ=LoopBreaker] :: Integer -> Integer -> Integer -> Integer -[GblId, Arity=3, Str=, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] F1.f1_h1 - = \ (n :: Integer) (x :: Integer) (eta :: Integer) -> - case GHC.Num.Integer.integerLt x n of { - False -> eta; - True -> F1.f1_h1 n (GHC.Num.Integer.integerAdd x F1.f2) (GHC.Num.Integer.integerAdd x eta) + = \ (n :: Integer) (x :: Integer) (eta [OS=OneShot] :: Integer) -> + case x of x1 { __DEFAULT -> + case n of y1 { __DEFAULT -> + case GHC.Num.Integer.integerLt# x1 y1 of { + __DEFAULT -> eta; + 1# -> F1.f1_h1 y1 (GHC.Num.Integer.integerAdd x1 F1.f2) (GHC.Num.Integer.integerAdd x1 eta) + } + } } end Rec } ===================================== testsuite/tests/arityanal/should_compile/Arity02.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 38, types: 23, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 51, types: 27, coercions: 0, joins: 0/0} -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} F2.f1 :: Integer @@ -18,14 +18,19 @@ lvl :: Integer lvl = GHC.Num.Integer.IS 1# Rec { --- RHS size: {terms: 16, types: 3, coercions: 0, joins: 0/0} +-- RHS size: {terms: 29, types: 7, coercions: 0, joins: 0/0} F2.f2_g [Occ=LoopBreaker] :: Integer -> Integer -> Integer -[GblId, Arity=2, Str=, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] F2.f2_g = \ (x :: Integer) (y :: Integer) -> - case GHC.Num.Integer.integerGt x F2.f1 of { - False -> y; - True -> F2.f2_g (GHC.Num.Integer.integerSub x lvl) (GHC.Num.Integer.integerAdd x y) + case x of x1 { + GHC.Num.Integer.IS x2 -> + case GHC.Prim.># x2 0# of { + __DEFAULT -> y; + 1# -> F2.f2_g (GHC.Num.Integer.integerSub x1 lvl) (GHC.Num.Integer.integerAdd x1 y) + }; + GHC.Num.Integer.IP x2 -> F2.f2_g (GHC.Num.Integer.integerSub x1 lvl) (GHC.Num.Integer.integerAdd x1 y); + GHC.Num.Integer.IN x2 -> y } end Rec } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/606a08b5f3126921be99e6255087476aa359862e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/606a08b5f3126921be99e6255087476aa359862e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 13:28:43 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 28 Mar 2024 09:28:43 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) Message-ID: <6605708af3566_25bec41c40be8635a@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: fcb5bb72 by Andrei Borzenkov at 2024-03-28T17:28:18+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 11 changed files: - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/Language/Haskell/Syntax/Type.hs - testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout - + testsuite/tests/th/T24299.hs - + testsuite/tests/th/T24299.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -677,7 +677,7 @@ References: [2] 'rnSpliceExpr' [3] 'GHC.Tc.Gen.Splice.qAddModFinalizer' [4] 'GHC.Tc.Gen.Expr.tcExpr' ('HsSpliceE' ('HsSpliced' ...)) -[5] 'GHC.Tc.Gen.HsType.tc_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) +[5] 'GHC.Tc.Gen.HsType.tc_check_hs_type' ('HsSpliceTy' ('HsSpliced' ...)) [6] 'GHC.Tc.Gen.Pat.tc_pat' ('SplicePat' ('HsSpliced' ...)) -} ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -1678,7 +1678,7 @@ tcRhs (TcPatBind infos pat' mult mult_ann grhss pat_ty) -- is generated so that multiplicity can be inferred. tcMultAnn :: HsMultAnn GhcRn -> TcM Mult tcMultAnn (HsPct1Ann _) = return oneDataConTy -tcMultAnn (HsMultAnn _ p) = tcCheckLHsType p (TheKind multiplicityTy) +tcMultAnn (HsMultAnn _ p) = tcCheckLHsTypeInContext p (TheKind multiplicityTy) tcMultAnn (HsNoMultAnn _) = newFlexiTyVarTy multiplicityTy tcExtendTyVarEnvForRhs :: Maybe TcIdSigInst -> TcM a -> TcM a ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -56,7 +56,7 @@ module GHC.Tc.Gen.HsType ( tcHsLiftedType, tcHsOpenType, tcHsLiftedTypeNC, tcHsOpenTypeNC, tcInferLHsType, tcInferLHsTypeKind, tcInferLHsTypeUnsaturated, - tcCheckLHsType, + tcCheckLHsTypeInContext, tcHsContext, tcLHsPredType, kindGeneralizeAll, @@ -397,7 +397,7 @@ kcClassSigType names sig_ty@(L _ (HsSig { sig_bndrs = hs_outer_bndrs, sig_body = hs_ty })) = addSigCtxt (funsSigCtxt names) sig_ty $ do { _ <- bindOuterSigTKBndrs_Tv hs_outer_bndrs $ - tcLHsType hs_ty liftedTypeKind + tcCheckLHsType hs_ty liftedTypeKind ; return () } tcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM Type @@ -467,7 +467,7 @@ tc_lhs_sig_type skol_info full_hs_ty@(L loc (HsSig { sig_bndrs = hs_outer_bndrs do { exp_kind <- newExpectedKind ctxt_kind -- See Note [Escaping kind in type signatures] ; stuff <- tcOuterTKBndrs skol_info hs_outer_bndrs $ - tcLHsType hs_ty exp_kind + tcCheckLHsType hs_ty exp_kind ; return (exp_kind, stuff) } -- Default any unconstrained variables free in the kind @@ -609,7 +609,7 @@ tc_top_lhs_type tyki ctxt (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs <- pushLevelAndSolveEqualitiesX "tc_top_lhs_type" $ tcOuterTKBndrs skol_info hs_outer_bndrs $ do { kind <- newExpectedKind (expectedKindInCtxt ctxt) - ; tc_lhs_type (mkMode tyki) body kind } + ; tc_check_lhs_type (mkMode tyki) body kind } ; outer_bndrs <- scopedSortOuter outer_bndrs ; let outer_tv_bndrs = outerTyVarBndrs outer_bndrs @@ -704,7 +704,7 @@ tcHsTypeApp wc_ty kind -- We are looking at a user-written type, very like a -- signature so we want to solve its equalities right now bindNamedWildCardBinders sig_wcs $ \ _ -> - tc_lhs_type mode hs_ty kind + tc_check_lhs_type mode hs_ty kind -- We do not kind-generalize type applications: we just -- instantiate with exactly what the user says. @@ -720,7 +720,7 @@ tcHsTypeApp wc_ty kind ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A HsWildCardBndrs's hswc_ext now only includes /named/ wildcards, so any unnamed wildcards stay unchanged in hswc_body. When called in -tcHsTypeApp, tcCheckLHsType will call emitAnonTypeHole +tcHsTypeApp, tcCheckLHsTypeInContext will call emitAnonTypeHole on these anonymous wildcards. However, this would trigger error/warning when an anonymous wildcard is passed in as a visible type argument, which we do not want because users should be able to write @@ -790,10 +790,10 @@ We work this out in a hacky way, by looking at the expected kind: see Note [Inferring tuple kinds]. In this case, we kind-check the RHS using the kind gotten from the LHS: -see the call to tcCheckLHsType in tcTyFamInstEqnGuts in GHC.Tc.Tycl. +see the call to tcCheckLHsTypeInContext in tcTyFamInstEqnGuts in GHC.Tc.Tycl. But we want the kind from the LHS to be /zonked/, so that when -kind-checking the RHS (tcCheckLHsType) we can "see" what we learned +kind-checking the RHS (tcCheckLHsTypeInContext) we can "see" what we learned from kind-checking the LHS (tcFamTyPats). In our example above, the type of the LHS is just `kappa` (by instantiating the forall k), but then we learn (from x::Constraint) that kappa ~ Constraint. We want @@ -821,15 +821,15 @@ tcHsOpenType, tcHsLiftedType, tcHsOpenType hs_ty = addTypeCtxt hs_ty $ tcHsOpenTypeNC hs_ty tcHsLiftedType hs_ty = addTypeCtxt hs_ty $ tcHsLiftedTypeNC hs_ty -tcHsOpenTypeNC hs_ty = do { ek <- newOpenTypeKind; tcLHsType hs_ty ek } -tcHsLiftedTypeNC hs_ty = tcLHsType hs_ty liftedTypeKind +tcHsOpenTypeNC hs_ty = do { ek <- newOpenTypeKind; tcCheckLHsType hs_ty ek } +tcHsLiftedTypeNC hs_ty = tcCheckLHsType hs_ty liftedTypeKind --- Like tcHsType, but takes an expected kind -tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType -tcCheckLHsType hs_ty exp_kind +-- Like tcCheckLHsType, but takes an expected kind +tcCheckLHsTypeInContext :: LHsType GhcRn -> ContextKind -> TcM TcType +tcCheckLHsTypeInContext hs_ty exp_kind = addTypeCtxt hs_ty $ do { ek <- newExpectedKind exp_kind - ; tcLHsType hs_ty ek } + ; tcCheckLHsType hs_ty ek } tcInferLHsType :: LHsType GhcRn -> TcM TcType tcInferLHsType hs_ty @@ -854,7 +854,7 @@ tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ do { mode <- mkHoleMode TypeLevel HM_Sig -- Allow and report holes - ; case splitHsAppTys (unLoc hs_ty) of + ; case splitHsAppTys_maybe (unLoc hs_ty) of Just (hs_fun_ty, hs_args) -> do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty ; tcInferTyApps_nosat mode hs_fun_ty fun_ty hs_args } @@ -890,12 +890,18 @@ Terms are eagerly instantiated. This means that if you say x = id then `id` gets instantiated to have type alpha -> alpha. The variable -alpha is then unconstrained and regeneralized. But we cannot do this -in types, as we have no type-level lambda. So, when we are sure -that we will not want to regeneralize later -- because we are done -checking a type, for example -- we can instantiate. But we do not -instantiate at variables, nor do we in tcInferLHsTypeUnsaturated, -which is used by :kind in GHCi. +alpha is then unconstrained and regeneralized. So we may well end up with + x = /\x. id @a +But we cannot do this in types, as we have no type-level lambda. + +So, we must be careful only to instantiate at the last possible moment, when +we're sure we're never going to want the lost polymorphism again. This is done +in calls to `tcInstInvisibleTyBinders`; a particular case in point is in +`checkExpectedKind`. + +Otherwise, we are careful /not/ to instantiate. For example: +* at a variable in `tcTyVar` +* in `tcInferLHsTypeUnsaturated`, which is used by :kind in GHCi. ************************************************************************ * * @@ -969,48 +975,18 @@ instance Outputable TcTyMode where {- Note [Bidirectional type checking] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In expressions, whenever we see a polymorphic identifier, say `id`, we are -free to instantiate it with metavariables, knowing that we can always -re-generalize with type-lambdas when necessary. For example: - - rank2 :: (forall a. a -> a) -> () - x = rank2 id - -When checking the body of `x`, we can instantiate `id` with a metavariable. -Then, when we're checking the application of `rank2`, we notice that we really -need a polymorphic `id`, and then re-generalize over the unconstrained -metavariable. - -In types, however, we're not so lucky, because *we cannot re-generalize*! -There is no lambda. So, we must be careful only to instantiate at the last -possible moment, when we're sure we're never going to want the lost polymorphism -again. This is done in calls to tcInstInvisibleTyBinders. - -To implement this behavior, we use bidirectional type checking, where we -explicitly think about whether we know the kind of the type we're checking -or not. Note that there is a difference between not knowing a kind and -knowing a metavariable kind: the metavariables are TauTvs, and cannot become -forall-quantified kinds. Previously (before dependent types), there were -no higher-rank kinds, and so we could instantiate early and be sure that -no types would have polymorphic kinds, and so we could always assume that -the kind of a type was a fresh metavariable. Not so anymore, thus the -need for two algorithms. - -For HsType forms that can never be kind-polymorphic, we implement only the -"down" direction, where we safely assume a metavariable kind. For HsType forms -that *can* be kind-polymorphic, we implement just the "up" (functions with -"infer" in their name) version, as we gain nothing by also implementing the -"down" version. - -Note [Future-proofing the type checker] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As discussed in Note [Bidirectional type checking], each HsType form is -handled in *either* tc_infer_hs_type *or* tc_hs_type. These functions -are mutually recursive, so that either one can work for any type former. -But, we want to make sure that our pattern-matches are complete. So, -we have a bunch of repetitive code just so that we get warnings if we're -missing any patterns. +In types, as in terms, we use bidirectional type infefence. The main workhorse +function looks like this: + type ExpKind = ExpType + data ExpType = Check TcSigmaKind | Infer ...(hole TcRhoType)... + + tcHsType :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType + +* When the `ExpKind` argument is (Check ki), we /check/ that the type has + kind `ki` +* When the `ExpKind` argument is (Infer hole), we /infer/ the kind of the + type, and fill the hole with that kind -} ------------------------------------------ @@ -1022,74 +998,13 @@ tc_infer_lhs_type mode (L span ty) = setSrcSpanA span $ tc_infer_hs_type mode ty ---------------------------- --- | Call 'tc_infer_hs_type' and check its result against an expected kind. -tc_infer_hs_type_ek :: HasDebugCallStack => TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType -tc_infer_hs_type_ek mode hs_ty ek - = do { (ty, k) <- tc_infer_hs_type mode hs_ty - ; checkExpectedKind hs_ty ty k ek } - --------------------------- -- | Infer the kind of a type and desugar. This is the "up" type-checker, -- as described in Note [Bidirectional type checking] tc_infer_hs_type :: TcTyMode -> HsType GhcRn -> TcM (TcType, TcKind) -tc_infer_hs_type mode (HsParTy _ t) - = tc_infer_lhs_type mode t - -tc_infer_hs_type mode ty - | Just (hs_fun_ty, hs_args) <- splitHsAppTys ty - = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty - ; tcInferTyApps mode hs_fun_ty fun_ty hs_args } - -tc_infer_hs_type mode (HsKindSig _ ty sig) - = do { let mode' = mode { mode_tyki = KindLevel } - ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig - -- We must typecheck the kind signature, and solve all - -- its equalities etc; from this point on we may do - -- things like instantiate its foralls, so it needs - -- to be fully determined (#14904) - ; traceTc "tc_infer_hs_type:sig" (ppr ty $$ ppr sig') - ; ty' <- tcAddKindSigPlaceholders sig $ - tc_lhs_type mode ty sig' - ; return (ty', sig') } - --- HsSpliced is an annotation produced by 'GHC.Rename.Splice.rnSpliceType' to communicate --- the splice location to the typechecker. Here we skip over it in order to have --- the same kind inferred for a given expression whether it was produced from --- splices or not. --- --- See Note [Delaying modFinalizers in untyped splices]. -tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ 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) - -tc_infer_hs_type mode (HsDocTy _ ty _) = tc_infer_lhs_type mode ty - --- See Note [Typechecking HsCoreTys] -tc_infer_hs_type _ (XHsType ty) - = do env <- getLclEnv - -- Raw uniques since we go from NameEnv to TvSubstEnv. - let subst_prs :: [(Unique, TcTyVar)] - subst_prs = [ (getUnique nm, tv) - | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] - subst = mkTvSubst - (mkInScopeSetList $ map snd subst_prs) - (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) - ty' = substTy subst ty - return (ty', typeKind ty') - -tc_infer_hs_type _ (HsExplicitListTy _ _ tys) - | null tys -- this is so that we can use visible kind application with '[] - -- e.g ... '[] @Bool - = return (mkTyConTy promotedNilDataCon, - mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy) - -tc_infer_hs_type mode other_ty - = do { kv <- newMetaKindVar - ; ty' <- tc_hs_type mode other_ty kv - ; return (ty', kv) } +tc_infer_hs_type mode rn_ty + = tcInfer $ \exp_kind -> tcHsType mode rn_ty exp_kind {- Note [Typechecking HsCoreTys] @@ -1133,26 +1048,36 @@ substitution to each HsCoreTy and all is well: -} ------------------------------------------ -tcLHsType :: LHsType GhcRn -> TcKind -> TcM TcType -tcLHsType hs_ty exp_kind - = tc_lhs_type typeLevelMode hs_ty exp_kind +tcCheckLHsType :: LHsType GhcRn -> TcKind -> TcM TcType +tcCheckLHsType hs_ty exp_kind + = tc_check_lhs_type typeLevelMode hs_ty exp_kind + +tc_check_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType +tc_check_lhs_type mode (L span ty) exp_kind + = setSrcSpanA span $ + tc_check_hs_type mode ty exp_kind -tc_lhs_type :: TcTyMode -> LHsType GhcRn -> TcKind -> TcM TcType -tc_lhs_type mode (L span ty) exp_kind +tc_check_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +-- See Note [Bidirectional type checking] +tc_check_hs_type mode ty ek = tcHsType mode ty (Check ek) + +tcLHsType :: TcTyMode -> LHsType GhcRn -> ExpKind -> TcM TcType +tcLHsType mode (L span ty) exp_kind = setSrcSpanA span $ - tc_hs_type mode ty exp_kind + tcHsType mode ty exp_kind -tc_hs_type :: TcTyMode -> HsType GhcRn -> TcKind -> TcM TcType +tcHsType :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +-- The main workhorse for type kind checking -- See Note [Bidirectional type checking] -tc_hs_type mode (HsParTy _ ty) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type mode (HsDocTy _ ty _) exp_kind = tc_lhs_type mode ty exp_kind -tc_hs_type _ ty@(HsBangTy _ bang _) _ +tcHsType mode (HsParTy _ ty) exp_kind = tcLHsType mode ty exp_kind +tcHsType mode (HsDocTy _ ty _) exp_kind = tcLHsType mode ty exp_kind +tcHsType _ ty@(HsBangTy _ bang _) _ -- While top-level bangs at this point are eliminated (eg !(Maybe Int)), -- other kinds of bangs are not (eg ((!Maybe) Int)). These kinds of -- bangs are invalid, so fail. (#7210, #14761) = failWith $ TcRnUnexpectedAnnotation ty bang -tc_hs_type _ ty@(HsRecTy {}) _ +tcHsType _ ty@(HsRecTy {}) _ -- Record types (which only show up temporarily in constructor -- signatures) should have been removed by now = failWithTc $ TcRnIllegalRecordSyntax (Right ty) @@ -1162,23 +1087,23 @@ tc_hs_type _ ty@(HsRecTy {}) _ -- while capturing the local environment. -- -- See Note [Delaying modFinalizers in untyped splices]. -tc_hs_type mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) +tcHsType mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) exp_kind = do addModFinalizersWithLclEnv mod_finalizers - tc_lhs_type mode ty exp_kind + tcLHsType mode ty exp_kind -tc_hs_type _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type: invalid nested splice" (pprUntypedSplice True (Just n) s) +tcHsType _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tcHsType: invalid nested splice" (pprUntypedSplice True (Just n) s) ---------- Functions and applications -tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind +tcHsType mode (HsFunTy _ mult ty1 ty2) exp_kind = tc_fun_type mode mult ty1 ty2 exp_kind -tc_hs_type mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind +tcHsType mode (HsOpTy _ _ ty1 (L _ op) ty2) exp_kind | op `hasKey` unrestrictedFunTyConKey = tc_fun_type mode (HsUnrestrictedArrow noExtField) ty1 ty2 exp_kind --------- Foralls -tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind +tcHsType mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllInvis{} <- tele = tc_hs_forall_ty tele ty exp_kind -- For an invisible forall, we allow the body to have @@ -1187,15 +1112,15 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind | HsForAllVis{} <- tele = do { ek <- newOpenTypeKind - ; r <- tc_hs_forall_ty tele ty ek - ; checkExpectedKind t r ek exp_kind } + ; r <- tc_hs_forall_ty tele ty (Check ek) + ; checkExpKind t r ek exp_kind } -- For a visible forall, we require that the body is of kind TYPE r. -- See Note [Body kind of a HsForAllTy] where tc_hs_forall_ty tele ty ek = do { (tv_bndrs, ty') <- tcTKTelescope mode tele $ - tc_lhs_type mode ty ek + tcLHsType mode ty ek -- Pass on the mode from the type, to any wildcards -- in kind signatures on the forall'd variables -- e.g. f :: _ -> Int -> forall (a :: _). blah @@ -1203,145 +1128,196 @@ tc_hs_type mode t@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind -- Do not kind-generalise here! See Note [Kind generalisation] ; return (mkForAllTys tv_bndrs ty') } -tc_hs_type mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind +tcHsType mode (HsQualTy { hst_ctxt = ctxt, hst_body = rn_ty }) exp_kind | null (unLoc ctxt) - = tc_lhs_type mode rn_ty exp_kind - - -- See Note [Body kind of a HsQualTy] - | isConstraintLikeKind exp_kind + = tcLHsType mode rn_ty exp_kind + -- See Note [Body kind of a HsQualTy] + | Check kind <- exp_kind, isConstraintLikeKind kind = do { ctxt' <- tc_hs_context mode ctxt - ; ty' <- tc_lhs_type mode rn_ty constraintKind - ; return (tcMkDFunPhiTy ctxt' ty') } + ; ty' <- tc_check_lhs_type mode rn_ty constraintKind + ; return (tcMkDFunPhiTy ctxt' ty') } | otherwise = do { ctxt' <- tc_hs_context mode ctxt - ; ek <- newOpenTypeKind -- The body kind (result of the function) can + ; ek <- newOpenTypeKind -- The body kind (result of the function) can -- be TYPE r, for any r, hence newOpenTypeKind - ; ty' <- tc_lhs_type mode rn_ty ek - ; checkExpectedKind (unLoc rn_ty) (tcMkPhiTy ctxt' ty') - liftedTypeKind exp_kind } + ; ty' <- tc_check_lhs_type mode rn_ty ek + ; let res_ty = tcMkPhiTy ctxt' ty' + ; checkExpKind (unLoc rn_ty) res_ty + liftedTypeKind exp_kind } --------- Lists, arrays, and tuples -tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind - = do { tau_ty <- tc_lhs_type mode elt_ty liftedTypeKind +tcHsType mode rn_ty@(HsListTy _ elt_ty) exp_kind + = do { tau_ty <- tc_check_lhs_type mode elt_ty liftedTypeKind ; checkWiredInTyCon listTyCon - ; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } + ; checkExpKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind } --- See Note [Distinguishing tuple kinds] in Language.Haskell.Syntax.Type --- See Note [Inferring tuple kinds] -tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind - -- (NB: not zonking before looking at exp_k, to avoid left-right bias) - | Just tup_sort <- tupKindSort_maybe exp_kind - = traceTc "tc_hs_type tuple" (ppr hs_tys) >> - tc_tuple rn_ty mode tup_sort hs_tys exp_kind - | otherwise - = do { traceTc "tc_hs_type tuple 2" (ppr hs_tys) - ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys - ; kinds <- liftZonkM $ mapM zonkTcType kinds - -- Infer each arg type separately, because errors can be - -- confusing if we give them a shared kind. Eg #7410 - -- (Either Int, Int), we do not want to get an error saying - -- "the second argument of a tuple should have kind *->*" +tcHsType mode rn_ty@(HsTupleTy _ tup_sort tys) exp_kind + = do k <- expTypeToType exp_kind + tc_hs_tuple_ty rn_ty mode tup_sort tys k - ; let (arg_kind, tup_sort) - = case [ (k,s) | k <- kinds - , Just s <- [tupKindSort_maybe k] ] of - ((k,s) : _) -> (k,s) - [] -> (liftedTypeKind, BoxedTuple) - -- In the [] case, it's not clear what the kind is, so guess * - - ; tys' <- sequence [ setSrcSpanA loc $ - checkExpectedKind hs_ty ty kind arg_kind - | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] - - ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } - - -tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind - = tc_tuple rn_ty mode UnboxedTuple tys exp_kind - -tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind +tcHsType mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys ; arg_kinds <- mapM (\_ -> newOpenTypeKind) hs_tys - ; tau_tys <- zipWithM (tc_lhs_type mode) hs_tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) hs_tys arg_kinds ; let arg_reps = map kindRep arg_kinds arg_tys = arg_reps ++ tau_tys sum_ty = mkTyConApp (sumTyCon arity) arg_tys sum_kind = unboxedSumKind arg_reps - ; checkExpectedKind rn_ty sum_ty sum_kind exp_kind + ; checkExpKind rn_ty sum_ty sum_kind exp_kind } --------- Promoted lists and tuples -tc_hs_type mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind - -- The '[] case is handled in tc_infer_hs_type. - -- See Note [Future-proofing the type checker]. +tcHsType mode rn_ty@(HsExplicitListTy _ _ tys) exp_kind + -- See Note [Kind-checking explicit lists] + | null tys - = tc_infer_hs_type_ek mode rn_ty exp_kind + = do let ty = mkTyConTy promotedNilDataCon + let kind = mkSpecForAllTys [alphaTyVar] $ mkListTy alphaTy + checkExpKind rn_ty ty kind exp_kind | otherwise = do { tks <- mapM (tc_infer_lhs_type mode) tys ; (taus', kind) <- unifyKinds tys tks ; let ty = (foldr (mk_cons kind) (mk_nil kind) taus') - ; checkExpectedKind rn_ty ty (mkListTy kind) exp_kind } + ; checkExpKind rn_ty ty (mkListTy kind) exp_kind } where mk_cons k a b = mkTyConApp (promoteDataCon consDataCon) [k, a, b] mk_nil k = mkTyConApp (promoteDataCon nilDataCon) [k] -tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind +tcHsType mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind -- using newMetaKindVar means that we force instantiations of any polykinded -- types. At first, I just used tc_infer_lhs_type, but that led to #11255. = do { ks <- replicateM arity newMetaKindVar - ; taus <- zipWithM (tc_lhs_type mode) tys ks + ; taus <- zipWithM (tc_check_lhs_type mode) tys ks ; let kind_con = tupleTyCon Boxed arity ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks ; checkTupSize arity - ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } + ; checkExpKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys --------- Constraint types -tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind +tcHsType mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind = do { massert (isTypeLevel (mode_tyki mode)) - ; ty' <- tc_lhs_type mode ty liftedTypeKind + ; ty' <- tc_check_lhs_type mode ty liftedTypeKind ; let n' = mkStrLitTy $ hsIPNameFS n ; ipClass <- tcLookupClass ipClassName - ; checkExpectedKind rn_ty (mkClassPred ipClass [n',ty']) + ; checkExpKind rn_ty (mkClassPred ipClass [n',ty']) constraintKind exp_kind } -tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind +tcHsType _ rn_ty@(HsStarTy _ _) exp_kind -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't -- have to handle it in 'coreView' - = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + = checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind --------- Literals -tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind +tcHsType _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon naturalTyCon - ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } + ; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind +tcHsType _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon - ; checkExpectedKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } -tc_hs_type _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind + ; checkExpKind rn_ty (mkStrLitTy s) typeSymbolKind exp_kind } +tcHsType _ rn_ty@(HsTyLit _ (HsCharTy _ c)) exp_kind = do { checkWiredInTyCon charTyCon - ; checkExpectedKind rn_ty (mkCharLitTy c) charTy exp_kind } + ; checkExpKind rn_ty (mkCharLitTy c) charTy exp_kind } --------- Wildcards -tc_hs_type mode ty@(HsWildCardTy _) ek - = tcAnonWildCardOcc NoExtraConstraint mode ty ek +tcHsType mode ty@(HsWildCardTy _) ek + = do k <- expTypeToType ek + tcAnonWildCardOcc NoExtraConstraint mode ty k + +--------- Type applications +tcHsType mode rn_ty@(HsTyVar{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tcHsType mode rn_ty@(HsAppTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tcHsType mode rn_ty@(HsAppKindTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind +tcHsType mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind + +tcHsType mode rn_ty@(HsKindSig _ ty sig) exp_kind + = do { let mode' = mode { mode_tyki = KindLevel } + ; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig + -- We must typecheck the kind signature, and solve all + -- its equalities etc; from this point on we may do + -- things like instantiate its foralls, so it needs + -- to be fully determined (#14904) + ; traceTc "tcHsType:sig" (ppr ty $$ ppr sig') + ; ty' <- tcAddKindSigPlaceholders sig $ + tc_check_lhs_type mode ty sig' + ; checkExpKind rn_ty ty' sig' exp_kind } + +-- See Note [Typechecking HsCoreTys] +tcHsType _ rn_ty@(XHsType ty) exp_kind + = do env <- getLclEnv + -- Raw uniques since we go from NameEnv to TvSubstEnv. + let subst_prs :: [(Unique, TcTyVar)] + subst_prs = [ (getUnique nm, tv) + | ATyVar nm tv <- nonDetNameEnvElts (getLclEnvTypeEnv env) ] + subst = mkTvSubst + (mkInScopeSetList $ map snd subst_prs) + (listToUFM_Directly $ map (fmap mkTyVarTy) subst_prs) + ty' = substTy subst ty + checkExpKind rn_ty ty' (typeKind ty') exp_kind + +tc_hs_tuple_ty :: HsType GhcRn + -> TcTyMode + -> HsTupleSort + -> [LHsType GhcRn] + -> TcKind + -> TcM TcType +-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type +-- See Note [Inferring tuple kinds] +tc_hs_tuple_ty rn_ty mode HsBoxedOrConstraintTuple hs_tys exp_kind + -- (NB: not zonking before looking at exp_k, to avoid left-right bias) + | Just tup_sort <- tupKindSort_maybe exp_kind + = traceTc "tcHsType tuple" (ppr hs_tys) >> + tc_tuple rn_ty mode tup_sort hs_tys exp_kind + | otherwise + = do { traceTc "tcHsType tuple 2" (ppr hs_tys) + ; (tys, kinds) <- mapAndUnzipM (tc_infer_lhs_type mode) hs_tys + ; kinds <- liftZonkM $ mapM zonkTcType kinds + -- Infer each arg type separately, because errors can be + -- confusing if we give them a shared kind. Eg #7410 + -- (Either Int, Int), we do not want to get an error saying + -- "the second argument of a tuple should have kind *->*" + + ; let (arg_kind, tup_sort) + = case [ (k,s) | k <- kinds + , Just s <- [tupKindSort_maybe k] ] of + ((k,s) : _) -> (k,s) + [] -> (liftedTypeKind, BoxedTuple) + -- In the [] case, it's not clear what the kind is, so guess * ---------- Potentially kind-polymorphic types: call the "up" checker --- See Note [Future-proofing the type checker] -tc_hs_type mode ty@(HsTyVar {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(XHsType {}) ek = tc_infer_hs_type_ek mode ty ek + ; tys' <- sequence [ setSrcSpanA loc $ + checkExpectedKind hs_ty ty kind arg_kind + | ((L loc hs_ty),ty,kind) <- zip3 hs_tys tys kinds ] + + ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } +tc_hs_tuple_ty rn_ty mode HsUnboxedTuple tys exp_kind = + tc_tuple rn_ty mode UnboxedTuple tys exp_kind {- +Note [Kind-checking explicit lists] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In a type, suppose we have an application (F [t1,t2]), +where [t1,t2] is an explicit list, and + F :: [ki] -> blah + +Then we want to return the type + F ((:) @ki t2 ((:) @ki t2 ([] @ki))) +where the argument list is instantiated to F's argument kind `ki`. + +But what about (G []), where + G :: (forall k. [k]) -> blah + +Here we want to return (G []), with no instantiation at all. But since we have +no lambda in types, we must be careful not to instantiate that `[]`, because we +can't re-generalise it. Hence, when kind-checking an explicit list, we need a +special case for `[]`. + Note [Variable Specificity and Forall Visibility] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A HsForAllTy contains an HsForAllTelescope to denote the visibility of the forall @@ -1366,28 +1342,28 @@ Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in "GHC.Core.TyCo ------------------------------------------ tc_mult :: TcTyMode -> HsArrow GhcRn -> TcM Mult -tc_mult mode ty = tc_lhs_type mode (arrowToHsType ty) multiplicityTy +tc_mult mode ty = tc_check_lhs_type mode (arrowToHsType ty) multiplicityTy ------------------------------------------ -tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> TcKind +tc_fun_type :: TcTyMode -> HsArrow GhcRn -> LHsType GhcRn -> LHsType GhcRn -> ExpKind -> TcM TcType tc_fun_type mode mult ty1 ty2 exp_kind = case mode_tyki mode of TypeLevel -> do { traceTc "tc_fun_type" (ppr ty1 $$ ppr ty2) ; arg_k <- newOpenTypeKind ; res_k <- newOpenTypeKind - ; ty1' <- tc_lhs_type mode ty1 arg_k - ; ty2' <- tc_lhs_type mode ty2 res_k + ; ty1' <- tc_check_lhs_type mode ty1 arg_k + ; ty2' <- tc_check_lhs_type mode ty2 res_k ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } KindLevel -> -- no representation polymorphism in kinds. yet. - do { ty1' <- tc_lhs_type mode ty1 liftedTypeKind - ; ty2' <- tc_lhs_type mode ty2 liftedTypeKind + do { ty1' <- tc_check_lhs_type mode ty1 liftedTypeKind + ; ty2' <- tc_check_lhs_type mode ty2 liftedTypeKind ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) - (tcMkVisFunTy mult' ty1' ty2') - liftedTypeKind exp_kind } + ; checkExpKind (HsFunTy noExtField mult ty1 ty2) + (tcMkVisFunTy mult' ty1' ty2') + liftedTypeKind exp_kind } {- Note [Skolem escape and forall-types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1442,7 +1418,7 @@ tc_tuple rn_ty mode tup_sort tys exp_kind BoxedTuple -> return (replicate arity liftedTypeKind) UnboxedTuple -> replicateM arity newOpenTypeKind ConstraintTuple -> return (replicate arity constraintKind) - ; tau_tys <- zipWithM (tc_lhs_type mode) tys arg_kinds + ; tau_tys <- zipWithM (tc_check_lhs_type mode) tys arg_kinds ; finish_tuple rn_ty tup_sort tau_tys arg_kinds exp_kind } where arity = length tys @@ -1530,9 +1506,9 @@ since the two constraints should be semantically equivalent. * * ********************************************************************* -} -splitHsAppTys :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) -splitHsAppTys hs_ty - | is_app hs_ty = Just (go (noLocA hs_ty) []) +splitHsAppTys_maybe :: HsType GhcRn -> Maybe (LHsType GhcRn, [LHsTypeArg GhcRn]) +splitHsAppTys_maybe hs_ty + | is_app hs_ty = Just (splitHsAppTys hs_ty) | otherwise = Nothing where is_app :: HsType GhcRn -> Bool @@ -1547,6 +1523,10 @@ splitHsAppTys hs_ty is_app (HsParTy _ (L _ ty)) = is_app ty is_app _ = False +splitHsAppTys :: HsType GhcRn -> (LHsType GhcRn, [LHsTypeArg GhcRn]) + +splitHsAppTys hs_ty = go (noLocA hs_ty) [] + where go :: LHsType GhcRn -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, @@ -1570,6 +1550,14 @@ tcInferTyAppHead _ (L _ (HsTyVar _ _ (L _ tv))) tcInferTyAppHead mode ty = tc_infer_lhs_type mode ty +tc_app_ty :: TcTyMode -> HsType GhcRn -> ExpKind -> TcM TcType +tc_app_ty mode rn_ty exp_kind + = do { (fun_ty, _ki) <- tcInferTyAppHead mode hs_fun_ty + ; (ty, infered_kind) <- tcInferTyApps mode hs_fun_ty fun_ty hs_args + ; checkExpKind rn_ty ty infered_kind exp_kind } + where + (hs_fun_ty, hs_args) = splitHsAppTys rn_ty + --------------------------- -- | Apply a type of a given kind to a list of arguments. This instantiates -- invisible parameters as necessary. Always consumes all the arguments, @@ -1656,7 +1644,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args ; arg_mode <- mkHoleMode KindLevel HM_VTA -- HM_VKA: see Note [Wildcards in visible kind application] ; ki_arg <- addErrCtxt (funAppCtxt orig_hs_ty hs_ki_arg n) $ - tc_lhs_type arg_mode hs_ki_arg exp_kind + tc_check_lhs_type arg_mode hs_ki_arg exp_kind ; traceTc "tcInferTyApps (vis kind app)" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder ki_arg @@ -1687,7 +1675,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args , ppr subst ]) ; let exp_kind = substTy subst $ piTyBinderType ki_binder ; arg' <- addErrCtxt (funAppCtxt orig_hs_ty arg n) $ - tc_lhs_type mode arg exp_kind + tc_check_lhs_type mode arg exp_kind ; traceTc "tcInferTyApps (vis normal app) 2" (ppr exp_kind) ; (subst', fun') <- mkAppTyM subst fun ki_binder arg' ; go (n+1) fun' subst' inner_ki args } @@ -1975,6 +1963,19 @@ checkExpectedKind hs_ty ty act_kind exp_kind n_act_invis_bndrs = invisibleTyBndrCount act_kind n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + +-- tyr <- checkExpKind hs_ty ty (act_ki :: Kind) (exp_ki :: ExpKind) +-- requires that `ty` has kind `act_ki` +-- It checks that the actual kind `act_ki` matches the expected kind `exp_ki` +-- and returns `tyr`, a possibly-casted form of `ty`, that has precisely kind `exp_ki` +-- `hs_ty` is purely for error messages +checkExpKind :: HsType GhcRn -> TcType -> TcKind -> ExpKind -> TcM TcType +checkExpKind rn_ty ty ki (Check ki') = + checkExpectedKind rn_ty ty ki ki' +checkExpKind _rn_ty ty ki (Infer cell) = do + co <- fillInferResult ki cell + pure (ty `mkCastTy` co) + --------------------------- tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] @@ -1988,7 +1989,7 @@ tc_hs_context :: TcTyMode -> LHsContext GhcRn -> TcM [PredType] tc_hs_context mode ctxt = mapM (tc_lhs_pred mode) (unLoc ctxt) tc_lhs_pred :: TcTyMode -> LHsType GhcRn -> TcM PredType -tc_lhs_pred mode pred = tc_lhs_type mode pred constraintKind +tc_lhs_pred mode pred = tc_check_lhs_type mode pred constraintKind --------------------------- tcTyVar :: Name -> TcM (TcType, TcKind) @@ -4045,7 +4046,7 @@ tcHsPartialSigType ctxt sig_ty ; tau <- -- Don't do (addTypeCtxt hs_tau) here else we get -- In the type -- In the type signature: foo :: - tc_lhs_type mode hs_tau ek + tc_check_lhs_type mode hs_tau ek ; return (wcs, wcx, theta, tau) } @@ -4355,8 +4356,8 @@ tc_type_in_pat ctxt hole_mode hs_ty wcs ns ctxt_kind -- and c.f #16033 bindNamedWildCardBinders wcs $ \ wcs -> tcExtendNameTyVarEnv tkv_prs $ - do { ek <- newExpectedKind ctxt_kind - ; ty <- tc_lhs_type mode hs_ty ek + do { ek <- newExpectedKind ctxt_kind + ; ty <- tc_check_lhs_type mode hs_ty ek ; return (wcs, ty) } ; mapM_ emitNamedTypeHole wcs @@ -4532,7 +4533,7 @@ tc_lhs_kind_sig mode ctxt hs_kind -- Result is zonked = do { kind <- addErrCtxt (text "In the kind" <+> quotes (ppr hs_kind)) $ solveEqualities "tcLHsKindSig" $ - tc_lhs_type mode hs_kind liftedTypeKind + tc_check_lhs_type mode hs_kind liftedTypeKind ; traceTc "tcLHsKindSig" (ppr hs_kind $$ ppr kind) -- No generalization: ; kindGeneralizeNone kind ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1772,7 +1772,7 @@ kcTyClDecl (DataDecl { tcdLName = (L _ _name), tcdDataDefn = HsDataDefn { dd_ kcTyClDecl (SynDecl { tcdLName = L _ _name, tcdRhs = rhs }) tycon = tcExtendNameTyVarEnv (tcTyConScopedTyVars tycon) $ let res_kind = tyConResKind tycon - in discardResult $ tcCheckLHsType rhs (TheKind res_kind) + in discardResult $ tcCheckLHsTypeInContext rhs (TheKind res_kind) -- NB: check against the result kind that we allocated -- in inferInitialKinds. @@ -1801,7 +1801,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc kcConArgTys :: NewOrData -> TcKind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () kcConArgTys new_or_data res_kind arg_tys = do { let exp_kind = getArgExpKind new_or_data res_kind - ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind + ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsTypeInContext (getBangType ty) exp_kind tcMult mult) -- See Note [Implementation of UnliftedNewtypes], STEP 2 } @@ -1868,7 +1868,7 @@ kcConDecl new_or_data do { _ <- tcHsContext cxt ; traceTc "kcConDecl:GADT {" (ppr names $$ ppr res_ty) ; con_res_kind <- newOpenTypeKind - ; _ <- tcCheckLHsType res_ty (TheKind con_res_kind) + ; _ <- tcCheckLHsTypeInContext res_ty (TheKind con_res_kind) ; kcConGADTArgs new_or_data con_res_kind args ; traceTc "kcConDecl:GADT }" (ppr names $$ ppr con_res_kind) ; return () } @@ -1895,7 +1895,7 @@ Otherwise we'd infer the bogus kind The type signature for MkT influences the kind of T simply by kind-checking the result type (T g b), which will force 'f' and 'g' to have the same kinds. This is the call to - tcCheckLHsType res_ty (TheKind con_res_kind) + tcCheckLHsTypeInContext res_ty (TheKind con_res_kind) Because this is the result type of an arrow, we know the kind must be of form (TYPE rr), and we get better error messages if we enforce that here (e.g. test gadt10). @@ -3054,7 +3054,7 @@ tcTySynRhs roles_info tc_name hs_ty do { env <- getLclEnv ; traceTc "tc-syn" (ppr tc_name $$ ppr (getLclEnvRdrEnv env)) ; rhs_ty <- pushLevelAndSolveEqualities skol_info tc_bndrs $ - tcCheckLHsType hs_ty (TheKind res_kind) + tcCheckLHsTypeInContext hs_ty (TheKind res_kind) -- See Note [Error on unconstrained meta-variables] in GHC.Tc.Utils.TcMType -- Example: (typecheck/should_fail/T17567) @@ -3197,7 +3197,7 @@ kcTyFamInstEqn tc_fam_tc ; discardResult $ bindOuterFamEqnTKBndrs_Q_Tv outer_bndrs $ do { (_fam_app, res_kind) <- tcFamTyPats tc_fam_tc hs_pats - ; tcCheckLHsType hs_rhs_ty (TheKind res_kind) } + ; tcCheckLHsTypeInContext hs_rhs_ty (TheKind res_kind) } -- Why "_Tv" here? Consider (#14066) -- type family Bar x y where -- Bar (x :: a) (y :: b) = Int @@ -3349,7 +3349,7 @@ tcTyFamInstEqnGuts fam_tc mb_clsinfo outer_hs_bndrs hs_pats hs_rhs_ty -- Ensure that the instance is consistent with its -- parent class (#16008) ; addConsistencyConstraints mb_clsinfo lhs_ty - ; rhs_ty <- tcCheckLHsType hs_rhs_ty (TheKind rhs_kind) + ; rhs_ty <- tcCheckLHsTypeInContext hs_rhs_ty (TheKind rhs_kind) ; return (lhs_ty, rhs_ty) } ; outer_bndrs <- scopedSortOuter outer_bndrs @@ -3926,7 +3926,7 @@ tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatype -> HsScaled GhcRn (LHsType GhcRn) -> TcM (Scaled TcType, HsSrcBang) tcConArg exp_kind (HsScaled w bty) = do { traceTc "tcConArg 1" (ppr bty) - ; arg_ty <- tcCheckLHsType (getBangType bty) exp_kind + ; arg_ty <- tcCheckLHsTypeInContext (getBangType bty) exp_kind ; w' <- tcDataConMult w ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Tc.Utils.TcType ( TcKind, TcCoVar, TcTyCoVar, TcTyVarBinder, TcInvisTVBinder, TcReqTVBinder, TcTyCon, MonoTcTyCon, PolyTcTyCon, TcTyConBinder, KnotTied, - ExpType(..), InferResult(..), + ExpType(..), ExpKind, InferResult(..), ExpTypeFRR, ExpSigmaType, ExpSigmaTypeFRR, ExpRhoType, mkCheckExpType, @@ -433,6 +433,9 @@ type ExpSigmaTypeFRR = ExpTypeFRR type ExpRhoType = ExpType +-- | Like 'ExpType', but on kind level +type ExpKind = ExpType + instance Outputable ExpType where ppr (Check ty) = text "Check" <> braces (ppr ty) ppr (Infer ir) = ppr ir ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -43,6 +43,8 @@ module GHC.Tc.Utils.Unify ( PuResult(..), failCheckWith, okCheckRefl, mapCheck, TyEqFlags(..), TyEqFamApp(..), AreUnifying(..), LevelCheck(..), FamAppBreaker, famAppArgFlags, simpleUnifyCheck, checkPromoteFreeVars, + + fillInferResult, ) where import GHC.Prelude ===================================== compiler/Language/Haskell/Syntax/Type.hs ===================================== @@ -1006,7 +1006,7 @@ would mean that when we pretty-print it back, we don't know whether the user wrote '*' or 'Type', and lose the parse/ppr roundtrip property. As a workaround, we parse '*' as HsStarTy (if it stands for 'Data.Kind.Type') -and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_hs_type). +and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_check_hs_type). When '*' is a regular type operator (StarIsType is disabled), HsStarTy is not involved. ===================================== testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout ===================================== @@ -1,2 +1,2 @@ -_ :: k +_ :: p Maybe _ :: * ===================================== testsuite/tests/th/T24299.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24299 where +import Language.Haskell.TH.Syntax (addModFinalizer, runIO) +import GHC.Types (Type) +import System.IO + +type Proxy :: forall a. a -> Type +data Proxy a = MkProxy + +check :: ($(addModFinalizer (runIO (do putStrLn "check"; hFlush stdout)) >> + [t| Proxy |]) :: Type -> Type) Int -- There is kind signature, we are in check mode +check = MkProxy + +infer :: ($(addModFinalizer (runIO (do putStrLn "infer"; hFlush stdout)) >> + [t| Proxy |]) ) Int -- no kind signature, inference mode is enabled +infer = MkProxy ===================================== testsuite/tests/th/T24299.stderr ===================================== @@ -0,0 +1,2 @@ +check +infer ===================================== testsuite/tests/th/all.T ===================================== @@ -604,3 +604,4 @@ test('T24308', normal, compile_and_run, ['']) test('T14032a', normal, compile, ['']) test('T14032e', normal, compile_fail, ['-dsuppress-uniques']) test('ListTuplePunsTH', [only_ways(['ghci']), extra_files(['ListTuplePunsTH.hs', 'T15843a.hs'])], ghci_script, ['ListTuplePunsTH.script']) +test('T24299', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fcb5bb72b14ee499f137da19fd0802ab337b5f8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fcb5bb72b14ee499f137da19fd0802ab337b5f8f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 13:41:55 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 28 Mar 2024 09:41:55 -0400 Subject: [Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 9 commits: loader: Note down suggestion for needed_mods Message-ID: <660573a360411_25bec41e98e54653b8@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC Commits: 341c836a by Rodrigo Mesquita at 2024-03-28T13:41:14+00:00 loader: Note down suggestion for needed_mods The associated ticket is #24600 - - - - - eaac1931 by Rodrigo Mesquita at 2024-03-28T13:41:18+00:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - b12635aa by Rodrigo Mesquita at 2024-03-28T13:41:18+00:00 Start writing test - - - - - fc0bdd47 by Alexis King at 2024-03-28T13:41:18+00:00 linker: Avoid linear search when looking up Haskell symbols via dlsym Write Note [Looking up symbols in the relevant objects] Write Note [Symbols may not be found in pkgs_loaded] Use lookupHsSymbol for PrimOps too - - - - - 8619bc42 by Rodrigo Mesquita at 2024-03-28T13:41:18+00:00 wip: make addDLL wrapper around loadNativeObj - - - - - 63d99f94 by Alexis King at 2024-03-28T13:41:18+00:00 wip: use loadNativeObj to implement addDLL - - - - - e3f6ced0 by Rodrigo Mesquita at 2024-03-28T13:41:18+00:00 Refactor loadNativeObj_ELF to _POSIX and delete dl_mutex CPP Support loadNativeObj in MachO - - - - - 95c7569e by Rodrigo Mesquita at 2024-03-28T13:41:18+00:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - 573b9729 by Rodrigo Mesquita at 2024-03-28T13:41:18+00:00 Implement lookupSymbolInDLL for ExternalInterp - - - - - 29 changed files: - + T23415/Makefile - + T23415/main.hs - + T23415/make_shared_libs.sh - + T23415/new-main.hs - + T23415/run_test.sh - compiler/GHC.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Runtime/Interpreter/Types.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/ObjLink.hs - libraries/ghci/GHCi/Run.hs - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/include/rts/Linker.h - rts/linker/Elf.c - rts/linker/Elf.h - + rts/linker/LoadNativeObjPosix.c - + rts/linker/LoadNativeObjPosix.h - rts/linker/PEi386.c - rts/rts.cabal - testsuite/tests/ghci/linking/dyn/T3372.hs Changes: ===================================== T23415/Makefile ===================================== @@ -0,0 +1,10 @@ +.PHONY: run build clean + +run: + sh run_test.sh + +build: + sh make_shared_libs.sh + +clean: + rm -f lib*.out main main.o main.hi test.o tags ===================================== T23415/main.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +hsLoadObjs = do + cwd <- getCurrentDirectory + forM_ [0..499] $ \i -> + loadDLL (cwd "lib" ++ show i ++ ".out") + +hsLoadSymbols = do + forM_ [0..99] $ \j -> + forM_ [0..499] $ \i -> + lookupSymbol ("lib" ++ show i ++ "_" ++ show j) + +main = do + initObjLinker RetainCAFs + hsLoadObjs + hsLoadSymbols + ===================================== T23415/make_shared_libs.sh ===================================== @@ -0,0 +1,20 @@ +#!/bin/sh + +example_dylib=$(basename -- $(find $(ghc --print-libdir) -name libHS* -not -name *.a | head -n1)) +dylib_ext="${example_dylib##*.}" +# we try .out instead of using the correct extension. + +i=0 +while [ $i -lt 500 ]; do + j=0 + while [ $j -lt 100 ]; do + echo "int lib${i}_$j(void) { return $i; }" >> "lib$i.c" + j=$(( j + 1 )) + done + cc -o "lib$i.o" -c "lib$i.c" -fPIC + cc -shared "lib$i.o" -o "lib$i.out" # "lib$i.$dylib_ext" + rm "lib$i.c" "lib$i.o" + i=$(( i + 1 )) +done + + ===================================== T23415/new-main.hs ===================================== @@ -0,0 +1,29 @@ +import Data.Either +import Data.Foldable +import Data.Map as M +import Control.Monad +import System.FilePath +import System.Directory +import GHCi.ObjLink + +libname i = "lib" ++ show i + +hsLoadObjs = do + cwd <- getCurrentDirectory + foldrM (\i acc -> do + Right handle <- loadDLL (cwd libname i ++ ".out") + return $ M.insert (libname i) handle acc + ) + M.empty [0..499] + +hsLoadSymbols handles = do + forM_ [0..499] $ \i -> + forM_ [0..99] $ \j -> do + let symbolname = libname i ++ "_" ++ show j + lookupSymbolInDLL (handles M.! libname i) symbolname + +main = do + initObjLinker RetainCAFs + handles <- hsLoadObjs + hsLoadSymbols handles + print "hi" ===================================== T23415/run_test.sh ===================================== @@ -0,0 +1,8 @@ +#!/bin/sh + +GHC1=/Users/romes/ghc-dev/ghc/_build/stage1/bin/ghc +GHC2=/Users/romes/ghc-dev/23415/_build/stage1/bin/ghc + +# $GHC1 --interactive main.hs -package directory -package ghci -package filepath +$GHC2 --interactive new-main.hs -package directory -package ghci -package filepath -package containers + ===================================== compiler/GHC.hs ===================================== @@ -394,6 +394,7 @@ import GHC.Types.Name.Ppr import GHC.Types.TypeEnv import GHC.Types.BreakInfo import GHC.Types.PkgQual +import GHC.Types.Unique.FM import GHC.Unit import GHC.Unit.Env @@ -673,6 +674,7 @@ setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setTopSessionDynFlags dflags = do hsc_env <- getSession logger <- getLogger + lookup_cache <- liftIO $ newMVar emptyUFM -- Interpreter interp <- if @@ -702,7 +704,7 @@ setTopSessionDynFlags dflags = do } s <- liftIO $ newMVar InterpPending loader <- liftIO Loader.uninitializedLoader - return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader)) + return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) -- JavaScript interpreter | ArchJavaScript <- platformArch (targetPlatform dflags) @@ -720,7 +722,7 @@ setTopSessionDynFlags dflags = do , jsInterpFinderOpts = initFinderOpts dflags , jsInterpFinderCache = hsc_FC hsc_env } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader)) + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) -- Internal interpreter | otherwise @@ -728,7 +730,7 @@ setTopSessionDynFlags dflags = do #if defined(HAVE_INTERNAL_INTERPRETER) do loader <- liftIO Loader.uninitializedLoader - return (Just (Interp InternalInterp loader)) + return (Just (Interp InternalInterp loader lookup_cache)) #else return Nothing #endif ===================================== compiler/GHC/ByteCode/Linker.hs ===================================== @@ -24,6 +24,7 @@ import GHCi.RemoteTypes import GHCi.ResolvedBCO import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Ids import GHC.Builtin.Names import GHC.Unit.Types @@ -38,6 +39,8 @@ import GHC.Utils.Outputable import GHC.Types.Name import GHC.Types.Name.Env +import qualified GHC.Types.Id as Id +import GHC.Types.Unique.DFM import Language.Haskell.Syntax.Module.Name @@ -52,31 +55,32 @@ import GHC.Exts linkBCO :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> UnlinkedBCO -> IO ResolvedBCO -linkBCO interp le bco_ix +linkBCO interp pkgs_loaded le bco_ix (UnlinkedBCO _ arity insns bitmap lits0 ptrs0) = do -- fromIntegral Word -> Word64 should be a no op if Word is Word64 -- otherwise it will result in a cast to longlong on 32bit systems. - lits <- mapM (fmap fromIntegral . lookupLiteral interp le) (ssElts lits0) - ptrs <- mapM (resolvePtr interp le bco_ix) (ssElts ptrs0) + lits <- mapM (fmap fromIntegral . lookupLiteral interp pkgs_loaded le) (ssElts lits0) + ptrs <- mapM (resolvePtr interp pkgs_loaded le bco_ix) (ssElts ptrs0) return (ResolvedBCO isLittleEndian arity insns bitmap (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) -lookupLiteral :: Interp -> LinkerEnv -> BCONPtr -> IO Word -lookupLiteral interp le ptr = case ptr of +lookupLiteral :: Interp -> PkgsLoaded -> LinkerEnv -> BCONPtr -> IO Word +lookupLiteral interp pkgs_loaded le ptr = case ptr of BCONPtrWord lit -> return lit BCONPtrLbl sym -> do Ptr a# <- lookupStaticPtr interp sym return (W# (int2Word# (addr2Int# a#))) BCONPtrItbl nm -> do - Ptr a# <- lookupIE interp (itbl_env le) nm + Ptr a# <- lookupIE interp pkgs_loaded (itbl_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrAddr nm -> do - Ptr a# <- lookupAddr interp (addr_env le) nm + Ptr a# <- lookupAddr interp pkgs_loaded (addr_env le) nm return (W# (int2Word# (addr2Int# a#))) BCONPtrStr _ -> -- should be eliminated during assembleBCOs @@ -90,19 +94,19 @@ lookupStaticPtr interp addr_of_label_string = do Nothing -> linkFail "GHC.ByteCode.Linker: can't find label" (unpackFS addr_of_label_string) -lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) -lookupIE interp ie con_nm = +lookupIE :: Interp -> PkgsLoaded -> ItblEnv -> Name -> IO (Ptr ()) +lookupIE interp pkgs_loaded ie con_nm = case lookupNameEnv ie con_nm of Just (_, ItblPtr a) -> return (fromRemotePtr (castRemotePtr a)) Nothing -> do -- try looking up in the object files. let sym_to_find1 = nameToCLabel con_nm "con_info" - m <- lookupSymbol interp sym_to_find1 + m <- lookupHsSymbol interp pkgs_loaded con_nm "con_info" case m of Just addr -> return addr Nothing -> do -- perhaps a nullary constructor? let sym_to_find2 = nameToCLabel con_nm "static_info" - n <- lookupSymbol interp sym_to_find2 + n <- lookupHsSymbol interp pkgs_loaded con_nm "static_info" case n of Just addr -> return addr Nothing -> linkFail "GHC.ByteCode.Linker.lookupIE" @@ -110,34 +114,35 @@ lookupIE interp ie con_nm = unpackFS sym_to_find2) -- see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode -lookupAddr :: Interp -> AddrEnv -> Name -> IO (Ptr ()) -lookupAddr interp ae addr_nm = do +lookupAddr :: Interp -> PkgsLoaded -> AddrEnv -> Name -> IO (Ptr ()) +lookupAddr interp pkgs_loaded ae addr_nm = do case lookupNameEnv ae addr_nm of Just (_, AddrPtr ptr) -> return (fromRemotePtr ptr) Nothing -> do -- try looking up in the object files. let sym_to_find = nameToCLabel addr_nm "bytes" -- see Note [Bytes label] in GHC.Cmm.CLabel - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded addr_nm "bytes" case m of Just ptr -> return ptr Nothing -> linkFail "GHC.ByteCode.Linker.lookupAddr" (unpackFS sym_to_find) -lookupPrimOp :: Interp -> PrimOp -> IO (RemotePtr ()) -lookupPrimOp interp primop = do +lookupPrimOp :: Interp -> PkgsLoaded -> PrimOp -> IO (RemotePtr ()) +lookupPrimOp interp pkgs_loaded primop = do let sym_to_find = primopToCLabel primop "closure" - m <- lookupSymbol interp (mkFastString sym_to_find) + m <- lookupHsSymbol interp pkgs_loaded (Id.idName $ primOpId primop) "closure" case m of Just p -> return (toRemotePtr p) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE(primop)" sym_to_find resolvePtr :: Interp + -> PkgsLoaded -> LinkerEnv -> NameEnv Int -> BCOPtr -> IO ResolvedBCOPtr -resolvePtr interp le bco_ix ptr = case ptr of +resolvePtr interp pkgs_loaded le bco_ix ptr = case ptr of BCOPtrName nm | Just ix <- lookupNameEnv bco_ix nm -> return (ResolvedBCORef ix) -- ref to another BCO in this group @@ -149,20 +154,38 @@ resolvePtr interp le bco_ix ptr = case ptr of -> assertPpr (isExternalName nm) (ppr nm) $ do let sym_to_find = nameToCLabel nm "closure" - m <- lookupSymbol interp sym_to_find + m <- lookupHsSymbol interp pkgs_loaded nm "closure" case m of Just p -> return (ResolvedBCOStaticPtr (toRemotePtr p)) Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE" (unpackFS sym_to_find) BCOPtrPrimOp op - -> ResolvedBCOStaticPtr <$> lookupPrimOp interp op + -> ResolvedBCOStaticPtr <$> lookupPrimOp interp pkgs_loaded op BCOPtrBCO bco - -> ResolvedBCOPtrBCO <$> linkBCO interp le bco_ix bco + -> ResolvedBCOPtrBCO <$> linkBCO interp pkgs_loaded le bco_ix bco BCOPtrBreakArray breakarray -> withForeignRef breakarray $ \ba -> return (ResolvedBCOPtrBreakArray ba) +lookupHsSymbol :: Interp -> PkgsLoaded -> Name -> String -> IO (Maybe (Ptr ())) +lookupHsSymbol interp pkgs_loaded nm sym_suffix = do + massertPpr (isExternalName nm) (ppr nm) + let sym_to_find = nameToCLabel nm sym_suffix + pkg_id = moduleUnitId $ nameModule nm + loaded_dlls = maybe [] loaded_pkg_hs_dlls $ lookupUDFM pkgs_loaded pkg_id + + go (dll:dlls) = do + mb_ptr <- lookupSymbolInDLL interp dll sym_to_find + case mb_ptr of + Just ptr -> pure (Just ptr) + Nothing -> go dlls + go [] = + -- See Note [Symbols may not be found in pkgs_loaded] in GHC.Linker.Types + lookupSymbol interp sym_to_find + + go loaded_dlls + linkFail :: String -> String -> IO a linkFail who what = throwGhcExceptionIO (ProgramError $ ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -2665,7 +2665,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do case interp of -- always generate JS code for the JS interpreter (no bytecode!) - Interp (ExternalInterp (ExtJS i)) _ -> + Interp (ExternalInterp (ExtJS i)) _ _ -> jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id _ -> do ===================================== compiler/GHC/Driver/Plugins.hs ===================================== @@ -420,12 +420,12 @@ loadExternalPluginLib :: FilePath -> IO () loadExternalPluginLib path = do -- load library loadDLL path >>= \case - Just errmsg -> pprPanic "loadExternalPluginLib" - (vcat [ text "Can't load plugin library" - , text " Library path: " <> text path - , text " Error : " <> text errmsg - ]) - Nothing -> do + Left errmsg -> pprPanic "loadExternalPluginLib" + (vcat [ text "Can't load plugin library" + , text " Library path: " <> text path + , text " Error : " <> text errmsg + ]) + Right _ -> do -- TODO: use returned LoadedDLL? -- resolve objects resolveObjs >>= \case True -> return () ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -55,6 +55,7 @@ import GHC.Tc.Utils.Monad import GHC.Runtime.Interpreter import GHCi.RemoteTypes import GHC.Iface.Load +import GHCi.Message (LoadedDLL) import GHC.ByteCode.Linker import GHC.ByteCode.Asm @@ -172,7 +173,7 @@ emptyLoaderState = LoaderState -- -- The linker's symbol table is populated with RTS symbols using an -- explicit list. See rts/Linker.c for details. - where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] emptyUniqDSet) + where init_pkgs = unitUDFM rtsUnitId (LoadedPkgInfo rtsUnitId [] [] [] emptyUniqDSet) extendLoadedEnv :: Interp -> [(Name,ForeignHValue)] -> IO () extendLoadedEnv interp new_bindings = @@ -221,8 +222,8 @@ loadDependencies -> SrcSpan -> [Module] -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required +-- When called, the loader state must have been initialized (see `initLoaderState`) loadDependencies interp hsc_env pls span needed_mods = do --- initLoaderState (hsc_dflags hsc_env) dl let opts = initLinkDepsOpts hsc_env -- Find what packages and linkables are required @@ -512,25 +513,25 @@ preloadLib interp hsc_env lib_paths framework_paths pls lib_spec = do DLL dll_unadorned -> do maybe_errstr <- loadDLL interp (platformSOName platform dll_unadorned) case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm | platformOS platform /= OSDarwin -> + Right _ -> maybePutStrLn logger "done" + Left mm | platformOS platform /= OSDarwin -> preloadFailed mm lib_paths lib_spec - Just mm | otherwise -> do + Left mm | otherwise -> do -- As a backup, on Darwin, try to also load a .so file -- since (apparently) some things install that way - see -- ticket #8770. let libfile = ("lib" ++ dll_unadorned) <.> "so" err2 <- loadDLL interp libfile case err2 of - Nothing -> maybePutStrLn logger "done" - Just _ -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left _ -> preloadFailed mm lib_paths lib_spec return pls DLLPath dll_path -> do do maybe_errstr <- loadDLL interp dll_path case maybe_errstr of - Nothing -> maybePutStrLn logger "done" - Just mm -> preloadFailed mm lib_paths lib_spec + Right _ -> maybePutStrLn logger "done" + Left mm -> preloadFailed mm lib_paths lib_spec return pls Framework framework -> @@ -614,13 +615,14 @@ loadExpr interp hsc_env span root_ul_bco = do -- Load the necessary packages and linkables let le = linker_env pls bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)] - resolved <- linkBCO interp le bco_ix root_ul_bco + resolved <- linkBCO interp (pkgs_loaded pls) le bco_ix root_ul_bco [root_hvref] <- createBCOs interp [resolved] fhv <- mkFinalizedHValue interp root_hvref return (pls, fhv) where free_names = uniqDSetToList (bcoFreeNames root_ul_bco) + -- TODO(24600): We should be using a Set-like datatype, as this may contain lots of duplicates. needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, isExternalName n, -- Names from other modules @@ -677,7 +679,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do , addr_env = plusNameEnv (addr_env le) bc_strs } -- Link the necessary packages and linkables - new_bindings <- linkSomeBCOs interp le2 [cbc] + new_bindings <- linkSomeBCOs interp (pkgs_loaded pls) le2 [cbc] nms_fhvs <- makeForeignNamedHValueRefs interp new_bindings let ce2 = extendClosureEnv (closure_env le2) nms_fhvs !pls2 = pls { linker_env = le2 { closure_env = ce2 } } @@ -686,6 +688,7 @@ loadDecls interp hsc_env span cbc at CompiledByteCode{..} = do free_names = uniqDSetToList $ foldr (unionUniqDSets . bcoFreeNames) emptyUniqDSet bc_bcos + -- TODO(24600): We should be using a Set-like datatype, as this may contain lots of duplicates. needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, isExternalName n, -- Names from other modules @@ -858,8 +861,8 @@ dynLoadObjs interp hsc_env pls at LoaderState{..} objs = do changeTempFilesLifetime tmpfs TFL_GhcSession [soFile] m <- loadDLL interp soFile case m of - Nothing -> return $! pls { temp_sos = (libPath, libName) : temp_sos } - Just err -> linkFail msg err + Right _ -> return $! pls { temp_sos = (libPath, libName) : temp_sos } + Left err -> linkFail msg err where msg = "GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed" @@ -899,7 +902,7 @@ dynLinkBCOs interp pls bcos = do ae2 = foldr plusNameEnv (addr_env le1) (map bc_strs cbcs) le2 = le1 { itbl_env = ie2, addr_env = ae2 } - names_and_refs <- linkSomeBCOs interp le2 cbcs + names_and_refs <- linkSomeBCOs interp (pkgs_loaded pls) le2 cbcs -- We only want to add the external ones to the ClosureEnv let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs @@ -914,6 +917,7 @@ dynLinkBCOs interp pls bcos = do -- Link a bunch of BCOs and return references to their values linkSomeBCOs :: Interp + -> PkgsLoaded -> LinkerEnv -> [CompiledByteCode] -> IO [(Name,HValueRef)] @@ -921,7 +925,7 @@ linkSomeBCOs :: Interp -- the incoming unlinked BCOs. Each gives the -- value of the corresponding unlinked BCO -linkSomeBCOs interp le mods = foldr fun do_link mods [] +linkSomeBCOs interp pkgs_loaded le mods = foldr fun do_link mods [] where fun CompiledByteCode{..} inner accum = inner (bc_bcos : accum) @@ -930,7 +934,7 @@ linkSomeBCOs interp le mods = foldr fun do_link mods [] let flat = [ bco | bcos <- mods, bco <- bcos ] names = map unlinkedBCOName flat bco_ix = mkNameEnv (zip names [0..]) - resolved <- sequence [ linkBCO interp le bco_ix bco | bco <- flat ] + resolved <- sequence [ linkBCO interp pkgs_loaded le bco_ix bco | bco <- flat ] hvrefs <- createBCOs interp resolved return (zip names hvrefs) @@ -1092,18 +1096,18 @@ loadPackages' interp hsc_env new_pks pls = do -- Link dependents first ; pkgs' <- link pkgs deps -- Now link the package itself - ; (hs_cls, extra_cls) <- loadPackage interp hsc_env pkg_cfg + ; (hs_cls, extra_cls, loaded_dlls) <- loadPackage interp hsc_env pkg_cfg ; let trans_deps = unionManyUniqDSets [ addOneToUniqDSet (loaded_pkg_trans_deps loaded_pkg_info) dep_pkg | dep_pkg <- deps , Just loaded_pkg_info <- pure (lookupUDFM pkgs' dep_pkg) ] - ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls trans_deps)) } + ; return (addToUDFM pkgs' new_pkg (LoadedPkgInfo new_pkg hs_cls extra_cls loaded_dlls trans_deps)) } | otherwise = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unpackFS (unitIdFS new_pkg))) -loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec]) +loadPackage :: Interp -> HscEnv -> UnitInfo -> IO ([LibrarySpec], [LibrarySpec], [RemotePtr LoadedDLL]) loadPackage interp hsc_env pkg = do let dflags = hsc_dflags hsc_env @@ -1145,7 +1149,9 @@ loadPackage interp hsc_env pkg let classifieds = hs_classifieds ++ extra_classifieds -- Complication: all the .so's must be loaded before any of the .o's. - let known_dlls = [ dll | DLLPath dll <- classifieds ] + let known_hs_dlls = [ dll | DLLPath dll <- hs_classifieds ] + known_extra_dlls = [ dll | DLLPath dll <- extra_classifieds ] + known_dlls = known_hs_dlls ++ known_extra_dlls #if defined(CAN_LOAD_DLL) dlls = [ dll | DLL dll <- classifieds ] #endif @@ -1166,10 +1172,13 @@ loadPackage interp hsc_env pkg loadFrameworks interp platform pkg -- See Note [Crash early load_dyn and locateLib] -- Crash early if can't load any of `known_dlls` - mapM_ (load_dyn interp hsc_env True) known_dlls + mapM_ (load_dyn interp hsc_env True) known_extra_dlls + loaded_dlls <- mapMaybeM (load_dyn interp hsc_env True) known_hs_dlls -- For remaining `dlls` crash early only when there is surely -- no package's DLL around ... (not is_dyn) mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls +#else + let loaded_dlls = [] #endif -- After loading all the DLLs, we can load the static objects. -- Ordering isn't important here, because we do one final link @@ -1189,7 +1198,7 @@ loadPackage interp hsc_env pkg if succeeded ok then do maybePutStrLn logger "done." - return (hs_classifieds, extra_classifieds) + return (hs_classifieds, extra_classifieds, loaded_dlls) else let errmsg = text "unable to load unit `" <> pprUnitInfoForUser pkg <> text "'" in throwGhcExceptionIO (InstallationError (showSDoc dflags errmsg)) @@ -1242,19 +1251,20 @@ restriction very easily. -- can be passed directly to loadDLL. They are either fully-qualified -- ("/usr/lib/libfoo.so"), or unqualified ("libfoo.so"). In the latter case, -- loadDLL is going to search the system paths to find the library. -load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO () +load_dyn :: Interp -> HscEnv -> Bool -> FilePath -> IO (Maybe (RemotePtr LoadedDLL)) load_dyn interp hsc_env crash_early dll = do r <- loadDLL interp dll case r of - Nothing -> return () - Just err -> + Right loaded_dll -> pure (Just loaded_dll) + Left err -> if crash_early then cmdLineErrorIO err - else + else do when (diag_wopt Opt_WarnMissedExtraSharedLib diag_opts) $ logMsg logger (mkMCDiagnostic diag_opts (WarningWithFlag Opt_WarnMissedExtraSharedLib) Nothing) noSrcSpan $ withPprStyle defaultUserStyle (note err) + pure Nothing where diag_opts = initDiagOpts (hsc_dflags hsc_env) logger = hsc_logger hsc_env ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -172,6 +172,6 @@ loadFramework interp extraPaths rootname findLoadDLL (p:ps) errs = do { dll <- loadDLL interp (p fwk_file) ; case dll of - Nothing -> return Nothing - Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) + Right _ -> return Nothing + Left err -> findLoadDLL ps ((p ++ ": " ++ err):errs) } ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -40,7 +40,8 @@ import GHC.Prelude import GHC.Unit ( UnitId, Module ) import GHC.ByteCode.Types ( ItblEnv, AddrEnv, CompiledByteCode ) import GHC.Fingerprint.Type ( Fingerprint ) -import GHCi.RemoteTypes ( ForeignHValue ) +import GHCi.RemoteTypes ( ForeignHValue, RemotePtr ) +import GHCi.Message ( LoadedDLL ) import GHC.Types.Var ( Id ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnvList, filterNameEnv ) @@ -75,6 +76,57 @@ initialised. The LinkerEnv maps Names to actual closures (for interpreted code only), for use during linking. + +Note [Looking up symbols in the relevant objects] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #23415, we determined that a lot of time (>10s, or even up to >35s!) was +being spent on dynamically loading symbols before actually interpreting code +when `:main` was run in GHCi. The root cause was that for each symbol we wanted +to lookup, we would traverse the list of loaded objects and try find the symbol +in each of them with dlsym (i.e. looking up a symbol was, worst case, linear in +the amount of loaded objects). + +To drastically improve load time (XXX(TODO:get better measure against 10s +baseline rather than 35second one) to <3s), we now: + +1. For every of the native objects loaded for a given unit, store the handles returned by `dlopen`. + - In `pkgs_loaded` of the `LoaderState`, which maps `UnitId`s to + `LoadedPkgInfo`s, where the handles live in its field `loaded_pkg_hs_dlls`. + +2. When looking up a Name (e.g. `lookupHsSymbol`), find that name's `UnitId` in + the `pkgs_loaded` mapping, + +3. And only look for the symbol (with `dlsym`) on the /handles relevant to that + unit/, rather than in every loaded object. + +Note [Symbols may not be found in pkgs_loaded] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Despite storing and looking for symbols in the relevant loaded libraries +handles for a given unit-id, as described in the note above, we may still have +to fallback to the "slow" `lookupSymbol` function (see its "fallback" call in +`lookupHsSymbol`). + +TODO: Ben: my understanding here is flawed; could you make this clearer?. + +This fallback is still needed because a given unit may be associated with +static objects (`loaded_pkg_hs_objs`) only and no dynamic libraries, but we +only `lookupSymbolInDLL` for loaded dynamic libraries. In that case, +`lookupSymbol` will do the right thing because, besides looking up the symbol +in every loaded dylib, it will end up searching the static name table and find those symbols. + +Arguably, we should rather generalise `lookupSymbolInDLL` to +`lookupSymbolInObject`, where an object may be a DLL/native object (as in +`loadNativeObj`), or e.g. a static archive, instead of having a special case +for dynamic libraries. + +This fallback is further needed because we don't look in the haskell objects +loaded for the home units (see the call to `loadModuleLinkables` in +`loadDependencies`, as opposed to the call to `loadPackages'` in the same +function which updates `pkgs_loaded`). We should ultimately keep track of the +objects loaded (probably in `objs_loaded`, for which `LinkableSet` is a bit +unsatisfactory, see a suggestion in 51c5c4eb1f2a33e4dc88e6a37b7b7c135234ce9b) +and be able to lookup symbols specifically in them too (similarly to +`lookupSymbolInDLL`). -} newtype Loader = Loader { loader_state :: MVar (Maybe LoaderState) } @@ -146,11 +198,13 @@ data LoadedPkgInfo { loaded_pkg_uid :: !UnitId , loaded_pkg_hs_objs :: ![LibrarySpec] , loaded_pkg_non_hs_objs :: ![LibrarySpec] + , loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL] + -- ^ See Note [Looking up symbols in the relevant objects] , loaded_pkg_trans_deps :: UniqDSet UnitId } instance Outputable LoadedPkgInfo where - ppr (LoadedPkgInfo uid hs_objs non_hs_objs trans_deps) = + ppr (LoadedPkgInfo uid hs_objs non_hs_objs _ trans_deps) = vcat [ppr uid , ppr hs_objs , ppr non_hs_objs @@ -159,10 +213,10 @@ instance Outputable LoadedPkgInfo where -- | Information we can use to dynamically link modules into the compiler data Linkable = LM { - linkableTime :: !UTCTime, -- ^ Time at which this linkable was built + linkableTime :: !UTCTime, -- ^ Time at which this linkable was built -- (i.e. when the bytecodes were produced, -- or the mod date on the files) - linkableModule :: !Module, -- ^ The linkable module itself + linkableModule :: !Module, -- ^ The linkable module itself linkableUnlinked :: [Unlinked] -- ^ Those files and chunks of code we have yet to link. -- ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Runtime.Interpreter -- * The object-code linker , initObjLinker , lookupSymbol + , lookupSymbolInDLL , lookupClosure , loadDLL , loadArchive @@ -151,22 +152,22 @@ The main pieces are: - implementation of Template Haskell (GHCi.TH) - a few other things needed to run interpreted code -- top-level iserv directory, containing the codefor the external - server. This is a fairly simple wrapper, most of the functionality +- top-level iserv directory, containing the code for the external + server. This is a fairly simple wrapper, most of the functionality is provided by modules in libraries/ghci. - This module which provides the interface to the server used by the rest of GHC. -GHC works with and without -fexternal-interpreter. With the flag, all -interpreted code is run by the iserv binary. Without the flag, +GHC works with and without -fexternal-interpreter. With the flag, all +interpreted code is run by the iserv binary. Without the flag, interpreted code is run in the same process as GHC. Things that do not work with -fexternal-interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dynCompileExpr cannot work, because we have no way to run code of an -unknown type in the remote process. This API fails with an error +unknown type in the remote process. This API fails with an error message if it is used with -fexternal-interpreter. Other Notes on Remote GHCi @@ -440,57 +441,78 @@ initObjLinker :: Interp -> IO () initObjLinker interp = interpCmd interp InitLinker lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) -lookupSymbol interp str = case interpInstance interp of +lookupSymbol interp str = withSymbolCache interp str $ + case interpInstance interp of #if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str)) #endif - - ExternalInterp ext -> case ext of - ExtIServ i -> withIServ i $ \inst -> do - -- Profiling of GHCi showed a lot of time and allocation spent - -- making cross-process LookupSymbol calls, so I added a GHC-side - -- cache which sped things up quite a lot. We have to be careful - -- to purge this cache when unloading code though. - cache <- readMVar (instLookupSymbolCache inst) - case lookupUFM cache str of - Just p -> return (Just p) - Nothing -> do - m <- uninterruptibleMask_ $ - sendMessage inst (LookupSymbol (unpackFS str)) - case m of - Nothing -> return Nothing - Just r -> do - let p = fromRemotePtr r - cache' = addToUFM cache str p - modifyMVar_ (instLookupSymbolCache inst) (const (pure cache')) - return (Just p) - - ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbol (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) + +lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> FastString -> IO (Maybe (Ptr ())) +lookupSymbolInDLL interp dll str = withSymbolCache interp str $ + case interpInstance interp of +#if defined(HAVE_INTERNAL_INTERPRETER) + InternalInterp -> fmap fromRemotePtr <$> run (LookupSymbolInDLL dll (unpackFS str)) +#endif + ExternalInterp ext -> case ext of + ExtIServ i -> withIServ i $ \inst -> fmap fromRemotePtr <$> do + uninterruptibleMask_ $ + sendMessage inst (LookupSymbolInDLL dll (unpackFS str)) + ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str) lookupClosure :: Interp -> String -> IO (Maybe HValueRef) lookupClosure interp str = interpCmd interp (LookupClosure str) +-- | 'withSymbolCache' tries to find a symbol in the 'interpLookupSymbolCache' +-- which maps symbols to the address where they are loaded. +-- When there's a cache hit we simply return the cached address, when there is +-- a miss we run the action which determines the symbol's address and populate +-- the cache with the answer. +withSymbolCache :: Interp + -> FastString + -- ^ The symbol we are looking up in the cache + -> IO (Maybe (Ptr ())) + -- ^ An action which determines the address of the symbol we + -- are looking up in the cache, which is run if there is a + -- cache miss. The result will be cached. + -> IO (Maybe (Ptr ())) +withSymbolCache interp str determine_addr = do + + -- Profiling of GHCi showed a lot of time and allocation spent + -- making cross-process LookupSymbol calls, so I added a GHC-side + -- cache which sped things up quite a lot. We have to be careful + -- to purge this cache when unloading code though. + -- + -- The analysis in #23415 further showed this cache should also benefit the + -- internal interpreter's loading times, and needn't be used by the external + -- interpreter only. + cache <- readMVar (interpLookupSymbolCache interp) + case lookupUFM cache str of + Just p -> return (Just p) + Nothing -> do + + maddr <- determine_addr + case maddr of + Nothing -> return Nothing + Just p -> do + let upd_cache cache' = addToUFM cache' str p + modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache) + return (Just p) + purgeLookupSymbolCache :: Interp -> IO () -purgeLookupSymbolCache interp = case interpInstance interp of -#if defined(HAVE_INTERNAL_INTERPRETER) - InternalInterp -> pure () -#endif - ExternalInterp ext -> withExtInterpMaybe ext $ \case - Nothing -> pure () -- interpreter stopped, nothing to do - Just inst -> modifyMVar_ (instLookupSymbolCache inst) (const (pure emptyUFM)) +purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM -- | loadDLL loads a dynamic library using the OS's native linker -- (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either -- an absolute pathname to the file, or a relative filename -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. --- --- Returns: --- --- Nothing => success --- Just err_msg => failure -loadDLL :: Interp -> String -> IO (Maybe String) +loadDLL :: Interp -> String -> IO (Either String (RemotePtr LoadedDLL)) loadDLL interp str = interpCmd interp (LoadDLL str) loadArchive :: Interp -> String -> IO () @@ -549,11 +571,9 @@ spawnIServ conf = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = process , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = () } pure inst ===================================== compiler/GHC/Runtime/Interpreter/JS.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Utils.Panic import GHC.Utils.Error (logInfo) import GHC.Utils.Outputable (text) import GHC.Data.FastString -import GHC.Types.Unique.FM import Control.Concurrent import Control.Monad @@ -178,11 +177,9 @@ spawnJSInterp cfg = do } pending_frees <- newMVar [] - lookup_cache <- newMVar emptyUFM let inst = ExtInterpInstance { instProcess = proc , instPendingFrees = pending_frees - , instLookupSymbolCache = lookup_cache , instExtra = extra } ===================================== compiler/GHC/Runtime/Interpreter/Types.hs ===================================== @@ -51,6 +51,9 @@ data Interp = Interp , interpLoader :: !Loader -- ^ Interpreter loader + + , interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) + -- ^ LookupSymbol cache } data InterpInstance @@ -108,9 +111,6 @@ data ExtInterpInstance c = ExtInterpInstance -- Finalizers for ForeignRefs can append values to this list -- asynchronously. - , instLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ()))) - -- ^ LookupSymbol cache - , instExtra :: !c -- ^ Instance specific extra fields } ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -23,6 +23,7 @@ module GHCi.Message , getMessage, putMessage, getTHMessage, putTHMessage , Pipe(..), remoteCall, remoteTHCall, readPipe, writePipe , BreakModule + , LoadedDLL ) where import Prelude -- See note [Why do we import Prelude here?] @@ -73,8 +74,9 @@ data Message a where -- These all invoke the corresponding functions in the RTS Linker API. InitLinker :: Message () LookupSymbol :: String -> Message (Maybe (RemotePtr ())) + LookupSymbolInDLL :: RemotePtr LoadedDLL -> String -> Message (Maybe (RemotePtr ())) LookupClosure :: String -> Message (Maybe HValueRef) - LoadDLL :: String -> Message (Maybe String) + LoadDLL :: String -> Message (Either String (RemotePtr LoadedDLL)) LoadArchive :: String -> Message () -- error? LoadObj :: String -> Message () -- error? UnloadObj :: String -> Message () -- error? @@ -415,6 +417,9 @@ instance Binary a => Binary (EvalResult a) -- that type isn't available here. data BreakModule +-- | A dummy type that tags pointers returned by 'LoadDLL'. +data LoadedDLL + -- SomeException can't be serialized because it contains dynamic -- types. However, we do very limited things with the exceptions that -- are thrown by interpreted computations: @@ -544,6 +549,7 @@ getMessage = do 37 -> Msg <$> return RtsRevertCAFs 38 -> Msg <$> (ResumeSeq <$> get) 39 -> Msg <$> (NewBreakModule <$> get) + 40 -> Msg <$> (LookupSymbolInDLL <$> get <*> get) _ -> error $ "Unknown Message code " ++ (show b) putMessage :: Message a -> Put @@ -588,7 +594,8 @@ putMessage m = case m of Seq a -> putWord8 36 >> put a RtsRevertCAFs -> putWord8 37 ResumeSeq a -> putWord8 38 >> put a - NewBreakModule name -> putWord8 39 >> put name + NewBreakModule name -> putWord8 39 >> put name + LookupSymbolInDLL dll str -> putWord8 40 >> put dll >> put str {- Note [Parallelize CreateBCOs serialization] ===================================== libraries/ghci/GHCi/ObjLink.hs ===================================== @@ -18,6 +18,7 @@ module GHCi.ObjLink , unloadObj , purgeObj , lookupSymbol + , lookupSymbolInDLL , lookupClosure , resolveObjs , addLibrarySearchPath @@ -27,18 +28,17 @@ module GHCi.ObjLink import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes +import GHCi.Message (LoadedDLL) import Control.Exception (throwIO, ErrorCall(..)) import Control.Monad ( when ) import Foreign.C -import Foreign.Marshal.Alloc ( free ) -import Foreign ( nullPtr ) +import Foreign.Marshal.Alloc ( alloca, free ) +import Foreign ( nullPtr, peek ) import GHC.Exts import System.Posix.Internals ( CFilePath, withFilePath, peekFilePath ) import System.FilePath ( dropExtension, normalise ) - - -- --------------------------------------------------------------------------- -- RTS Linker Interface -- --------------------------------------------------------------------------- @@ -70,6 +70,15 @@ lookupSymbol str_in = do then return Nothing else return (Just addr) +lookupSymbolInDLL :: Ptr LoadedDLL -> String -> IO (Maybe (Ptr a)) +lookupSymbolInDLL dll str_in = do + let str = prefixUnderscore str_in + withCAString str $ \c_str -> do + addr <- c_lookupSymbolInNativeObj dll c_str + if addr == nullPtr + then return Nothing + else return (Just addr) + lookupClosure :: String -> IO (Maybe HValueRef) lookupClosure str = do m <- lookupSymbol str @@ -89,7 +98,7 @@ prefixUnderscore -- (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL -- searches the standard locations for the appropriate library. -- -loadDLL :: String -> IO (Maybe String) +loadDLL :: String -> IO (Either String (Ptr LoadedDLL)) -- Nothing => success -- Just err_msg => failure loadDLL str0 = do @@ -101,12 +110,16 @@ loadDLL str0 = do str | isWindowsHost = dropExtension str0 | otherwise = str0 -- - maybe_errmsg <- withFilePath (normalise str) $ \dll -> c_addDLL dll - if maybe_errmsg == nullPtr - then return Nothing - else do str <- peekCString maybe_errmsg - free maybe_errmsg - return (Just str) + (maybe_handle, maybe_errmsg) <- withFilePath (normalise str) $ \dll -> + alloca $ \errmsg_ptr -> (,) + <$> c_loadNativeObj dll errmsg_ptr + <*> peek errmsg_ptr + + if maybe_handle == nullPtr + then do str <- peekCString maybe_errmsg + free maybe_errmsg + return (Left str) + else return (Right maybe_handle) loadArchive :: String -> IO () loadArchive str = do @@ -163,7 +176,8 @@ resolveObjs = do -- Foreign declarations to RTS entry points which does the real work; -- --------------------------------------------------------------------------- -foreign import ccall unsafe "addDLL" c_addDLL :: CFilePath -> IO CString +foreign import ccall unsafe "loadNativeObj" c_loadNativeObj :: CFilePath -> Ptr CString -> IO (Ptr LoadedDLL) +foreign import ccall unsafe "lookupSymbolInNativeObj" c_lookupSymbolInNativeObj :: Ptr LoadedDLL -> CString -> IO (Ptr a) foreign import ccall unsafe "initLinker_" c_initLinker_ :: CInt -> IO () foreign import ccall unsafe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) foreign import ccall unsafe "loadArchive" c_loadArchive :: CFilePath -> IO Int ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -66,7 +66,7 @@ run m = case m of LookupClosure str -> lookupJSClosure str #else InitLinker -> initObjLinker RetainCAFs - LoadDLL str -> loadDLL str + LoadDLL str -> fmap toRemotePtr <$> loadDLL str LoadArchive str -> loadArchive str LoadObj str -> loadObj str UnloadObj str -> unloadObj str @@ -81,6 +81,8 @@ run m = case m of #endif RtsRevertCAFs -> rts_revertCAFs LookupSymbol str -> fmap toRemotePtr <$> lookupSymbol str + LookupSymbolInDLL dll str -> + fmap toRemotePtr <$> lookupSymbolInDLL (fromRemotePtr dll) str FreeHValueRefs rs -> mapM_ freeRemoteRef rs AddSptEntry fpr r -> localRef r >>= sptAddEntry fpr EvalStmt opts r -> evalStmt opts r ===================================== rts/Linker.c ===================================== @@ -77,6 +77,10 @@ # include #endif +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) +# include "linker/LoadNativeObjPosix.h" +#endif + #if defined(dragonfly_HOST_OS) #include #endif @@ -130,7 +134,7 @@ extern void iconv(); - Indexing (e.g. ocVerifyImage and ocGetNames) - Initialization (e.g. ocResolve) - RunInit (e.g. ocRunInit) - - Lookup (e.g. lookupSymbol) + - Lookup (e.g. lookupSymbol/lookupSymbolInDLL) This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will @@ -419,9 +423,6 @@ static int linker_init_done = 0 ; static void *dl_prog_handle; static regex_t re_invalid; static regex_t re_realso; -#if defined(THREADED_RTS) -Mutex dl_mutex; // mutex to protect dlopen/dlerror critical section -#endif #endif void initLinker (void) @@ -455,9 +456,6 @@ initLinker_ (int retain_cafs) #if defined(THREADED_RTS) initMutex(&linker_mutex); -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - initMutex(&dl_mutex); -#endif #endif symhash = allocStrHashTable(); @@ -520,9 +518,6 @@ exitLinker( void ) { if (linker_init_done == 1) { regfree(&re_invalid); regfree(&re_realso); -#if defined(THREADED_RTS) - closeMutex(&dl_mutex); -#endif } #endif if (linker_init_done == 1) { @@ -556,90 +551,6 @@ exitLinker( void ) { # if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -/* Suppose in ghci we load a temporary SO for a module containing - f = 1 - and then modify the module, recompile, and load another temporary - SO with - f = 2 - Then as we don't unload the first SO, dlsym will find the - f = 1 - symbol whereas we want the - f = 2 - symbol. We therefore need to keep our own SO handle list, and - try SOs in the right order. */ - -typedef - struct _OpenedSO { - struct _OpenedSO* next; - void *handle; - } - OpenedSO; - -/* A list thereof. */ -static OpenedSO* openedSOs = NULL; - -static const char * -internal_dlopen(const char *dll_name) -{ - OpenedSO* o_so; - void *hdl; - const char *errmsg; - char *errmsg_copy; - - // omitted: RTLD_NOW - // see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html - IF_DEBUG(linker, - debugBelch("internal_dlopen: dll_name = '%s'\n", dll_name)); - - //-------------- Begin critical section ------------------ - // This critical section is necessary because dlerror() is not - // required to be reentrant (see POSIX -- IEEE Std 1003.1-2008) - // Also, the error message returned must be copied to preserve it - // (see POSIX also) - - ACQUIRE_LOCK(&dl_mutex); - - // When dlopen() loads a profiled dynamic library, it calls the - // ctors which will call registerCcsList() to append the defined - // CostCentreStacks to CCS_LIST. This execution path starting from - // addDLL() was only protected by dl_mutex previously. However, - // another thread may be doing other things with the RTS linker - // that transitively calls refreshProfilingCCSs() which also - // accesses CCS_LIST, and those execution paths are protected by - // linker_mutex. So there's a risk of data race that may lead to - // segfaults (#24423), and we need to ensure the ctors are also - // protected by ccs_mutex. -#if defined(PROFILING) - ACQUIRE_LOCK(&ccs_mutex); -#endif - - hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ - -#if defined(PROFILING) - RELEASE_LOCK(&ccs_mutex); -#endif - - errmsg = NULL; - if (hdl == NULL) { - /* dlopen failed; return a ptr to the error msg. */ - errmsg = dlerror(); - if (errmsg == NULL) errmsg = "addDLL: unknown error"; - errmsg_copy = stgMallocBytes(strlen(errmsg)+1, "addDLL"); - strcpy(errmsg_copy, errmsg); - errmsg = errmsg_copy; - } else { - o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); - o_so->handle = hdl; - o_so->next = openedSOs; - openedSOs = o_so; - } - - RELEASE_LOCK(&dl_mutex); - //--------------- End critical section ------------------- - - return errmsg; -} - /* Note [RTLD_LOCAL] ~~~~~~~~~~~~~~~~~ @@ -660,11 +571,10 @@ internal_dlopen(const char *dll_name) static void * internal_dlsym(const char *symbol) { - OpenedSO* o_so; void *v; - // We acquire dl_mutex as concurrent dl* calls may alter dlerror - ACQUIRE_LOCK(&dl_mutex); + // concurrent dl* calls may alter dlerror + ASSERT_LOCK_HELD(&linker_mutex); // clears dlerror dlerror(); @@ -672,20 +582,19 @@ internal_dlsym(const char *symbol) { // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } - for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { - v = dlsym(o_so->handle, symbol); - if (dlerror() == NULL) { + for (ObjectCode *nc = loaded_objects; nc; nc = nc->next_loaded_object) { + if (nc->type == DYNAMIC_OBJECT) { + v = dlsym(nc->dlopen_handle, symbol); + if (dlerror() == NULL) { IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); - RELEASE_LOCK(&dl_mutex); return v; + } } } - RELEASE_LOCK(&dl_mutex); IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); # define SPECIAL_SYMBOL(sym) \ @@ -725,79 +634,33 @@ internal_dlsym(const char *symbol) { // we failed to find the symbol return NULL; } -# endif -const char * -addDLL( pathchar *dll_name ) +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name) { -# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) - /* ------------------- ELF DLL loader ------------------- */ - -#define NMATCH 5 - regmatch_t match[NMATCH]; - const char *errmsg; - FILE* fp; - size_t match_length; -#define MAXLINE 1000 - char line[MAXLINE]; - int result; - - IF_DEBUG(linker, debugBelch("addDLL: dll_name = '%s'\n", dll_name)); - errmsg = internal_dlopen(dll_name); + ASSERT_LOCK_HELD(&linker_mutex); - if (errmsg == NULL) { - return NULL; - } +#if defined(OBJFORMAT_MACHO) + CHECK(symbol_name[0] == '_'); + symbol_name = symbol_name+1; +#endif + void *result = dlsym(handle, symbol_name); + return result; +} +# endif - // GHC #2615 - // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) - // contain linker scripts rather than ELF-format object code. This - // code handles the situation by recognizing the real object code - // file name given in the linker script. - // - // If an "invalid ELF header" error occurs, it is assumed that the - // .so file contains a linker script instead of ELF object code. - // In this case, the code looks for the GROUP ( ... ) linker - // directive. If one is found, the first file name inside the - // parentheses is treated as the name of a dynamic library and the - // code attempts to dlopen that file. If this is also unsuccessful, - // an error message is returned. - - // see if the error message is due to an invalid ELF header - IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", errmsg)); - result = regexec(&re_invalid, errmsg, (size_t) NMATCH, match, 0); - IF_DEBUG(linker, debugBelch("result = %i\n", result)); - if (result == 0) { - // success -- try to read the named file as a linker script - match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), - MAXLINE-1); - strncpy(line, (errmsg+(match[1].rm_so)),match_length); - line[match_length] = '\0'; // make sure string is null-terminated - IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); - if ((fp = __rts_fopen(line, "r")) == NULL) { - return errmsg; // return original error if open fails - } - // try to find a GROUP or INPUT ( ... ) command - while (fgets(line, MAXLINE, fp) != NULL) { - IF_DEBUG(linker, debugBelch("input line = %s", line)); - if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { - // success -- try to dlopen the first named file - IF_DEBUG(linker, debugBelch("match%s\n","")); - line[match[2].rm_eo] = '\0'; - stgFree((void*)errmsg); // Free old message before creating new one - errmsg = internal_dlopen(line+match[2].rm_so); - break; - } - // if control reaches here, no GROUP or INPUT ( ... ) directive - // was found and the original error message is returned to the - // caller - } - fclose(fp); +const char *addDLL(pathchar* dll_name) +{ +# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) + char *errmsg; + if (loadNativeObj(dll_name, &errmsg)) { + return NULL; + } else { + ASSERT(errmsg != NULL); + return errmsg; } - return errmsg; # elif defined(OBJFORMAT_PEi386) - return addDLL_PEi386(dll_name, NULL); + return addDLL_PEi386(dll_name); # else barf("addDLL: not implemented on this platform"); @@ -1229,9 +1092,10 @@ void freeObjectCode (ObjectCode *oc) if (oc->type == DYNAMIC_OBJECT) { #if defined(OBJFORMAT_ELF) - ACQUIRE_LOCK(&dl_mutex); - freeNativeCode_ELF(oc); - RELEASE_LOCK(&dl_mutex); + // ROMES:TODO: This previously acquired dl_mutex. Check that acquiring linker_mutex here is fine. + ACQUIRE_LOCK(&linker_mutex); + freeNativeCode_POSIX(oc); + RELEASE_LOCK(&linker_mutex); #else barf("freeObjectCode: This shouldn't happen"); #endif @@ -1896,12 +1760,20 @@ HsInt purgeObj (pathchar *path) return r; } +ObjectCode *lookupObjectByPath(pathchar *path) { + for (ObjectCode *o = objects; o; o = o->next) { + if (0 == pathcmp(o->fileName, path)) { + return o; + } + } + return NULL; +} + OStatus getObjectLoadStatus_ (pathchar *path) { - for (ObjectCode *o = objects; o; o = o->next) { - if (0 == pathcmp(o->fileName, path)) { - return o->status; - } + ObjectCode *oc = lookupObjectByPath(path); + if (oc) { + return oc->status; } return OBJECT_NOT_LOADED; } @@ -1988,11 +1860,21 @@ addSection (Section *s, SectionKind kind, SectionAlloc alloc, #define UNUSED(x) (void)(x) -#if defined(OBJFORMAT_ELF) +#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) void * loadNativeObj (pathchar *path, char **errmsg) { + IF_DEBUG(linker, debugBelch("loadNativeObj: path = '%s'\n", path)); ACQUIRE_LOCK(&linker_mutex); - void *r = loadNativeObj_ELF(path, errmsg); + void *r = loadNativeObj_POSIX(path, errmsg); + +#if defined(OBJFORMAT_ELF) + if (!r) { + // Check if native object may be a linker script and try loading a native + // object from it + r = loadNativeObjFromLinkerScript_ELF(errmsg); + } +#endif + RELEASE_LOCK(&linker_mutex); return r; } @@ -2006,7 +1888,7 @@ loadNativeObj (pathchar *path, char **errmsg) } #endif -HsInt unloadNativeObj (void *handle) +static HsInt unloadNativeObj_(void *handle) { bool unloadedAnyObj = false; @@ -2044,6 +1926,13 @@ HsInt unloadNativeObj (void *handle) } } +HsInt unloadNativeObj(void *handle) { + ACQUIRE_LOCK(&linker_mutex); + HsInt r = unloadNativeObj_(handle); + RELEASE_LOCK(&linker_mutex); + return r; +} + /* ----------------------------------------------------------------------------- * Segment management */ ===================================== rts/LinkerInternals.h ===================================== @@ -412,10 +412,6 @@ extern Elf_Word shndx_table_uninit_label; #if defined(THREADED_RTS) extern Mutex linker_mutex; - -#if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO) -extern Mutex dl_mutex; -#endif #endif /* THREADED_RTS */ /* Type of an initializer */ @@ -515,9 +511,9 @@ HsInt loadArchive_ (pathchar *path); #define USE_CONTIGUOUS_MMAP 0 #endif - HsInt isAlreadyLoaded( pathchar *path ); OStatus getObjectLoadStatus_ (pathchar *path); +ObjectCode *lookupObjectByPath(pathchar *path); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( ObjectType type, pathchar *path, char *image, int imageSize, bool mapped, pathchar *archiveMemberName, ===================================== rts/RtsSymbols.c ===================================== @@ -619,6 +619,7 @@ extern char **environ; SymI_HasProto(purgeObj) \ SymI_HasProto(insertSymbol) \ SymI_HasProto(lookupSymbol) \ + SymI_HasProto(lookupSymbolInNativeObj) \ SymI_HasDataProto(stg_makeStablePtrzh) \ SymI_HasDataProto(stg_mkApUpd0zh) \ SymI_HasDataProto(stg_labelThreadzh) \ ===================================== rts/include/rts/Linker.h ===================================== @@ -90,8 +90,12 @@ void *loadNativeObj( pathchar *path, char **errmsg ); Takes the handle returned from loadNativeObj() as an argument. */ HsInt unloadNativeObj( void *handle ); +void *lookupSymbolInNativeObj(void *handle, const char *symbol_name); + /* load a dynamic library */ -const char *addDLL( pathchar* dll_name ); +const char *addDLL(pathchar* dll_name); + +void *lookupSymbolInDLL(void *handle, const char *symbol_name); /* add a path to the library search path */ HsPtr addLibrarySearchPath(pathchar* dll_path); ===================================== rts/linker/Elf.c ===================================== @@ -2069,159 +2069,6 @@ int ocRunFini_ELF( ObjectCode *oc ) return true; } -/* - * Shared object loading - */ - -#if defined(HAVE_DLINFO) -struct piterate_cb_info { - ObjectCode *nc; - void *l_addr; /* base virtual address of the loaded code */ -}; - -static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size STG_UNUSED, void *data) { - struct piterate_cb_info *s = (struct piterate_cb_info *) data; - - // This logic mimicks _dl_addr_inside_object from glibc - // For reference: - // int - // internal_function - // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) - // { - // int n = l->l_phnum; - // const ElfW(Addr) reladdr = addr - l->l_addr; - // - // while (--n >= 0) - // if (l->l_phdr[n].p_type == PT_LOAD - // && reladdr - l->l_phdr[n].p_vaddr >= 0 - // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) - // return 1; - // return 0; - // } - - if ((void*) info->dlpi_addr == s->l_addr) { - int n = info->dlpi_phnum; - while (--n >= 0) { - if (info->dlpi_phdr[n].p_type == PT_LOAD) { - NativeCodeRange* ncr = - stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); - ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); - ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); - - ncr->next = s->nc->nc_ranges; - s->nc->nc_ranges = ncr; - } - } - } - return 0; -} -#endif /* defined(HAVE_DLINFO) */ - -static void copyErrmsg(char** errmsg_dest, char* errmsg) { - if (errmsg == NULL) errmsg = "loadNativeObj_ELF: unknown error"; - *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_ELF"); - strcpy(*errmsg_dest, errmsg); -} - -// need dl_mutex -void freeNativeCode_ELF (ObjectCode *nc) { - dlclose(nc->dlopen_handle); - - NativeCodeRange *ncr = nc->nc_ranges; - while (ncr) { - NativeCodeRange* last_ncr = ncr; - ncr = ncr->next; - stgFree(last_ncr); - } -} - -void * loadNativeObj_ELF (pathchar *path, char **errmsg) -{ - ObjectCode* nc; - void *hdl, *retval; - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF %" PATH_FMT "\n", path)); - - retval = NULL; - ACQUIRE_LOCK(&dl_mutex); - - /* Loading the same object multiple times will lead to chaos - * as we will have two ObjectCodes but one underlying dlopen - * handle. Fail if this happens. - */ - if (getObjectLoadStatus_(path) != OBJECT_NOT_LOADED) { - copyErrmsg(errmsg, "loadNativeObj_ELF: Already loaded"); - goto dlopen_fail; - } - - nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); - - foreignExportsLoadingObject(nc); - hdl = dlopen(path, RTLD_NOW|RTLD_LOCAL); - nc->dlopen_handle = hdl; - foreignExportsFinishedLoadingObject(); - if (hdl == NULL) { - /* dlopen failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlopen_fail; - } - -#if defined(HAVE_DLINFO) - struct link_map *map; - if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { - /* dlinfo failed; save the message in errmsg */ - copyErrmsg(errmsg, dlerror()); - goto dlinfo_fail; - } - - hdl = NULL; // pass handle ownership to nc - - struct piterate_cb_info piterate_info = { - .nc = nc, - .l_addr = (void *) map->l_addr - }; - dl_iterate_phdr(loadNativeObjCb_, &piterate_info); - if (!nc->nc_ranges) { - copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); - goto dl_iterate_phdr_fail; - } - nc->unloadable = true; -#else - nc->nc_ranges = NULL; - nc->unloadable = false; -#endif /* defined (HAVE_DLINFO) */ - - insertOCSectionIndices(nc); - - nc->next_loaded_object = loaded_objects; - loaded_objects = nc; - - retval = nc->dlopen_handle; - -#if defined(PROFILING) - // collect any new cost centres that were defined in the loaded object. - refreshProfilingCCSs(); -#endif - - goto success; - -dl_iterate_phdr_fail: - // already have dl_mutex - freeNativeCode_ELF(nc); -dlinfo_fail: - if (hdl) dlclose(hdl); -dlopen_fail: -success: - - RELEASE_LOCK(&dl_mutex); - - IF_DEBUG(linker, debugBelch("loadNativeObj_ELF result=%p\n", retval)); - - return retval; -} - - /* * PowerPC & X86_64 ELF specifics */ @@ -2271,4 +2118,70 @@ int ocAllocateExtras_ELF( ObjectCode *oc ) #endif /* NEED_SYMBOL_EXTRAS */ +void * loadNativeObjFromLinkerScript_ELF(char **errmsg) +{ + // GHC #2615 + // On some systems (e.g., Gentoo Linux) dynamic files (e.g. libc.so) + // contain linker scripts rather than ELF-format object code. This + // code handles the situation by recognizing the real object code + // file name given in the linker script. + // + // If an "invalid ELF header" error occurs, it is assumed that the + // .so file contains a linker script instead of ELF object code. + // In this case, the code looks for the GROUP ( ... ) linker + // directive. If one is found, the first file name inside the + // parentheses is treated as the name of a dynamic library and the + // code attempts to dlopen that file. If this is also unsuccessful, + // an error message is returned. + +#define NMATCH 5 + regmatch_t match[NMATCH]; + FILE* fp; + size_t match_length; +#define MAXLINE 1000 + char line[MAXLINE]; + int result; + void* r = NULL; + + ASSERT_LOCK_HELD(&linker_mutex) + + // see if the error message is due to an invalid ELF header + IF_DEBUG(linker, debugBelch("errmsg = '%s'\n", *errmsg)); + result = regexec(&re_invalid, *errmsg, (size_t) NMATCH, match, 0); + IF_DEBUG(linker, debugBelch("result = %i\n", result)); + if (result == 0) { + // success -- try to read the named file as a linker script + match_length = (size_t) stg_min((match[1].rm_eo - match[1].rm_so), + MAXLINE-1); + strncpy(line, (*errmsg+(match[1].rm_so)),match_length); + line[match_length] = '\0'; // make sure string is null-terminated + IF_DEBUG(linker, debugBelch("file name = '%s'\n", line)); + if ((fp = __rts_fopen(line, "r")) == NULL) { + // return original error if open fails + return NULL; + } + // try to find a GROUP or INPUT ( ... ) command + while (fgets(line, MAXLINE, fp) != NULL) { + IF_DEBUG(linker, debugBelch("input line = %s", line)); + if (regexec(&re_realso, line, (size_t) NMATCH, match, 0) == 0) { + // success -- try to dlopen the first named file + IF_DEBUG(linker, debugBelch("match%s\n","")); + line[match[2].rm_eo] = '\0'; + stgFree((void*)*errmsg); // Free old message before creating new one + // ROMES:TODO: NO GOOD, this is almost recursive? no, as long we + // move the loadNativeObj_ELF to a shared impl + r = loadNativeObj_POSIX(line+match[2].rm_so, errmsg); + break; + } + // if control reaches here, no GROUP or INPUT ( ... ) directive + // was found and the original error message is returned to the + // caller + } + fclose(fp); + } + + return r; +} + + #endif /* elf */ ===================================== rts/linker/Elf.h ===================================== @@ -14,7 +14,6 @@ int ocResolve_ELF ( ObjectCode* oc ); int ocRunInit_ELF ( ObjectCode* oc ); int ocRunFini_ELF ( ObjectCode* oc ); int ocAllocateExtras_ELF ( ObjectCode *oc ); -void freeNativeCode_ELF ( ObjectCode *nc ); -void *loadNativeObj_ELF ( pathchar *path, char **errmsg ); +void *loadNativeObjFromLinkerScript_ELF( char **errmsg ); #include "EndPrivate.h" ===================================== rts/linker/LoadNativeObjPosix.c ===================================== @@ -0,0 +1,211 @@ +#include "CheckUnload.h" +#include "ForeignExports.h" +#include "LinkerInternals.h" +#include "Rts.h" +#include "RtsUtils.h" +#include "Profiling.h" + +#include "linker/LoadNativeObjPosix.h" + +#if defined(HAVE_DLFCN_H) +#include +#endif + +#include + +#if defined(THREADED_RTS) +extern Mutex linker_mutex; +#endif + +/* + * Shared object loading + */ + +#if defined(HAVE_DLINFO) +struct piterate_cb_info { + ObjectCode *nc; + void *l_addr; /* base virtual address of the loaded code */ +}; + +static int loadNativeObjCb_(struct dl_phdr_info *info, + size_t _size STG_UNUSED, void *data) { + struct piterate_cb_info *s = (struct piterate_cb_info *) data; + + // This logic mimicks _dl_addr_inside_object from glibc + // For reference: + // int + // internal_function + // _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr) + // { + // int n = l->l_phnum; + // const ElfW(Addr) reladdr = addr - l->l_addr; + // + // while (--n >= 0) + // if (l->l_phdr[n].p_type == PT_LOAD + // && reladdr - l->l_phdr[n].p_vaddr >= 0 + // && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz) + // return 1; + // return 0; + // } + + if ((void*) info->dlpi_addr == s->l_addr) { + int n = info->dlpi_phnum; + while (--n >= 0) { + if (info->dlpi_phdr[n].p_type == PT_LOAD) { + NativeCodeRange* ncr = + stgMallocBytes(sizeof(NativeCodeRange), "loadNativeObjCb_"); + ncr->start = (void*) ((char*) s->l_addr + info->dlpi_phdr[n].p_vaddr); + ncr->end = (void*) ((char*) ncr->start + info->dlpi_phdr[n].p_memsz); + + ncr->next = s->nc->nc_ranges; + s->nc->nc_ranges = ncr; + } + } + } + return 0; +} +#endif /* defined(HAVE_DLINFO) */ + +static void copyErrmsg(char** errmsg_dest, char* errmsg) { + if (errmsg == NULL) errmsg = "loadNativeObj_POSIX: unknown error"; + *errmsg_dest = stgMallocBytes(strlen(errmsg)+1, "loadNativeObj_POSIX"); + strcpy(*errmsg_dest, errmsg); +} + +void freeNativeCode_POSIX (ObjectCode *nc) { + ASSERT_LOCK_HELD(&linker_mutex); + + dlclose(nc->dlopen_handle); + + NativeCodeRange *ncr = nc->nc_ranges; + while (ncr) { + NativeCodeRange* last_ncr = ncr; + ncr = ncr->next; + stgFree(last_ncr); + } +} + +void * loadNativeObj_POSIX (pathchar *path, char **errmsg) +{ + ObjectCode* nc; + void *hdl, *retval; + + ASSERT_LOCK_HELD(&linker_mutex); + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX %" PATH_FMT "\n", path)); + + retval = NULL; + + + /* If we load the same object multiple times, just return the + * already-loaded handle. Note that this is broken if unloadNativeObj + * is used, as we don’t do any reference counting; see #24345. + */ + ObjectCode *existing_oc = lookupObjectByPath(path); + if (existing_oc && existing_oc->status != OBJECT_UNLOADED) { + if (existing_oc->type == DYNAMIC_OBJECT) { + retval = existing_oc->dlopen_handle; + goto success; + } + copyErrmsg(errmsg, "loadNativeObj_POSIX: already loaded as non-dynamic object"); + goto dlopen_fail; + } + + nc = mkOc(DYNAMIC_OBJECT, path, NULL, 0, false, NULL, 0); + + foreignExportsLoadingObject(nc); + + // When dlopen() loads a profiled dynamic library, it calls the ctors which + // will call registerCcsList() to append the defined CostCentreStacks to + // CCS_LIST. However, another thread may be doing other things with the RTS + // linker that transitively calls refreshProfilingCCSs() which also accesses + // CCS_LIST. So there's a risk of data race that may lead to segfaults + // (#24423), and we need to ensure the ctors are also protected by + // ccs_mutex. +#if defined(PROFILING) + ACQUIRE_LOCK(&ccs_mutex); +#endif + + // If we HAVE_DLINFO, we use RTLD_NOW rather than RTLD_LAZY because we want + // to learn eagerly about all external functions. Otherwise, there is no + // additional advantage to being eager, so it is better to be lazy and only bind + // functions when needed for better performance. + int dlopen_mode; +#if defined(HAVE_DLINFO) + dlopen_mode = RTLD_NOW; +#else + dlopen_mode = RTLD_LAZY; +#endif + + hdl = dlopen(path, dlopen_mode|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + nc->dlopen_handle = hdl; + nc->status = OBJECT_READY; + +#if defined(PROFILING) + RELEASE_LOCK(&ccs_mutex); +#endif + + foreignExportsFinishedLoadingObject(); + + if (hdl == NULL) { + /* dlopen failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlopen_fail; + } + +#if defined(HAVE_DLINFO) + struct link_map *map; + if (dlinfo(hdl, RTLD_DI_LINKMAP, &map) == -1) { + /* dlinfo failed; save the message in errmsg */ + copyErrmsg(errmsg, dlerror()); + goto dlinfo_fail; + } + + hdl = NULL; // pass handle ownership to nc + + struct piterate_cb_info piterate_info = { + .nc = nc, + .l_addr = (void *) map->l_addr + }; + dl_iterate_phdr(loadNativeObjCb_, &piterate_info); + if (!nc->nc_ranges) { + copyErrmsg(errmsg, "dl_iterate_phdr failed to find obj"); + goto dl_iterate_phdr_fail; + } + nc->unloadable = true; +#else + nc->nc_ranges = NULL; + nc->unloadable = false; +#endif /* defined (HAVE_DLINFO) */ + + insertOCSectionIndices(nc); + + nc->next_loaded_object = loaded_objects; + loaded_objects = nc; + + retval = nc->dlopen_handle; + +#if defined(PROFILING) + // collect any new cost centres that were defined in the loaded object. + refreshProfilingCCSs(); +#endif + + goto success; + +#if defined(HAVE_DLINFO) +dl_iterate_phdr_fail: +#endif + freeNativeCode_POSIX(nc); +#if defined(HAVE_DLINFO) +dlinfo_fail: +#endif + if (hdl) dlclose(hdl); +dlopen_fail: +success: + + IF_DEBUG(linker, debugBelch("loadNativeObj_POSIX result=%p\n", retval)); + + return retval; +} + + ===================================== rts/linker/LoadNativeObjPosix.h ===================================== @@ -0,0 +1,11 @@ +#pragma once + +#include "Rts.h" +#include "LinkerInternals.h" + +#include "BeginPrivate.h" + +void freeNativeCode_POSIX ( ObjectCode *nc ); +void *loadNativeObj_POSIX ( pathchar *path, char **errmsg ); + +#include "EndPrivate.h" ===================================== rts/linker/PEi386.c ===================================== @@ -1865,6 +1865,7 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if (result != NULL || dllInstance == 0) { errorBelch("Could not load `%s'. Reason: %s\n", (char*)dllName, result); + stgFree((void*)result); return false; } ===================================== rts/rts.cabal ===================================== @@ -458,6 +458,7 @@ library linker/Elf.c linker/InitFini.c linker/LoadArchive.c + linker/LoadNativeObjPosix.c linker/M32Alloc.c linker/MMap.c linker/MachO.c ===================================== testsuite/tests/ghci/linking/dyn/T3372.hs ===================================== @@ -1,3 +1,6 @@ +-- Note: This test exercises running concurrent GHCi sessions, but +-- although this test is expected to pass, running concurrent GHCi +-- sessions is currently broken in other ways; see #24345. {-# LANGUAGE MagicHash #-} module Main where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f699827724a3e95189fd9ddb7499a6a6abf11522...573b9729cabfbbc4810ae894ec7a6932ab24dcd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f699827724a3e95189fd9ddb7499a6a6abf11522...573b9729cabfbbc4810ae894ec7a6932ab24dcd3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 14:05:29 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 28 Mar 2024 10:05:29 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/bidir-ki-check] 90 commits: base: Use strerror_r instead of strerror Message-ID: <6605792950b5b_25bec4225f04c7153a@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/bidir-ki-check at Glasgow Haskell Compiler / GHC Commits: 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - e17bf91e by Andrei Borzenkov at 2024-03-28T18:05:10+04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Core/LateCC/OverloadedCalls.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Word64Map/Strict.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Config/CoreToStg/Prep.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fcb5bb72b14ee499f137da19fd0802ab337b5f8f...e17bf91e1fb4ee058f86688d875a24cd9d9e83e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fcb5bb72b14ee499f137da19fd0802ab337b5f8f...e17bf91e1fb4ee058f86688d875a24cd9d9e83e9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 15:37:08 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 11:37:08 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip2 Message-ID: <66058ea49ce95_25bec42ddf8687537a@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: e98c02f2 by Jade at 2024-03-28T16:41:35+01:00 wip2 - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - − testsuite/tests/ghci/linking/T11531.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr - testsuite/tests/parser/should_fail/T18251e.stderr - testsuite/tests/parser/should_fail/T3095.stderr - testsuite/tests/parser/should_fail/readFail001.stderr - testsuite/tests/parser/should_fail/readFail036.stderr - testsuite/tests/parser/should_fail/readFail037.stderr - testsuite/tests/parser/should_fail/readFail038.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e98c02f2bebdeb41493b2cc2f106436d9a37a9b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e98c02f2bebdeb41493b2cc2f106436d9a37a9b5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 15:48:47 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 11:48:47 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip2 Message-ID: <6605915f8b32a_25bec42f65ea8757c5@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: c30df2b4 by Jade at 2024-03-28T16:53:19+01:00 wip2 - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr - testsuite/tests/parser/should_fail/T18251e.stderr - testsuite/tests/parser/should_fail/T3095.stderr - testsuite/tests/parser/should_fail/readFail001.stderr - testsuite/tests/parser/should_fail/readFail036.stderr - testsuite/tests/parser/should_fail/readFail037.stderr - testsuite/tests/parser/should_fail/readFail038.stderr - testsuite/tests/polykinds/BadKindVar.stderr - testsuite/tests/polykinds/T14710.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c30df2b442b7376b04184a9c8a7c41fc6b795d37 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c30df2b442b7376b04184a9c8a7c41fc6b795d37 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 15:50:23 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 11:50:23 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip2 Message-ID: <660591bf2519e_25bec42fcb76c7764d@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 1bee65f0 by Jade at 2024-03-28T16:54:42+01:00 wip2 - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr - testsuite/tests/parser/should_fail/T18251e.stderr - testsuite/tests/parser/should_fail/T3095.stderr - testsuite/tests/parser/should_fail/readFail001.stderr - testsuite/tests/parser/should_fail/readFail036.stderr - testsuite/tests/parser/should_fail/readFail037.stderr - testsuite/tests/parser/should_fail/readFail038.stderr - testsuite/tests/polykinds/BadKindVar.stderr - testsuite/tests/polykinds/T14710.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bee65f052f45998bb93df432dd99556223fad33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bee65f052f45998bb93df432dd99556223fad33 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 15:51:35 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 28 Mar 2024 11:51:35 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24601 Message-ID: <660592076b69c_25bec42fef7347785c@gitlab.mail> Ben Gamari pushed new branch wip/T24601 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24601 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 15:52:07 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 28 Mar 2024 11:52:07 -0400 Subject: [Git][ghc/ghc][wip/T24601] 10 commits: rts: fix clang compilation on aarch64 Message-ID: <66059227b6e7_25bec430488c078032@gitlab.mail> Ben Gamari pushed to branch wip/T24601 at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - fb19e109 by Ben Gamari at 2024-03-28T11:51:38-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 25 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Utils.hs - distrib/configure.ac.in - hadrian/bindist/Makefile - libffi-tarballs - m4/fp_cc_linker_flag_try.m4 - rts/ARMOutlineAtomicsSymbols.h - rts/js/profiling.js - − testsuite/tests/codeGen/should_run/T24507.hs - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PprLetIn.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -301,20 +301,15 @@ isJumpishInstr instr = case instr of -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr (ANN _ i) = jumpDestsOfInstr i -jumpDestsOfInstr i = case i of - (CBZ _ t) -> [ mkDest t ] - (CBNZ _ t) -> [ mkDest t ] - (J t) -> [ mkDest t ] - (B t) -> [ mkDest t ] - (BL t _ _) -> [ mkDest t ] - (BCOND _ t) -> [ mkDest t ] - _ -> [] - where - mkDest (TBlock id) = Just id - mkDest TLabel{} = Nothing - mkDest TReg{} = Nothing +jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] +jumpDestsOfInstr (BL t _ _) = [ id | TBlock id <- [t]] +jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] +jumpDestsOfInstr _ = [] -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/BlockLayout.hs ===================================== @@ -771,7 +771,7 @@ dropJumps :: forall a i. Instruction i => LabelMap a -> [GenBasicBlock i] dropJumps _ [] = [] dropJumps info (BasicBlock lbl ins:todo) | Just ins <- nonEmpty ins --This can happen because of shortcutting - , [Just dest] <- jumpDestsOfInstr (NE.last ins) + , [dest] <- jumpDestsOfInstr (NE.last ins) , BasicBlock nextLbl _ : _ <- todo , not (mapMember dest info) , nextLbl == dest @@ -870,7 +870,7 @@ mkNode edgeWeights block@(BasicBlock id instrs) = | length successors > 2 || edgeWeight info <= 0 -> [] | otherwise -> [target] | Just instr <- lastMaybe instrs - , [one] <- jumpBlockDestsOfInstr instr + , [one] <- jumpDestsOfInstr instr = [one] | otherwise = [] ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -17,8 +17,6 @@ import GHC.Cmm.BlockId import GHC.CmmToAsm.Config import GHC.Data.FastString -import Data.Maybe (catMaybes) - -- | Holds a list of source and destination registers used by a -- particular instruction. -- @@ -75,17 +73,9 @@ class Instruction instr where -- | Give the possible destinations of this jump instruction. -- Must be defined for all jumpish instructions. - -- Returns Nothing for non BlockId destinations. jumpDestsOfInstr - :: instr -> [Maybe BlockId] - - -- | Give the possible block destinations of this jump instruction. - -- Must be defined for all jumpish instructions. - jumpBlockDestsOfInstr :: instr -> [BlockId] - jumpBlockDestsOfInstr = catMaybes . jumpDestsOfInstr - -- | Change the destination of this jump instruction. -- Used in the linear allocator when adding fixup blocks for join ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -513,15 +513,12 @@ isJumpishInstr instr -- | Checks whether this instruction is a jump/branch instruction. -- One that can change the flow of control in a way that the -- register allocator needs to worry about. -jumpDestsOfInstr :: Instr -> [Maybe BlockId] +jumpDestsOfInstr :: Instr -> [BlockId] jumpDestsOfInstr insn = case insn of - BCC _ id _ -> [Just id] - BCCFAR _ id _ -> [Just id] - BCTR targets _ _ -> targets - BCTRL{} -> [Nothing] - BL{} -> [Nothing] - JMP{} -> [Nothing] + BCC _ id _ -> [id] + BCCFAR _ id _ -> [id] + BCTR targets _ _ -> [id | Just id <- targets] _ -> [] ===================================== compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs ===================================== @@ -207,7 +207,7 @@ cleanForward platform blockId assoc acc (li : instrs) -- Remember the association over a jump. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accJumpValid assoc) targets cleanForward platform blockId assoc (li : acc) instrs @@ -386,7 +386,7 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs) -- it always does, but if those reloads are cleaned the slot -- liveness map doesn't get updated. | LiveInstr instr _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr = do let slotsReloadedByTargets = IntSet.unions ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -57,7 +57,7 @@ joinToTargets block_live id instr = return ([], instr) | otherwise - = joinToTargets' block_live [] id instr (jumpBlockDestsOfInstr instr) + = joinToTargets' block_live [] id instr (jumpDestsOfInstr instr) ----- joinToTargets' ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -468,7 +468,7 @@ slurpReloadCoalesce live -- if we hit a jump, remember the current slotMap | LiveInstr (Instr instr) _ <- li - , targets <- jumpBlockDestsOfInstr instr + , targets <- jumpDestsOfInstr instr , not $ null targets = do mapM_ (accSlotMap slotMap) targets return (slotMap, Nothing) @@ -760,7 +760,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs sccs = stronglyConnCompG g2 getOutEdges :: Instruction instr => [instr] -> [BlockId] - getOutEdges instrs = concatMap jumpBlockDestsOfInstr instrs + getOutEdges instrs = concatMap jumpDestsOfInstr instrs -- This is truly ugly, but I don't see a good alternative. -- Digraph just has the wrong API. We want to identify nodes @@ -837,7 +837,7 @@ checkIsReverseDependent sccs' slurpJumpDestsOfBlock (BasicBlock _ instrs) = unionManyUniqSets - $ map (mkUniqSet . jumpBlockDestsOfInstr) + $ map (mkUniqSet . jumpDestsOfInstr) [ i | LiveInstr i _ <- instrs] @@ -1047,7 +1047,7 @@ liveness1 platform liveregs blockmap (LiveInstr instr _) -- union in the live regs from all the jump destinations of this -- instruction. - targets = jumpBlockDestsOfInstr instr -- where we go from here + targets = jumpDestsOfInstr instr -- where we go from here not_a_branch = null targets targetLiveRegs target ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -672,16 +672,13 @@ isJumpishInstr instr jumpDestsOfInstr :: Instr - -> [Maybe BlockId] + -> [BlockId] jumpDestsOfInstr insn = case insn of - JXX _ id -> [Just id] - JMP_TBL _ ids _ _ -> [(mkDest dest) | Just dest <- ids] + JXX _ id -> [id] + JMP_TBL _ ids _ _ -> [id | Just (DestBlockId id) <- ids] _ -> [] - where - mkDest (DestBlockId id) = Just id - mkDest _ = Nothing patchJumpInstr ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -736,12 +736,12 @@ mkBigLHsPatTup = mkChunkified mkLHsPatTup -- | Convert an 'LHsType' to an 'LHsSigType'. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -hsTypeToHsSigType lty@(L loc ty) = L loc $ case ty of +hsTypeToHsSigType lty@(L loc ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an , hsf_invis_bndrs = bndrs } , hst_body = body } - -> mkHsExplicitSigType an bndrs body - _ -> mkHsImplicitSigType lty + -> L loc $ mkHsExplicitSigType an bndrs body + _ -> L (l2l loc) $ mkHsImplicitSigType lty -- The annotations are in lty, erase them from loc -- | Convert an 'LHsType' to an 'LHsSigWcType'. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs ===================================== compiler/GHC/Parser.y ===================================== @@ -1438,10 +1438,10 @@ ty_fam_inst_eqns :: { Located [LTyFamInstEqn GhcPs] } h' <- addTrailingSemiA h (gl $2) return (sLL $1 $> ($3 : h' : t)) } | ty_fam_inst_eqns ';' {% case unLoc $1 of - [] -> return (sLL $1 $> (unLoc $1)) + [] -> return (sLZ $1 $> (unLoc $1)) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | ty_fam_inst_eqn { sLL $1 $> [$1] } | {- empty -} { noLoc [] } @@ -1719,12 +1719,12 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_cls { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1765,12 +1765,12 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_inst { sL1 $1 ([],unLoc $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1806,12 +1806,12 @@ decls :: { Located ([AddEpAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLL $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemiA $2) + then return (sLZ $1 $> (((fst $ unLoc $1) ++ (msemiA $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -3334,11 +3334,11 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs return (sLL $1 $> (fst $ unLoc $1,$3 : h' : t)) } | alts1(PATS) ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (fst $ unLoc $1, h' : t)) } + return (sLZ $1 $> (fst $ unLoc $1, h' : t)) } | alt(PATS) { $1 >>= \ $1 -> return $ sL1 $1 ([],[$1]) } alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) } @@ -3442,7 +3442,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} @@ -3552,7 +3552,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed | dbinds ';' {% case unLoc $1 of (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | dbind { let this = $1 in this `seq` (sL1 $1 [this]) } -- | {- empty -} { [] } @@ -4195,6 +4195,12 @@ sLLAsl :: (HasLoc a) => [a] -> Located b -> c -> Located c sLLAsl [] = sL1 sLLAsl (!x:_) = sLL x +{-# INLINE sLZ #-} +sLZ :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c +sLZ !x !y = if isZeroWidthSpan (getHasLoc y) + then sL (getHasLoc x) + else sL (comb2 x y) + {- Note [Adding location info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2870,7 +2870,7 @@ alexInputPrevChar (AI _ buf) = unsafeChr (fromIntegral (adjustChar pc)) where pc = prevChar buf '\n' unsafeChr :: Int -> Char -unsafeChr (I# c) = C# (chr# c) +unsafeChr (I# c) = GHC.Exts.C# (GHC.Exts.chr# c) -- backwards compatibility for Alex 2.x alexGetChar :: AlexInput -> Maybe (Char,AlexInput) ===================================== compiler/GHC/Runtime/Utils.hs ===================================== @@ -29,7 +29,7 @@ foreign import ccall "io.h _close" c__close :: CInt -> IO CInt foreign import ccall unsafe "io.h _get_osfhandle" - _get_osfhandle :: CInt -> IO CInt + _get_osfhandle :: CInt -> IO HANDLE runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle) -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle) ===================================== distrib/configure.ac.in ===================================== @@ -105,6 +105,29 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) fi + +if test "$HostOS" = "darwin"; then + # On darwin, we need to clean the extended attributes of the + # ghc-toolchain binary and its dynamic library before we can execute it in the bindist + # (this is a workaround for #24554, for the lack of proper notarisation #17418) + + # The following is the work around suggested by @carter in #17418 during + # install time. This should help us with code signing issues by removing + # extended attributes from all files. + XATTR=${XATTR:-/usr/bin/xattr} + + if [ -e "${XATTR}" ]; then + + # Instead of cleaning the attributes of the ghc-toolchain binary only, + # we clean them from all files in the bin/ and lib/ directories, as it additionally future + # proofs running executables from the bindist besides ghc-toolchain at configure time, and + # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. + /usr/bin/xattr -rc bin/ + /usr/bin/xattr -rc lib/ + + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) ===================================== hadrian/bindist/Makefile ===================================== @@ -19,13 +19,6 @@ default: # TODO : find if a better function exists eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# the following is the work around suggested by @carter in #17418 during install -# time. This should help us with code signing issues by removing extended -# attributes from all files. -ifeq "$(Darwin_Host)" "YES" -XATTR ?= /usr/bin/xattr -endif - # patchpackageconf # # Hacky function to patch up the 'haddock-interfaces' and 'haddock-html' @@ -157,10 +150,6 @@ install_bin_libdir: $(INSTALL_PROGRAM) "$$i" "$(DESTDIR)$(ActualBinsDir)"; \ fi; \ done - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualBinsDir)"; \ - fi .PHONY: install_bin_direct install_bin_direct: @@ -195,10 +184,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - # Work around #17418 on Darwin - if [ -e "${XATTR}" ]; then \ - "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ - fi .PHONY: install_docs install_docs: ===================================== libffi-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 5624fd5c8bbce8432cd3c0b0ea92d152a1bba047 +Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1 ===================================== m4/fp_cc_linker_flag_try.m4 ===================================== @@ -9,7 +9,7 @@ AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [ AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1]) echo 'int main(void) {return 0;}' > conftest.c - if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1 + if $CC -o conftest.o -fuse-ld=$1 $LDFLAGS conftest.c > /dev/null 2>&1 then $2="-fuse-ld=$1" AC_MSG_RESULT([yes]) ===================================== rts/ARMOutlineAtomicsSymbols.h ===================================== @@ -10,583 +10,583 @@ #include #include -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_relax(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_acq_rel(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p); -uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, uint8_t* p) { +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p); +uint8_t ghc___aarch64_cas1_sync(uint8_t old, uint8_t new, _Atomic uint8_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_relax(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_acq_rel(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p); -uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, uint16_t* p) { +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p); +uint16_t ghc___aarch64_cas2_sync(uint16_t old, uint16_t new, _Atomic uint16_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_relax(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_acq_rel(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p); -uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, uint32_t* p) { +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p); +uint32_t ghc___aarch64_cas4_sync(uint32_t old, uint32_t new, _Atomic uint32_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_relax(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_relaxed, memory_order_relaxed); return old; } -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acquire, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_acq_rel(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_acq_rel, memory_order_acquire); return old; } -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p); -uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, uint64_t* p) { +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p); +uint64_t ghc___aarch64_cas8_sync(uint64_t old, uint64_t new, _Atomic uint64_t* p) { atomic_compare_exchange_strong_explicit(p, &old, new, memory_order_seq_cst, memory_order_seq_cst); return old; } -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_swp1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_swp1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_swp2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_swp2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_swp4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_swp4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_swp8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_swp8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_exchange_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldadd1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldadd2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldadd4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldadd8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_add_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldclr1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldclr2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldclr4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldclr8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_and_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldeor1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldeor2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldeor4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldeor8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_xor_explicit(p, v, memory_order_seq_cst); } -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_relax(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_relax(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_acq_rel(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p); -uint8_t ghc___aarch64_ldset1_sync(uint8_t v, uint8_t* p) { +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p); +uint8_t ghc___aarch64_ldset1_sync(uint8_t v, _Atomic uint8_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_relax(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_relax(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_acq_rel(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p); -uint16_t ghc___aarch64_ldset2_sync(uint16_t v, uint16_t* p) { +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p); +uint16_t ghc___aarch64_ldset2_sync(uint16_t v, _Atomic uint16_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_relax(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_relax(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_acq_rel(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p); -uint32_t ghc___aarch64_ldset4_sync(uint32_t v, uint32_t* p) { +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p); +uint32_t ghc___aarch64_ldset4_sync(uint32_t v, _Atomic uint32_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_relax(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_relax(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_relaxed); } -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acquire); } -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_release); } -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_acq_rel(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_acq_rel); } -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p); -uint64_t ghc___aarch64_ldset8_sync(uint64_t v, uint64_t* p) { +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p); +uint64_t ghc___aarch64_ldset8_sync(uint64_t v, _Atomic uint64_t* p) { return atomic_fetch_or_explicit(p, v, memory_order_seq_cst); } ===================================== rts/js/profiling.js ===================================== @@ -331,7 +331,3 @@ function h$buildCCSPtr(o) { function h$clearCCS(a) { throw new Error("ClearCCSOp not implemented"); } - -function h$rts_isProfiled() { - return 0; -} ===================================== testsuite/tests/codeGen/should_run/T24507.hs deleted ===================================== @@ -1,15 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE GHCForeignImportPrim #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import GHC.Exts - -foreign import prim "foo" foo :: Int# -> Int# - -main = do - - let f x = case x of I# x' -> case foo x' of x -> print (I# x) - mapM_ f [1..7] \ No newline at end of file ===================================== testsuite/tests/codeGen/should_run/T24507.stdout deleted ===================================== @@ -1,7 +0,0 @@ -1 -2 -2 -2 -2 -2 -2 ===================================== testsuite/tests/codeGen/should_run/T24507_cmm.cmm deleted ===================================== @@ -1,35 +0,0 @@ -#include "Cmm.h" - -bar() { - return (2); -} - -foo(W_ x) { - - switch(x) { - case 1: goto a; - case 2: goto b; - case 3: goto c; - case 4: goto d; - case 5: goto e; - case 6: goto f; - case 7: goto g; - } - return (1); - - a: - return (1); - b: - jump bar(); - c: - jump bar(); - d: - jump bar(); - e: - jump bar(); - f: - jump bar(); - g: - jump bar(); - -} ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,6 +243,3 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) - -test('T24507', [req_cmm], multi_compile_and_run, - ['T24507', [('T24507_cmm.cmm', '')], '-O2']) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -821,3 +821,8 @@ AnnotationNoListTuplePuns: Test24533: $(CHECK_PPR) $(LIBDIR) Test24533.hs $(CHECK_EXACT) $(LIBDIR) Test24533.hs + +.PHONY: PprLetIn +PprLetIn: + $(CHECK_PPR) $(LIBDIR) PprLetIn.hs + $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs ===================================== testsuite/tests/printer/PprLetIn.hs ===================================== @@ -0,0 +1,5 @@ +module PprLetIn where + +ff = let + x = 1 + in 4 ===================================== testsuite/tests/printer/all.T ===================================== @@ -197,3 +197,4 @@ test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) +test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5554dffd47ed08f29c854c7f6f04cd42419a76f2...fb19e109d05bf4b633a7b2888807fd73975d4183 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5554dffd47ed08f29c854c7f6f04cd42419a76f2...fb19e109d05bf4b633a7b2888807fd73975d4183 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 15:54:02 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 28 Mar 2024 11:54:02 -0400 Subject: [Git][ghc/ghc][wip/T24601] Fix type of _get_osfhandle foreign import Message-ID: <6605929a354d5_25bec43134ab87981f@gitlab.mail> Ben Gamari pushed to branch wip/T24601 at Glasgow Haskell Compiler / GHC Commits: 128775ee by Ben Gamari at 2024-03-28T11:53:57-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 1 changed file: - compiler/GHC/Runtime/Utils.hs Changes: ===================================== compiler/GHC/Runtime/Utils.hs ===================================== @@ -29,7 +29,7 @@ foreign import ccall "io.h _close" c__close :: CInt -> IO CInt foreign import ccall unsafe "io.h _get_osfhandle" - _get_osfhandle :: CInt -> IO CInt + _get_osfhandle :: CInt -> IO CIntPtr runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle) -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/128775eea1cdc2d569a8a8dd0b1bb4ceac903851 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/128775eea1cdc2d569a8a8dd0b1bb4ceac903851 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 16:21:20 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 12:21:20 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip2 Message-ID: <66059900bdeb1_25bec434ee7bc853e3@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: a3ff1b1a by Jade at 2024-03-28T17:25:50+01:00 wip2 - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr - testsuite/tests/parser/should_fail/T18251e.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3ff1b1a338109f3825da15399bf76f6561f1347 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3ff1b1a338109f3825da15399bf76f6561f1347 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 16:24:37 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 12:24:37 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip2 Message-ID: <660599c52215_25bec435889ac85523@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 7f395d2e by Jade at 2024-03-28T17:29:10+01:00 wip2 - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr - testsuite/tests/parser/should_fail/T18251e.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f395d2ecf50d7161e355ddb4dcef3ab6b007880 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f395d2ecf50d7161e355ddb4dcef3ab6b007880 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 16:32:35 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 12:32:35 -0400 Subject: [Git][ghc/ghc][wip/T24477] When suggesting Language extensions, also suggest Extensions which imply Message-ID: <66059ba3523ab_25bec4366b5cc857d4@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: e1951d93 by Jade at 2024-03-28T17:37:05+01:00 When suggesting Language extensions, also suggest Extensions which imply them Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 - - - - - 30 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1951d9301248ea0f09e115fa600f9bce8d86ee4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1951d9301248ea0f09e115fa600f9bce8d86ee4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 16:37:37 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 12:37:37 -0400 Subject: [Git][ghc/ghc][wip/T24477] When suggesting Language extensions, also suggest Extensions which imply them Message-ID: <66059cd1cca_25bec43726a4887594@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 393d5f7b by Jade at 2024-03-28T17:42:04+01:00 When suggesting Language extensions, also suggest Extensions which imply them Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 - - - - - 30 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/393d5f7b3903155f3f0cb53022ad262e129c3859 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/393d5f7b3903155f3f0cb53022ad262e129c3859 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 17:13:32 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 28 Mar 2024 13:13:32 -0400 Subject: [Git][ghc/ghc][wip/T24359] Fix derivations conflict in parser, disambiguate them in post-process Message-ID: <6605a53cd3dc8_25bec43b9a7f09107b@gitlab.mail> Andrei Borzenkov pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: 2d39571f by Andrei Borzenkov at 2024-03-28T21:13:19+04:00 Fix derivations conflict in parser, disambiguate them in post-process - - - - - 5 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Types/Error/Codes.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1871,7 +1871,7 @@ rule :: { LRuleDecl GhcPs } { rd_ext = (((fst $3) (mj AnnEqual $5 : (fst $2))), getSTRINGs $1) , rd_name = L (noAnnSrcSpan $ gl $1) (getSTRING $1) , rd_act = snd $2 `orElse` AlwaysActive - , rd_bndrs = snd $3 + , rd_bndrs = ruleBndrsOrDef (snd $3) , rd_lhs = $4, rd_rhs = $6 }) } -- Rules can be specified to be NeverActive, unlike inline/specialize pragmas @@ -1907,7 +1907,7 @@ rule_explicit_activation :: { ([AddEpAnn] { ($2++[mos $1,mcs $3] ,NeverActive) } -rule_foralls :: { ([AddEpAnn] -> HsRuleAnn, RuleBndrs GhcPs) } +rule_foralls :: { ([AddEpAnn] -> HsRuleAnn, Maybe (RuleBndrs GhcPs)) } : 'forall' rule_vars '.' 'forall' rule_vars '.' {% hintExplicitForall $1 >> checkRuleTyVarBndrNames $2 @@ -1915,15 +1915,15 @@ rule_foralls :: { ([AddEpAnn] -> HsRuleAnn, RuleBndrs GhcPs) } (Just (mu AnnForall $1,mj AnnDot $3)) (Just (mu AnnForall $4,mj AnnDot $6)) anns - , mkRuleBndrs (Just $2) $5 ) } + , Just (mkRuleBndrs (Just $2) $5) ) } | 'forall' rule_vars '.' { ( \anns -> HsRuleAnn Nothing (Just (mu AnnForall $1,mj AnnDot $3)) anns - , mkRuleBndrs Nothing $2 ) } + , Just (mkRuleBndrs Nothing $2) ) } -- See Note [%shift: rule_foralls -> {- empty -}] | {- empty -} %shift - { (\anns -> HsRuleAnn Nothing Nothing anns, mkRuleBndrs Nothing []) } + { (\anns -> HsRuleAnn Nothing Nothing anns, Nothing) } rule_vars :: { [LRuleTyTmVar] } : rule_var rule_vars { $1 : $2 } @@ -2681,25 +2681,13 @@ sigdecl :: { LHsDecl GhcPs } ; let str_lit = StringLiteral (getSTRINGs $3) scc Nothing ; amsA' (sLL $1 $> (SigD noExtField (SCCFunSig ([mo $1, mc $4], (getSCC_PRAGs $1)) $2 (Just ( sL1a $3 str_lit))))) }} - | '{-# SPECIALISE' activation qvar '::' sigtypes1 '#-}' - {% amsA' ( - let inl_prag = mkInlinePragma (getSPEC_PRAGs $1) - (NoUserInlinePrag, FunLike) (snd $2) - in sLL $1 $> $ SigD noExtField $ - SpecSig (mo $1:mu AnnDcolon $4:mc $6:fst $2) - $3 (fromOL $5) - inl_prag) } - - | '{-# SPECIALISE' activation rule_foralls exp '#-}' - {% runPV (unECP $4) >>= \ $4 -> - amsA' ( + | '{-# SPECIALISE' activation rule_foralls infixexp sigtypes_maybe '#-}' + {% runPV (unECP $4) >>= \ $4 -> do let inl_prag = mkInlinePragma (getSPEC_PRAGs $1) (NoUserInlinePrag, FunLike) (snd $2) - in sLL $1 $> $ SigD noExtField $ - SpecSigE (mo $1:mc $5:fst $2) - (snd $3) $4 - inl_prag) } + spec <- mkSpecSig $1 inl_prag (fst $2) (snd $3) $4 $5 $6 + amsA' $ sLL $1 $> $ SigD noExtField spec } | '{-# SPECIALISE_INLINE' activation qvar '::' sigtypes1 '#-}' {% amsA' (sLL $1 $> $ SigD noExtField (SpecSig (mo $1:mu AnnDcolon $4:mc $6:(fst $2)) $3 (fromOL $5) @@ -2713,6 +2701,10 @@ sigdecl :: { LHsDecl GhcPs } | '{-# MINIMAL' name_boolformula_opt '#-}' {% amsA' (sLL $1 $> $ SigD noExtField (MinimalSig ([mo $1,mc $3], (getMINIMAL_PRAGs $1)) $2)) } +sigtypes_maybe :: { Maybe (Located Token, OrdList (LHsSigType GhcPs)) } + : '::' sigtypes1 { Just ($1, $2) } + | {- empty -} { Nothing } + activation :: { ([AddEpAnn],Maybe Activation) } -- See Note [%shift: activation -> {- empty -}] : {- empty -} %shift { ([],Nothing) } ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -531,6 +531,10 @@ instance Diagnostic PsMessage where , text "Use" <+> quotes (text "Sum# a b c ...") <+> text "to refer to the type constructor." ] + PsErrSpecEpxrMultipleTypeAscription + -> mkSimpleDecorated $ + text "SPECIALIZE expression doesn't support multiple specialize type ascriptions" + diagnosticReason = \case PsUnknownMessage m -> diagnosticReason m PsHeaderMessage m -> psHeaderMessageReason m @@ -646,6 +650,7 @@ instance Diagnostic PsMessage where PsErrMultipleConForNewtype {} -> ErrorWithoutFlag PsErrUnicodeCharLooksLike{} -> ErrorWithoutFlag PsErrInvalidPun {} -> ErrorWithoutFlag + PsErrSpecEpxrMultipleTypeAscription{} -> ErrorWithoutFlag diagnosticHints = \case PsUnknownMessage m -> diagnosticHints m @@ -816,6 +821,7 @@ instance Diagnostic PsMessage where PsErrMultipleConForNewtype {} -> noHints PsErrUnicodeCharLooksLike{} -> noHints PsErrInvalidPun {} -> [suggestExtension LangExt.ListTuplePuns] + PsErrSpecEpxrMultipleTypeAscription {} -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Parser/Errors/Types.hs ===================================== @@ -461,6 +461,8 @@ data PsMessage | PsErrInvalidPun !PsErrPunDetails + | PsErrSpecEpxrMultipleTypeAscription + deriving Generic -- | Extra details about a parse error, which helps ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -63,7 +63,9 @@ module GHC.Parser.PostProcess ( checkValSigLhs, LRuleTyTmVar, RuleTyTmVar(..), mkRuleBndrs, + ruleBndrsOrDef, checkRuleTyVarBndrNames, + mkSpecSig, checkRecordSyntax, checkEmptyGADTs, addFatalError, hintBangPat, @@ -993,6 +995,10 @@ type LRuleTyTmVar = LocatedAn NoEpAnns RuleTyTmVar data RuleTyTmVar = RuleTyTmVar [AddEpAnn] (LocatedN RdrName) (Maybe (LHsType GhcPs)) -- ^ Essentially a wrapper for a @RuleBndr GhcPs@ +ruleBndrsOrDef :: Maybe (RuleBndrs GhcPs) -> RuleBndrs GhcPs +ruleBndrsOrDef (Just bndrs) = bndrs +ruleBndrsOrDef Nothing = mkRuleBndrs Nothing [] + mkRuleBndrs :: Maybe [LRuleTyTmVar] -> [LRuleTyTmVar] -> RuleBndrs GhcPs mkRuleBndrs tvbs tmbs = RuleBndrs { rb_tyvs = fmap (fmap cvt_tv) tvbs @@ -1023,6 +1029,43 @@ checkRuleTyVarBndrNames bndrs PsErrParseErrorOnInput occ check _ = panic "checkRuleTyVarBndrNames" +mkSpecSig :: Located Token + -> InlinePragma + -> [AddEpAnn] + -> Maybe (RuleBndrs GhcPs) + -> LHsExpr GhcPs + -> Maybe (Located Token, OrdList (LHsSigType GhcPs)) + -> Located Token + -> P (Sig GhcPs) +mkSpecSig prag_start inl_prag activation_anns m_rule_binds expr m_sigtypes_ascr prag_end = + match_on_pragma_structure m_rule_binds expr m_sigtypes_ascr + where + match_on_pragma_structure _ _ Nothing = pure $ + SpecSigE (start_ann:end_ann:activation_anns) + (ruleBndrsOrDef m_rule_binds) expr + inl_prag + + match_on_pragma_structure Nothing (L _ (HsVar _ var)) (Just (dcolon, sigtypes)) = pure $ + SpecSig (start_ann:colon_ann:end_ann:activation_anns) + var (fromOL sigtypes) + inl_prag + where colon_ann = AddEpAnn (toUnicodeAnn AnnDcolon dcolon) (gl dcolon) + + match_on_pragma_structure _ _ _ = + ps_err PsErrSpecEpxrMultipleTypeAscription + + + gl = srcSpan2e . getLoc + start_ann = AddEpAnn AnnOpen (gl prag_start) + end_ann = AddEpAnn AnnClose (gl prag_end) + + toUnicodeAnn !a (L _ (ITdcolon UnicodeSyntax)) = unicodeAnn a + toUnicodeAnn a _ = a + + ps_err = addFatalError + . mkPlainErrorMsgEnvelope + (getLoc prag_start `combineSrcSpans` getLoc prag_end) + checkRecordSyntax :: (MonadP m, Outputable a) => LocatedA a -> m (LocatedA a) checkRecordSyntax lr@(L loc r) = do allowed <- getBit TraditionalRecordSyntaxBit ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -287,6 +287,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "PsErrMultipleConForNewtype" = 05380 GhcDiagnosticCode "PsErrUnicodeCharLooksLike" = 31623 GhcDiagnosticCode "PsErrInvalidPun" = 52943 + GhcDiagnosticCode "PsErrSpecEpxrMultipleTypeAscription" = 62037 -- Driver diagnostic codes GhcDiagnosticCode "DriverMissingHomeModules" = 32850 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2d39571f017252663e89a233247c76f89ba1629b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2d39571f017252663e89a233247c76f89ba1629b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 17:21:32 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Thu, 28 Mar 2024 13:21:32 -0400 Subject: [Git][ghc/ghc][wip/T24477] When suggesting Language extensions, also suggest Extensions which imply them Message-ID: <6605a71ccd87_25bec43d2cd0c93019@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 1f0ebef8 by Jade at 2024-03-28T17:59:59+01:00 When suggesting Language extensions, also suggest Extensions which imply them Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 - - - - - 30 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f0ebef846b83ca1e05c36a3f7cd1df09afaaef0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f0ebef846b83ca1e05c36a3f7cd1df09afaaef0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 17:33:08 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 28 Mar 2024 13:33:08 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] More wibbles Message-ID: <6605a9d487d41_25bec43f4f00895155@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 1fbbc520 by Simon Peyton Jones at 2024-03-28T17:32:55+00:00 More wibbles - - - - - 4 changed files: - testsuite/tests/arityanal/should_compile/Arity09.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T20040.stderr - testsuite/tests/simplStg/should_compile/T15226b.stderr Changes: ===================================== testsuite/tests/arityanal/should_compile/Arity09.stderr ===================================== @@ -1,16 +1,11 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 28, types: 8, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 38, types: 11, coercions: 0, joins: 0/0} -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Integer [GblId, Unf=OtherCon []] -lvl = GHC.Num.Integer.IS 100# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl1 :: Integer -[GblId, Unf=OtherCon []] -lvl1 = GHC.Num.Integer.IS 11# +lvl = GHC.Num.Integer.IS 11# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} F9.f1 :: Integer @@ -18,14 +13,19 @@ F9.f1 :: Integer F9.f1 = GHC.Num.Integer.IS 10# Rec { --- RHS size: {terms: 15, types: 2, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 6, coercions: 0, joins: 0/0} F9.f91_f [Occ=LoopBreaker] :: Integer -> Integer -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=<1L>, Unf=OtherCon []] F9.f91_f = \ (n :: Integer) -> - case GHC.Num.Integer.integerLe n lvl of { - False -> GHC.Num.Integer.integerSub n F9.f1; - True -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd n lvl1)) + case n of x1 { + GHC.Num.Integer.IS x -> + case GHC.Prim.<=# x 100# of { + __DEFAULT -> GHC.Num.Integer.integerSub x1 F9.f1; + 1# -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd x1 lvl)) + }; + GHC.Num.Integer.IP x -> GHC.Num.Integer.integerSub x1 F9.f1; + GHC.Num.Integer.IN x -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd x1 lvl)) } end Rec } ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -165,9 +165,9 @@ mapMaybeRule [InlPrag=[2]] Result s b #))) s1 of - { (# new_s [Occ=Once1], a2 [Occ=Once1!] #) -> - case a2 of { Result t2 [Occ=Once1] c1 [Occ=Once1] -> - (# new_s, + { (# ipv [Occ=Once1], ipv1 [Occ=Once1!] #) -> + case ipv1 of { Result t2 [Occ=Once1] c1 [Occ=Once1] -> + (# ipv, T18013a.Result @s @(Maybe b) t2 (GHC.Internal.Maybe.Just @b c1) #) } } @@ -207,9 +207,9 @@ mapMaybeRule Result s b #))) s1 of - { (# new_s, a2 #) -> - case a2 of { Result t2 c1 -> - (# new_s, + { (# ipv, ipv1 #) -> + case ipv1 of { Result t2 c1 -> + (# ipv, T18013a.Result @s @(Maybe b) t2 (GHC.Internal.Maybe.Just @b c1) #) } } ===================================== testsuite/tests/simplCore/should_compile/T20040.stderr ===================================== @@ -13,9 +13,10 @@ ifoldl' = \r [f z ds] case ds of wild { Nil -> z; - Cons x xs -> + Cons ipv2 ipv3 -> case z of z1 { - __DEFAULT -> case f z1 x of sat { __DEFAULT -> ifoldl' f sat xs; }; + __DEFAULT -> + case f z1 ipv2 of sat { __DEFAULT -> ifoldl' f sat ipv3; }; }; }; end Rec } ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -20,13 +20,13 @@ T15226b.testFun1 [GblId, Arity=3, Str=, Unf=OtherCon []] = {} \r [x y void] case seq# [x GHC.Prim.void#] of ds1 { - (# #) a1 [Occ=Once1] -> + (# #) ipv1 [Occ=Once1] -> let { sat [Occ=Once1] :: T15226b.StrictPair a b [LclId] = - {a1, y} \u [] + {ipv1, y} \u [] case y of conrep { - __DEFAULT -> T15226b.MkStrictPair [a1 conrep]; + __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep]; }; } in seq# [sat GHC.Prim.void#]; }; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1fbbc520911b02b6a82e9688527595dc524cf860 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1fbbc520911b02b6a82e9688527595dc524cf860 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 19:52:20 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 28 Mar 2024 15:52:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.10 Message-ID: <6605ca74c6fbc_25bec44f0e9f8114272@gitlab.mail> Ben Gamari pushed new branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Mar 28 20:12:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 28 Mar 2024 16:12:07 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: JS: `h$rts_isProfiled` is removed from `profiling` and left its version at Message-ID: <6605cf17770d1_1ff69f10985c379@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - e5054075 by Ben Gamari at 2024-03-28T16:11:55-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 78bf1813 by Alan Zimmerman at 2024-03-28T16:11:55-04:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - 2f522372 by Ben Gamari at 2024-03-28T16:11:55-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 18 changed files: - compiler/GHC/Parser.y - compiler/GHC/Runtime/Utils.hs - compiler/GHC/Tc/Gen/Foreign.hs - rts/js/profiling.js - testsuite/tests/ffi/should_fail/ccfail001.stderr - + testsuite/tests/ffi/should_run/T24598.hs - + testsuite/tests/ffi/should_run/T24598.stdout - + testsuite/tests/ffi/should_run/T24598_cmm.cmm - + testsuite/tests/ffi/should_run/T24598b.hs - + testsuite/tests/ffi/should_run/T24598b.stdout - + testsuite/tests/ffi/should_run/T24598b_cmm.cmm - + testsuite/tests/ffi/should_run/T24598c.hs - + testsuite/tests/ffi/should_run/T24598c.stdout - + testsuite/tests/ffi/should_run/T24598c_cmm.cmm - testsuite/tests/ffi/should_run/all.T - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PprLetIn.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1313,7 +1313,7 @@ ty_decl :: { LTyClDecl GhcPs } -- data/newtype family | 'data' 'family' type opt_datafam_kind_sig - {% mkFamDecl (comb3 $1 $2 $4) DataFamily TopLevel $3 + {% mkFamDecl (comb4 $1 $2 $3 $4) DataFamily TopLevel $3 (snd $ unLoc $4) Nothing (mj AnnData $1:mj AnnFamily $2:(fst $ unLoc $4)) } @@ -1438,10 +1438,10 @@ ty_fam_inst_eqns :: { Located [LTyFamInstEqn GhcPs] } h' <- addTrailingSemiA h (gl $2) return (sLL $1 $> ($3 : h' : t)) } | ty_fam_inst_eqns ';' {% case unLoc $1 of - [] -> return (sLL $1 $> (unLoc $1)) + [] -> return (sLZ $1 $> (unLoc $1)) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | ty_fam_inst_eqn { sLL $1 $> [$1] } | {- empty -} { noLoc [] } @@ -1719,12 +1719,12 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_cls { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1765,12 +1765,12 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + then return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl_inst { sL1 $1 ([],unLoc $1) } | {- empty -} { noLoc ([],nilOL) } @@ -1806,12 +1806,12 @@ decls :: { Located ([AddEpAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLL $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemiA $2) + then return (sLZ $1 $> (((fst $ unLoc $1) ++ (msemiA $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do t' <- addTrailingSemiA t (gl $2) - return (sLL $1 $> (fst $ unLoc $1 + return (sLZ $1 $> (fst $ unLoc $1 , snocOL hs t')) } | decl { sL1 $1 ([], unitOL $1) } | {- empty -} { noLoc ([],nilOL) } @@ -3334,11 +3334,11 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs return (sLL $1 $> (fst $ unLoc $1,$3 : h' : t)) } | alts1(PATS) ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (fst $ unLoc $1, h' : t)) } + return (sLZ $1 $> (fst $ unLoc $1, h' : t)) } | alt(PATS) { $1 >>= \ $1 -> return $ sL1 $1 ([],[$1]) } alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) } @@ -3442,7 +3442,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) + [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} @@ -3552,7 +3552,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed | dbinds ';' {% case unLoc $1 of (h:t) -> do h' <- addTrailingSemiA h (gl $2) - return (sLL $1 $> (h':t)) } + return (sLZ $1 $> (h':t)) } | dbind { let this = $1 in this `seq` (sL1 $1 [this]) } -- | {- empty -} { [] } @@ -4195,6 +4195,12 @@ sLLAsl :: (HasLoc a) => [a] -> Located b -> c -> Located c sLLAsl [] = sL1 sLLAsl (!x:_) = sLL x +{-# INLINE sLZ #-} +sLZ :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c +sLZ !x !y = if isZeroWidthSpan (getHasLoc y) + then sL (getHasLoc x) + else sL (comb2 x y) + {- Note [Adding location info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Runtime/Utils.hs ===================================== @@ -29,7 +29,7 @@ foreign import ccall "io.h _close" c__close :: CInt -> IO CInt foreign import ccall unsafe "io.h _get_osfhandle" - _get_osfhandle :: CInt -> IO CInt + _get_osfhandle :: CInt -> IO CIntPtr runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle) -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle) ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -84,7 +84,6 @@ import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class ( lift ) import Data.Maybe (isJust) -import GHC.Types.RepType (tyConPrimRep) import GHC.Builtin.Types (unitTyCon) -- Defines a binding @@ -737,7 +736,6 @@ marshalablePrimTyCon tc = isPrimTyCon tc && not (isLiftedTypeKind (tyConResKind marshalableTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledReason marshalableTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | otherwise = boxedMarshalableTyCon tc @@ -772,7 +770,6 @@ legalFIPrimResultTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledRe -- types and also unboxed tuple and sum result types. legalFIPrimResultTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | isUnboxedTupleTyCon tc || isUnboxedSumTyCon tc @@ -786,13 +783,3 @@ validIfUnliftedFFITypes dflags | xopt LangExt.UnliftedFFITypes dflags = IsValid | otherwise = NotValid UnliftedFFITypesNeeded -{- -Note [Marshalling void] -~~~~~~~~~~~~~~~~~~~~~~~ -We don't treat State# (whose PrimRep is VoidRep) as marshalable. -In turn that means you can't write - foreign import foo :: Int -> State# RealWorld - -Reason: the back end falls over with panic "primRepHint:VoidRep"; - and there is no compelling reason to permit it --} ===================================== rts/js/profiling.js ===================================== @@ -331,7 +331,3 @@ function h$buildCCSPtr(o) { function h$clearCCS(a) { throw new Error("ClearCCSOp not implemented"); } - -function h$rts_isProfiled() { - return 0; -} ===================================== testsuite/tests/ffi/should_fail/ccfail001.stderr ===================================== @@ -1,6 +1,8 @@ -ccfail001.hs:10:1: error: [GHC-89401] +ccfail001.hs:10:1: error: [GHC-10964] • Unacceptable result type in foreign declaration: ‘State# RealWorld’ cannot be marshalled in a foreign call + UnliftedFFITypes is required to marshal unlifted types • When checking declaration: foreign import ccall safe foo :: Int -> State# RealWorld + Suggested fix: Perhaps you intended to use UnliftedFFITypes ===================================== testsuite/tests/ffi/should_run/T24598.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in results correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello >>= print + +hello :: IO Int +hello = IO $ \s -> case hello# s of (# s', n# #) -> (# s', I# n# #) ===================================== testsuite/tests/ffi/should_run/T24598.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello() { + return (42); +} ===================================== testsuite/tests/ffi/should_run/T24598b.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: Int# -> State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello 21 >>= print + +hello :: Int -> IO Int +hello (I# n#) = IO $ \s -> + case hello# n# s of (# s', n# #) -> (# s', I# n# #) + ===================================== testsuite/tests/ffi/should_run/T24598b.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598b_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello(W_ n) { + return (2*n); +} ===================================== testsuite/tests/ffi/should_run/T24598c.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> State# RealWorld + +main :: IO () +main = hello + +hello :: IO () +hello = IO $ \s -> + case hello# s of s' -> (# s', () #) + ===================================== testsuite/tests/ffi/should_run/T24598c.stdout ===================================== @@ -0,0 +1 @@ +hello ===================================== testsuite/tests/ffi/should_run/T24598c_cmm.cmm ===================================== @@ -0,0 +1,11 @@ +#include "Cmm.h" + +section "data" { + test_str: bits8[] "hello"; +} + +hello() { + ccall puts(test_str); + return (); +} + ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -268,3 +268,7 @@ test('T24314', # libffi-wasm doesn't support more than 4 args yet when(arch('wasm32'), skip)], compile_and_run, ['T24314_c.c']) + +test('T24598', req_cmm, compile_and_run, ['T24598_cmm.cmm']) +test('T24598b', req_cmm, compile_and_run, ['T24598b_cmm.cmm']) +test('T24598c', req_cmm, compile_and_run, ['T24598c_cmm.cmm']) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -821,3 +821,8 @@ AnnotationNoListTuplePuns: Test24533: $(CHECK_PPR) $(LIBDIR) Test24533.hs $(CHECK_EXACT) $(LIBDIR) Test24533.hs + +.PHONY: PprLetIn +PprLetIn: + $(CHECK_PPR) $(LIBDIR) PprLetIn.hs + $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs ===================================== testsuite/tests/printer/PprLetIn.hs ===================================== @@ -0,0 +1,5 @@ +module PprLetIn where + +ff = let + x = 1 + in 4 ===================================== testsuite/tests/printer/all.T ===================================== @@ -197,3 +197,4 @@ test('Test23885', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23885']) test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTuplePuns.script']) test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) +test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3d686560e3d994c23e32cfe4da823b221d080520...2f522372a4d5ef887cf93d2843b8365683b2e60b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3d686560e3d994c23e32cfe4da823b221d080520...2f522372a4d5ef887cf93d2843b8365683b2e60b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 00:46:22 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Thu, 28 Mar 2024 20:46:22 -0400 Subject: [Git][ghc/ghc][wip/T24598] 8 commits: libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 Message-ID: <66060f5e7ee5e_1ff69f253e15057279e@gitlab.mail> Cheng Shao pushed to branch wip/T24598 at Glasgow Haskell Compiler / GHC Commits: 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - 44a9ae02 by Ben Gamari at 2024-03-29T00:46:05+00:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Tc/Gen/Foreign.hs - distrib/configure.ac.in - hadrian/bindist/Makefile - libffi-tarballs - m4/fp_cc_linker_flag_try.m4 - rts/js/profiling.js - − testsuite/tests/codeGen/should_run/T24507.stdout - − testsuite/tests/codeGen/should_run/T24507_cmm.cmm - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/ffi/should_fail/ccfail001.stderr - + testsuite/tests/ffi/should_run/T24598.hs - + testsuite/tests/ffi/should_run/T24598.stdout - + testsuite/tests/ffi/should_run/T24598_cmm.cmm - + testsuite/tests/ffi/should_run/T24598b.hs - + testsuite/tests/ffi/should_run/T24598b.stdout - + testsuite/tests/ffi/should_run/T24598b_cmm.cmm - testsuite/tests/codeGen/should_run/T24507.hs → testsuite/tests/ffi/should_run/T24598c.hs - + testsuite/tests/ffi/should_run/T24598c.stdout - + testsuite/tests/ffi/should_run/T24598c_cmm.cmm - testsuite/tests/ffi/should_run/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab1b69413852ca59c2f5510b52056a861e617a2d...44a9ae0224069bb3cece6621081f7dd917a1c479 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab1b69413852ca59c2f5510b52056a861e617a2d...44a9ae0224069bb3cece6621081f7dd917a1c479 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 01:02:29 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 28 Mar 2024 21:02:29 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: EPA: Fix FamDecl range Message-ID: <66061324f3fbd_1ff69f277f7c05835c8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - 9f13dff2 by Ben Gamari at 2024-03-28T21:02:21-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 2 changed files: - compiler/GHC/Parser.y - compiler/GHC/Runtime/Utils.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1313,7 +1313,7 @@ ty_decl :: { LTyClDecl GhcPs } -- data/newtype family | 'data' 'family' type opt_datafam_kind_sig - {% mkFamDecl (comb3 $1 $2 $4) DataFamily TopLevel $3 + {% mkFamDecl (comb4 $1 $2 $3 $4) DataFamily TopLevel $3 (snd $ unLoc $4) Nothing (mj AnnData $1:mj AnnFamily $2:(fst $ unLoc $4)) } ===================================== compiler/GHC/Runtime/Utils.hs ===================================== @@ -29,7 +29,7 @@ foreign import ccall "io.h _close" c__close :: CInt -> IO CInt foreign import ccall unsafe "io.h _get_osfhandle" - _get_osfhandle :: CInt -> IO CInt + _get_osfhandle :: CInt -> IO CIntPtr runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle) -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2f522372a4d5ef887cf93d2843b8365683b2e60b...9f13dff2370b50cef57590c6875c546d3217a3d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2f522372a4d5ef887cf93d2843b8365683b2e60b...9f13dff2370b50cef57590c6875c546d3217a3d9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 04:36:32 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Fri, 29 Mar 2024 00:36:32 -0400 Subject: [Git][ghc/ghc][wip/T24598] compiler: Allow more types in GHCForeignImportPrim Message-ID: <6606455021115_1ff69f3d676dc595461@gitlab.mail> Cheng Shao pushed to branch wip/T24598 at Glasgow Haskell Compiler / GHC Commits: c9a87587 by Ben Gamari at 2024-03-29T04:36:11+00:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 12 changed files: - compiler/GHC/Tc/Gen/Foreign.hs - testsuite/tests/ffi/should_fail/ccfail001.stderr - + testsuite/tests/ffi/should_run/T24598.hs - + testsuite/tests/ffi/should_run/T24598.stdout - + testsuite/tests/ffi/should_run/T24598_cmm.cmm - + testsuite/tests/ffi/should_run/T24598b.hs - + testsuite/tests/ffi/should_run/T24598b.stdout - + testsuite/tests/ffi/should_run/T24598b_cmm.cmm - + testsuite/tests/ffi/should_run/T24598c.hs - + testsuite/tests/ffi/should_run/T24598c.stdout - + testsuite/tests/ffi/should_run/T24598c_cmm.cmm - testsuite/tests/ffi/should_run/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -84,7 +84,6 @@ import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class ( lift ) import Data.Maybe (isJust) -import GHC.Types.RepType (tyConPrimRep) import GHC.Builtin.Types (unitTyCon) -- Defines a binding @@ -737,7 +736,6 @@ marshalablePrimTyCon tc = isPrimTyCon tc && not (isLiftedTypeKind (tyConResKind marshalableTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledReason marshalableTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | otherwise = boxedMarshalableTyCon tc @@ -772,7 +770,6 @@ legalFIPrimResultTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledRe -- types and also unboxed tuple and sum result types. legalFIPrimResultTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | isUnboxedTupleTyCon tc || isUnboxedSumTyCon tc @@ -786,13 +783,3 @@ validIfUnliftedFFITypes dflags | xopt LangExt.UnliftedFFITypes dflags = IsValid | otherwise = NotValid UnliftedFFITypesNeeded -{- -Note [Marshalling void] -~~~~~~~~~~~~~~~~~~~~~~~ -We don't treat State# (whose PrimRep is VoidRep) as marshalable. -In turn that means you can't write - foreign import foo :: Int -> State# RealWorld - -Reason: the back end falls over with panic "primRepHint:VoidRep"; - and there is no compelling reason to permit it --} ===================================== testsuite/tests/ffi/should_fail/ccfail001.stderr ===================================== @@ -1,6 +1,8 @@ -ccfail001.hs:10:1: error: [GHC-89401] +ccfail001.hs:10:1: error: [GHC-10964] • Unacceptable result type in foreign declaration: ‘State# RealWorld’ cannot be marshalled in a foreign call + UnliftedFFITypes is required to marshal unlifted types • When checking declaration: foreign import ccall safe foo :: Int -> State# RealWorld + Suggested fix: Perhaps you intended to use UnliftedFFITypes ===================================== testsuite/tests/ffi/should_run/T24598.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in results correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello >>= print + +hello :: IO Int +hello = IO $ \s -> case hello# s of (# s', n# #) -> (# s', I# n# #) ===================================== testsuite/tests/ffi/should_run/T24598.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello() { + return (42); +} ===================================== testsuite/tests/ffi/should_run/T24598b.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: Int# -> State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello 21 >>= print + +hello :: Int -> IO Int +hello (I# n#) = IO $ \s -> + case hello# n# s of (# s', n# #) -> (# s', I# n# #) + ===================================== testsuite/tests/ffi/should_run/T24598b.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598b_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello(W_ n) { + return (2*n); +} ===================================== testsuite/tests/ffi/should_run/T24598c.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> State# RealWorld + +main :: IO () +main = hello + +hello :: IO () +hello = IO $ \s -> + case hello# s of s' -> (# s', () #) + ===================================== testsuite/tests/ffi/should_run/T24598c.stdout ===================================== @@ -0,0 +1 @@ +hello ===================================== testsuite/tests/ffi/should_run/T24598c_cmm.cmm ===================================== @@ -0,0 +1,15 @@ +#include "Cmm.h" + +#if !defined(UnregisterisedCompiler) +import CLOSURE test_str; +#endif + +section "data" { + test_str: bits8[] "hello"; +} + +hello() { + CInt r; + (r) = ccall puts(test_str "ptr"); + return (); +} ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -268,3 +268,7 @@ test('T24314', # libffi-wasm doesn't support more than 4 args yet when(arch('wasm32'), skip)], compile_and_run, ['T24314_c.c']) + +test('T24598', req_cmm, compile_and_run, ['T24598_cmm.cmm']) +test('T24598b', req_cmm, compile_and_run, ['T24598b_cmm.cmm']) +test('T24598c', req_cmm, compile_and_run, ['T24598c_cmm.cmm']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9a875874cf9c9fab4187e8a84dbf2f09f9615fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9a875874cf9c9fab4187e8a84dbf2f09f9615fc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 05:22:55 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 29 Mar 2024 01:22:55 -0400 Subject: [Git][ghc/ghc][master] EPA: Fix FamDecl range Message-ID: <6606502f4a123_1ff69f44322b4602125@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1313,7 +1313,7 @@ ty_decl :: { LTyClDecl GhcPs } -- data/newtype family | 'data' 'family' type opt_datafam_kind_sig - {% mkFamDecl (comb3 $1 $2 $4) DataFamily TopLevel $3 + {% mkFamDecl (comb4 $1 $2 $3 $4) DataFamily TopLevel $3 (snd $ unLoc $4) Nothing (mj AnnData $1:mj AnnFamily $2:(fst $ unLoc $4)) } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd0fb82f57a16c96e720d47ec80a4f8fda58083d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd0fb82f57a16c96e720d47ec80a4f8fda58083d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 05:23:39 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 29 Mar 2024 01:23:39 -0400 Subject: [Git][ghc/ghc][master] Fix type of _get_osfhandle foreign import Message-ID: <6606505bce9e5_1ff69f45ac3886067f8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 1 changed file: - compiler/GHC/Runtime/Utils.hs Changes: ===================================== compiler/GHC/Runtime/Utils.hs ===================================== @@ -29,7 +29,7 @@ foreign import ccall "io.h _close" c__close :: CInt -> IO CInt foreign import ccall unsafe "io.h _get_osfhandle" - _get_osfhandle :: CInt -> IO CInt + _get_osfhandle :: CInt -> IO CIntPtr runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle) -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8f384a8cc7212284379d109f6dc78c6188f3f18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8f384a8cc7212284379d109f6dc78c6188f3f18 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 10:41:14 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 29 Mar 2024 06:41:14 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 19 commits: configure: Use LDFLAGS when trying linkers Message-ID: <66069aca20308_1e37c12208ad011877@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - e42c7e48 by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - ac81968c by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 94c5594b by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 75d58615 by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Spelling, layout, pretty-printing only - - - - - 8abb62e6 by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 9b1e466f by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - c50b2ac1 by Simon Peyton Jones at 2024-03-29T10:23:20+00:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - b170fb8b by Simon Peyton Jones at 2024-03-29T10:23:20+00:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - 196129b0 by Simon Peyton Jones at 2024-03-29T10:23:20+00:00 Remove a long-commented-out line Pure refactoring - - - - - 21c60ae9 by Simon Peyton Jones at 2024-03-29T10:40:31+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Singletons(normal) -9.0% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.1% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -4.2% PmSeriesV(normal) -1.9% T11195(normal) -1.1% T12227(normal) -20.5% GOOD T12545(normal) -3.2% T12707(normal) -2.2% GOOD T13253(normal) -1.3% T13253-spj(normal) +7.8% BAD T13379(normal) +0.8% T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.2% T15304(normal) +1.2% T15630(normal) -8.4% T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -34.8% GOOD T18223(normal) -17.2% GOOD T18282(normal) -5.2% GOOD T18304(normal) +10.6% BAD T18923(normal) -3.2% GOOD T1969(normal) +1.0% T19695(normal) -1.6% T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.1% T5030(normal) -15.3% GOOD T5321Fun(normal) -1.5% T6048(optasm) -17.1% GOOD T783(normal) -1.3% T8095(normal) -6.0% GOOD T9630(normal) -4.8% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.3% info_table_map_perf(normal) -1.7% parsing001(normal) +1.4% geo. mean -1.9% minimum -34.8% maximum +10.6% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is almost all good: Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T5030 T6048 T8095 T9630 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T3294 T9961 - - - - - 32c1cb18 by Simon Peyton Jones at 2024-03-29T10:41:00+00:00 Testsuite message changes from simplifier improvements - - - - - c7afc943 by Simon Peyton Jones at 2024-03-29T10:41:00+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 22 changed files: - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/FloatOut.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fbbc520911b02b6a82e9688527595dc524cf860...c7afc94316273e748b5f7a83b71c3b66a55f09ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fbbc520911b02b6a82e9688527595dc524cf860...c7afc94316273e748b5f7a83b71c3b66a55f09ec You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 11:38:25 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 29 Mar 2024 07:38:25 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 3 commits: Simplifier improvements Message-ID: <6606a83126f81_383216437bb4673dd@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 359c2ed0 by Simon Peyton Jones at 2024-03-29T11:38:13+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Singletons(normal) -9.0% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.1% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -4.2% PmSeriesV(normal) -1.9% T11195(normal) -1.1% T12227(normal) -20.5% GOOD T12545(normal) -3.2% T12707(normal) -2.2% GOOD T13253(normal) -1.3% T13253-spj(normal) +7.8% BAD T13379(normal) +0.8% T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.2% T15304(normal) +1.2% T15630(normal) -8.4% T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -34.8% GOOD T18223(normal) -17.2% GOOD T18282(normal) -5.2% GOOD T18304(normal) +10.6% BAD T18923(normal) -3.2% GOOD T1969(normal) +1.0% T19695(normal) -1.6% T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.1% T5030(normal) -15.3% GOOD T5321Fun(normal) -1.5% T6048(optasm) -17.1% GOOD T783(normal) -1.3% T8095(normal) -6.0% GOOD T9630(normal) -4.8% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.3% info_table_map_perf(normal) -1.7% parsing001(normal) +1.4% geo. mean -1.9% minimum -34.8% maximum +10.6% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is almost all good: Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T5030 T6048 T8095 T9630 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T3294 T9961 - - - - - 7ae697ea by Simon Peyton Jones at 2024-03-29T11:38:13+00:00 Testsuite message changes from simplifier improvements - - - - - 6f6f9be6 by Simon Peyton Jones at 2024-03-29T11:38:13+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 24 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Tickish.hs - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity09.stderr - testsuite/tests/arityanal/should_compile/Arity13.stderr - testsuite/tests/cpranal/should_compile/T18401.stderr - testsuite/tests/driver/inline-check.stderr - testsuite/tests/lib/integer/Makefile - testsuite/tests/numeric/should_compile/T19641.stderr - testsuite/tests/perf/compiler/T15630.hs - + testsuite/tests/perf/compiler/T15630a.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7afc94316273e748b5f7a83b71c3b66a55f09ec...6f6f9be644bb04c94f63bab130effae0dc44727a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7afc94316273e748b5f7a83b71c3b66a55f09ec...6f6f9be644bb04c94f63bab130effae0dc44727a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 12:46:45 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Fri, 29 Mar 2024 08:46:45 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-stringliteral-comma Message-ID: <6606b8353b7fc_383216bf345c712d6@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-stringliteral-comma at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-stringliteral-comma You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 13:57:30 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 29 Mar 2024 09:57:30 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/ghc-9.10 Message-ID: <6606c8ca26ed3_3832161413498759a7@gitlab.mail> Ben Gamari deleted branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 13:57:34 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 29 Mar 2024 09:57:34 -0400 Subject: [Git][ghc/ghc][ghc-9.10] 4 commits: EPA: Fix FamDecl range Message-ID: <6606c8ce1b8ee_383216136a8e876196@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: a17965fc by Alan Zimmerman at 2024-03-28T15:50:35-04:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - 89dee1d6 by Alan Zimmerman at 2024-03-28T15:50:39-04:00 EPA: do not duplicate comments in signature RHS (cherry picked from commit d2ba41e8c3e71d70a0f80dcc3f588ecbdc5ce4b2) - - - - - 7d9c2102 by Ben Gamari at 2024-03-28T15:50:56-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 16e1fca2 by Ben Gamari at 2024-03-28T15:51:22-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 15 changed files: - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Runtime/Utils.hs - compiler/GHC/Tc/Gen/Foreign.hs - testsuite/tests/ffi/should_fail/ccfail001.stderr - + testsuite/tests/ffi/should_run/T24598.hs - + testsuite/tests/ffi/should_run/T24598.stdout - + testsuite/tests/ffi/should_run/T24598_cmm.cmm - + testsuite/tests/ffi/should_run/T24598b.hs - + testsuite/tests/ffi/should_run/T24598b.stdout - + testsuite/tests/ffi/should_run/T24598b_cmm.cmm - + testsuite/tests/ffi/should_run/T24598c.hs - + testsuite/tests/ffi/should_run/T24598c.stdout - + testsuite/tests/ffi/should_run/T24598c_cmm.cmm - testsuite/tests/ffi/should_run/all.T Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -736,12 +736,12 @@ mkBigLHsPatTup = mkChunkified mkLHsPatTup -- | Convert an 'LHsType' to an 'LHsSigType'. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -hsTypeToHsSigType lty@(L loc ty) = L loc $ case ty of +hsTypeToHsSigType lty@(L loc ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an , hsf_invis_bndrs = bndrs } , hst_body = body } - -> mkHsExplicitSigType an bndrs body - _ -> mkHsImplicitSigType lty + -> L loc $ mkHsExplicitSigType an bndrs body + _ -> L (l2l loc) $ mkHsImplicitSigType lty -- The annotations are in lty, erase them from loc -- | Convert an 'LHsType' to an 'LHsSigWcType'. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs ===================================== compiler/GHC/Parser.y ===================================== @@ -1313,7 +1313,7 @@ ty_decl :: { LTyClDecl GhcPs } -- data/newtype family | 'data' 'family' type opt_datafam_kind_sig - {% mkFamDecl (comb3 $1 $2 $4) DataFamily TopLevel $3 + {% mkFamDecl (comb4 $1 $2 $3 $4) DataFamily TopLevel $3 (snd $ unLoc $4) Nothing (mj AnnData $1:mj AnnFamily $2:(fst $ unLoc $4)) } ===================================== compiler/GHC/Runtime/Utils.hs ===================================== @@ -29,7 +29,7 @@ foreign import ccall "io.h _close" c__close :: CInt -> IO CInt foreign import ccall unsafe "io.h _get_osfhandle" - _get_osfhandle :: CInt -> IO CInt + _get_osfhandle :: CInt -> IO CIntPtr runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle) -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle) ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -84,7 +84,6 @@ import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class ( lift ) import Data.Maybe (isJust) -import GHC.Types.RepType (tyConPrimRep) import GHC.Builtin.Types (unitTyCon) -- Defines a binding @@ -737,7 +736,6 @@ marshalablePrimTyCon tc = isPrimTyCon tc && not (isLiftedTypeKind (tyConResKind marshalableTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledReason marshalableTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | otherwise = boxedMarshalableTyCon tc @@ -772,7 +770,6 @@ legalFIPrimResultTyCon :: DynFlags -> TyCon -> Validity' TypeCannotBeMarshaledRe -- types and also unboxed tuple and sum result types. legalFIPrimResultTyCon dflags tc | marshalablePrimTyCon tc - , not (null (tyConPrimRep tc)) -- Note [Marshalling void] = validIfUnliftedFFITypes dflags | isUnboxedTupleTyCon tc || isUnboxedSumTyCon tc @@ -786,13 +783,3 @@ validIfUnliftedFFITypes dflags | xopt LangExt.UnliftedFFITypes dflags = IsValid | otherwise = NotValid UnliftedFFITypesNeeded -{- -Note [Marshalling void] -~~~~~~~~~~~~~~~~~~~~~~~ -We don't treat State# (whose PrimRep is VoidRep) as marshalable. -In turn that means you can't write - foreign import foo :: Int -> State# RealWorld - -Reason: the back end falls over with panic "primRepHint:VoidRep"; - and there is no compelling reason to permit it --} ===================================== testsuite/tests/ffi/should_fail/ccfail001.stderr ===================================== @@ -1,6 +1,8 @@ -ccfail001.hs:10:1: error: [GHC-89401] +ccfail001.hs:10:1: error: [GHC-10964] • Unacceptable result type in foreign declaration: ‘State# RealWorld’ cannot be marshalled in a foreign call + UnliftedFFITypes is required to marshal unlifted types • When checking declaration: foreign import ccall safe foo :: Int -> State# RealWorld + Suggested fix: Perhaps you intended to use UnliftedFFITypes ===================================== testsuite/tests/ffi/should_run/T24598.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in results correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello >>= print + +hello :: IO Int +hello = IO $ \s -> case hello# s of (# s', n# #) -> (# s', I# n# #) ===================================== testsuite/tests/ffi/should_run/T24598.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello() { + return (42); +} ===================================== testsuite/tests/ffi/should_run/T24598b.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Int +import GHC.Exts + +foreign import prim "hello" + hello# :: Int# -> State# RealWorld -> (# State# RealWorld, Int# #) + +main :: IO () +main = hello 21 >>= print + +hello :: Int -> IO Int +hello (I# n#) = IO $ \s -> + case hello# n# s of (# s', n# #) -> (# s', I# n# #) + ===================================== testsuite/tests/ffi/should_run/T24598b.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/ffi/should_run/T24598b_cmm.cmm ===================================== @@ -0,0 +1,5 @@ +#include "Cmm.h" + +hello(W_ n) { + return (2*n); +} ===================================== testsuite/tests/ffi/should_run/T24598c.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE MagicHash #-} + +-- | Test that `foreign import prim` imports handle `State#` in arguments correctly. +module Main where + +import GHC.IO +import GHC.Exts + +foreign import prim "hello" + hello# :: State# RealWorld -> State# RealWorld + +main :: IO () +main = hello + +hello :: IO () +hello = IO $ \s -> + case hello# s of s' -> (# s', () #) + ===================================== testsuite/tests/ffi/should_run/T24598c.stdout ===================================== @@ -0,0 +1 @@ +hello ===================================== testsuite/tests/ffi/should_run/T24598c_cmm.cmm ===================================== @@ -0,0 +1,11 @@ +#include "Cmm.h" + +section "data" { + test_str: bits8[] "hello"; +} + +hello() { + ccall puts(test_str); + return (); +} + ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -268,3 +268,7 @@ test('T24314', # libffi-wasm doesn't support more than 4 args yet when(arch('wasm32'), skip)], compile_and_run, ['T24314_c.c']) + +test('T24598', req_cmm, compile_and_run, ['T24598_cmm.cmm']) +test('T24598b', req_cmm, compile_and_run, ['T24598b_cmm.cmm']) +test('T24598c', req_cmm, compile_and_run, ['T24598c_cmm.cmm']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ecd5f2ff97af53c7334f2d8581651203a2c6b7d...16e1fca214c4f90d9d881e44cb82bd193231204b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ecd5f2ff97af53c7334f2d8581651203a2c6b7d...16e1fca214c4f90d9d881e44cb82bd193231204b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 14:34:35 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Fri, 29 Mar 2024 10:34:35 -0400 Subject: [Git][ghc/ghc][wip/T24477] When suggesting Language extensions, also suggest Extensions which imply them Message-ID: <6606d17bae3dc_3832161857464763a0@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: feed899b by Jade at 2024-03-29T15:39:00+01:00 When suggesting Language extensions, also suggest Extensions which imply them Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 - - - - - 30 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/feed899b36ad86cbcec73ceee9e515982e85be4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/feed899b36ad86cbcec73ceee9e515982e85be4b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 15:15:20 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Fri, 29 Mar 2024 11:15:20 -0400 Subject: [Git][ghc/ghc][wip/T24477] When suggesting Language extensions, also suggest Extensions which imply them Message-ID: <6606db08c83c_3832161d56af0791d5@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 884a73f5 by Jade at 2024-03-29T16:19:56+01:00 When suggesting Language extensions, also suggest Extensions which imply them Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 - - - - - 30 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/drvfail015.stderr - testsuite/tests/gadt/T20485.stderr - testsuite/tests/gadt/gadtSyntaxFail001.stderr - testsuite/tests/gadt/gadtSyntaxFail002.stderr - testsuite/tests/gadt/gadtSyntaxFail003.stderr - testsuite/tests/ghci/prog006/prog006.stderr - testsuite/tests/ghci/scripts/T23686.stderr - testsuite/tests/ghci/scripts/T9293.stderr - testsuite/tests/ghci/scripts/ghci057.stderr - testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail15.stderr - testsuite/tests/linear/should_fail/T18888.stderr - testsuite/tests/module/T20007.stderr - testsuite/tests/module/mod39.stderr - testsuite/tests/module/mod43.stderr - testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.stderr - testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.stderr - testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr - testsuite/tests/parser/should_fail/T16270.stderr - testsuite/tests/parser/should_fail/T16270h.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/884a73f5db28f917a23b73a01bd67ce46b942e9f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/884a73f5db28f917a23b73a01bd67ce46b942e9f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 16:02:09 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Fri, 29 Mar 2024 12:02:09 -0400 Subject: [Git][ghc/ghc][wip/T24359] Fix exact printing for RuleBndrs Message-ID: <6606e6017d5aa_383216231173879620@gitlab.mail> Alan Zimmerman pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: b984c233 by Alan Zimmerman at 2024-03-29T15:59:38+00:00 Fix exact printing for RuleBndrs This puts the exact print annotations inside a TTG extension point in RuleBndrs. It also adds an exact print case for SpecSigE - - - - - 12 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/ThToHs.hs - compiler/Language/Haskell/Syntax/Binds.hs - compiler/Language/Haskell/Syntax/Decls.hs - compiler/Language/Haskell/Syntax/Extension.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -26,6 +26,7 @@ Datatype for: @BindGroup@, @Bind@, @Sig@, @Bind at . module GHC.Hs.Binds ( module Language.Haskell.Syntax.Binds , module GHC.Hs.Binds + , HsRuleBndrsAnn(..) ) where import GHC.Prelude @@ -976,7 +977,23 @@ pprMinimalSig (L _ bf) = ppr (fmap unLoc bf) * * ********************************************************************* -} +data HsRuleBndrsAnn + = HsRuleBndrsAnn + { ra_tyanns :: Maybe (AddEpAnn, AddEpAnn) + -- ^ The locations of 'forall' and '.' for forall'd type vars + -- Using AddEpAnn to capture possible unicode variants + , ra_tmanns :: Maybe (AddEpAnn, AddEpAnn) + -- ^ The locations of 'forall' and '.' for forall'd term vars + -- Using AddEpAnn to capture possible unicode variants + } deriving (Data, Eq) + +instance NoAnn HsRuleBndrsAnn where + noAnn = HsRuleBndrsAnn Nothing Nothing + + type instance XCRuleBndr (GhcPass _) = [AddEpAnn] +type instance XCRuleBndrs (GhcPass _) = HsRuleBndrsAnn +type instance XXRuleBndrs (GhcPass _) = DataConCantHappen type instance XRuleBndrSig (GhcPass _) = [AddEpAnn] type instance XXRuleBndr (GhcPass _) = DataConCantHappen ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -62,7 +62,6 @@ module GHC.Hs.Decls ( XViaStrategyPs(..), -- ** @RULE@ declarations LRuleDecls,RuleDecls(..),RuleDecl(..),LRuleDecl,HsRuleRn(..), - HsRuleAnn(..), RuleBndr(..),LRuleBndr, collectRuleBndrSigTys, flattenRuleDecls, pprFullRuleName, @@ -1196,7 +1195,7 @@ type instance XCRuleDecls GhcTc = SourceText type instance XXRuleDecls (GhcPass _) = DataConCantHappen -type instance XHsRule GhcPs = (HsRuleAnn, SourceText) +type instance XHsRule GhcPs = ([AddEpAnn], SourceText) type instance XHsRule GhcRn = (HsRuleRn, SourceText) type instance XHsRule GhcTc = (HsRuleRn, SourceText) @@ -1205,20 +1204,6 @@ data HsRuleRn = HsRuleRn NameSet NameSet -- Free-vars from the LHS and RHS type instance XXRuleDecl (GhcPass _) = DataConCantHappen -data HsRuleAnn - = HsRuleAnn - { ra_tyanns :: Maybe (AddEpAnn, AddEpAnn) - -- ^ The locations of 'forall' and '.' for forall'd type vars - -- Using AddEpAnn to capture possible unicode variants - , ra_tmanns :: Maybe (AddEpAnn, AddEpAnn) - -- ^ The locations of 'forall' and '.' for forall'd term vars - -- Using AddEpAnn to capture possible unicode variants - , ra_rest :: [AddEpAnn] - } deriving (Data, Eq) - -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing [] - flattenRuleDecls :: [LRuleDecls (GhcPass p)] -> [LRuleDecl (GhcPass p)] flattenRuleDecls decls = concatMap (rds_rules . unLoc) decls ===================================== compiler/GHC/Parser.y ===================================== @@ -1868,10 +1868,10 @@ rule :: { LRuleDecl GhcPs } {%runPV (unECP $4) >>= \ $4 -> runPV (unECP $6) >>= \ $6 -> amsA' (sLL $1 $> $ HsRule - { rd_ext = (((fst $3) (mj AnnEqual $5 : (fst $2))), getSTRINGs $1) + { rd_ext = (mj AnnEqual $5 : (fst $2), getSTRINGs $1) , rd_name = L (noAnnSrcSpan $ gl $1) (getSTRING $1) , rd_act = snd $2 `orElse` AlwaysActive - , rd_bndrs = ruleBndrsOrDef (snd $3) + , rd_bndrs = ruleBndrsOrDef $3 , rd_lhs = $4, rd_rhs = $6 }) } -- Rules can be specified to be NeverActive, unlike inline/specialize pragmas @@ -1907,23 +1907,22 @@ rule_explicit_activation :: { ([AddEpAnn] { ($2++[mos $1,mcs $3] ,NeverActive) } -rule_foralls :: { ([AddEpAnn] -> HsRuleAnn, Maybe (RuleBndrs GhcPs)) } +rule_foralls :: { Maybe (RuleBndrs GhcPs) } : 'forall' rule_vars '.' 'forall' rule_vars '.' {% hintExplicitForall $1 >> checkRuleTyVarBndrNames $2 - >> return ( \anns -> HsRuleAnn - (Just (mu AnnForall $1,mj AnnDot $3)) - (Just (mu AnnForall $4,mj AnnDot $6)) - anns - , Just (mkRuleBndrs (Just $2) $5) ) } + >> let ann = HsRuleBndrsAnn + (Just (mu AnnForall $1,mj AnnDot $3)) + (Just (mu AnnForall $4,mj AnnDot $6)) + in return (Just (mkRuleBndrs ann (Just $2) $5)) } | 'forall' rule_vars '.' - { ( \anns -> HsRuleAnn Nothing (Just (mu AnnForall $1,mj AnnDot $3)) anns - , Just (mkRuleBndrs Nothing $2) ) } + { Just (mkRuleBndrs (HsRuleBndrsAnn Nothing (Just (mu AnnForall $1,mj AnnDot $3))) + Nothing $2) } -- See Note [%shift: rule_foralls -> {- empty -}] | {- empty -} %shift - { (\anns -> HsRuleAnn Nothing Nothing anns, Nothing) } + { Nothing } rule_vars :: { [LRuleTyTmVar] } : rule_var rule_vars { $1 : $2 } @@ -2686,7 +2685,7 @@ sigdecl :: { LHsDecl GhcPs } let inl_prag = mkInlinePragma (getSPEC_PRAGs $1) (NoUserInlinePrag, FunLike) (snd $2) - spec <- mkSpecSig $1 inl_prag (fst $2) (snd $3) $4 $5 $6 + spec <- mkSpecSig $1 inl_prag (fst $2) $3 $4 $5 $6 amsA' $ sLL $1 $> $ SigD noExtField spec } | '{-# SPECIALISE_INLINE' activation qvar '::' sigtypes1 '#-}' ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -997,11 +997,12 @@ data RuleTyTmVar = RuleTyTmVar [AddEpAnn] (LocatedN RdrName) (Maybe (LHsType Ghc ruleBndrsOrDef :: Maybe (RuleBndrs GhcPs) -> RuleBndrs GhcPs ruleBndrsOrDef (Just bndrs) = bndrs -ruleBndrsOrDef Nothing = mkRuleBndrs Nothing [] +ruleBndrsOrDef Nothing = mkRuleBndrs noAnn Nothing [] -mkRuleBndrs :: Maybe [LRuleTyTmVar] -> [LRuleTyTmVar] -> RuleBndrs GhcPs -mkRuleBndrs tvbs tmbs - = RuleBndrs { rb_tyvs = fmap (fmap cvt_tv) tvbs +mkRuleBndrs :: HsRuleBndrsAnn -> Maybe [LRuleTyTmVar] -> [LRuleTyTmVar] -> RuleBndrs GhcPs +mkRuleBndrs ann tvbs tmbs + = RuleBndrs { rb_ext = ann + , rb_tyvs = fmap (fmap cvt_tv) tvbs , rb_tmvs = fmap (fmap cvt_tm) tmbs } where -- cvt_tm turns RuleTyTmVars into RuleBnrs - this is straightforward ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -1290,7 +1290,8 @@ bindRuleBndrs doc (RuleBndrs { rb_tyvs = tyvs, rb_tmvs = tmvs }) thing_inside ; names <- newLocalBndrsRn rdr_names_w_loc ; bindRuleTyVars doc tyvs $ \ tyvs' -> bindRuleTmVars doc tyvs' tmvs names $ \ tmvs' -> - thing_inside names (RuleBndrs { rb_tyvs = tyvs', rb_tmvs = tmvs' }) } + thing_inside names (RuleBndrs { rb_ext = noAnn + , rb_tyvs = tyvs', rb_tmvs = tmvs' }) } where get_var :: RuleBndr GhcPs -> LocatedN RdrName get_var (RuleBndrSig _ v _) = v ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -1122,7 +1122,8 @@ tcRule (HsRule { rd_ext = ext mkTcRuleBndrs :: RuleBndrs GhcRn -> [Var] -> RuleBndrs GhcTc mkTcRuleBndrs (RuleBndrs { rb_tyvs = tyvs }) vars - = RuleBndrs { rb_tyvs = tyvs -- preserved for ppr-ing + = RuleBndrs { rb_ext = noAnn + , rb_tyvs = tyvs -- preserved for ppr-ing , rb_tmvs = map (noLocA . RuleBndr noAnn . noLocA) vars } generateRuleConstraints :: SkolemInfo ===================================== compiler/GHC/Tc/Zonk/Type.hs ===================================== @@ -1697,7 +1697,7 @@ zonkRule rule@(HsRule { rd_bndrs = bndrs zonkRuleBndrs :: RuleBndrs GhcTc -> (RuleBndrs GhcTc -> ZonkTcM a) -> ZonkTcM a zonkRuleBndrs (RuleBndrs { rb_tyvs = tyvs, rb_tmvs = tmvs }) thing_inside = runZonkBndrT (traverse zonk_tm_bndr tmvs) $ \ new_tmvs -> - thing_inside (RuleBndrs { rb_tyvs = tyvs, rb_tmvs = new_tmvs }) + thing_inside (RuleBndrs { rb_ext = noAnn, rb_tyvs = tyvs, rb_tmvs = new_tmvs }) where zonk_tm_bndr :: LRuleBndr GhcTc -> ZonkBndrTcM (LRuleBndr GhcTc) zonk_tm_bndr (L l (RuleBndr x (L loc v))) ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -919,7 +919,7 @@ cvtPragmaD (RuleP nm ty_bndrs tm_bndrs lhs rhs phases) HsRule { rd_ext = (noAnn, quotedSourceText nm) , rd_name = rd_name' , rd_act = act - , rd_bndrs = RuleBndrs { rb_tyvs = ty_bndrs', rb_tmvs = tm_bndrs' } + , rd_bndrs = RuleBndrs { rb_ext = noAnn, rb_tyvs = ty_bndrs', rb_tmvs = tm_bndrs' } , rd_lhs = lhs' , rd_rhs = rhs' } ; returnJustLA $ Hs.RuleD noExtField ===================================== compiler/Language/Haskell/Syntax/Binds.hs ===================================== @@ -558,12 +558,14 @@ isCompleteMatchSig _ = False ********************************************************************* -} data RuleBndrs pass = RuleBndrs - { rb_tyvs :: Maybe [LHsTyVarBndr () (NoGhcTc pass)] + { rb_ext :: (XCRuleBndrs pass) + , rb_tyvs :: Maybe [LHsTyVarBndr () (NoGhcTc pass)] -- ^ Forall'd type vars , rb_tmvs :: [LRuleBndr pass] -- ^ Forall'd term vars, before typechecking; -- after typechecking this includes all forall'd vars } + | XRuleBndrs !(XXRuleBndrs pass) -- | Located Rule Binder type LRuleBndr pass = XRec pass (RuleBndr pass) ===================================== compiler/Language/Haskell/Syntax/Decls.hs ===================================== @@ -1635,8 +1635,8 @@ data RuleDecl pass -- ^ After renamer, free-vars from the LHS and RHS , rd_name :: XRec pass RuleName -- ^ Note [Pragma source text] in "GHC.Types.SourceText" - , rd_bndrs :: RuleBndrs pass , rd_act :: Activation + , rd_bndrs :: RuleBndrs pass , rd_lhs :: XRec pass (HsExpr pass) , rd_rhs :: XRec pass (HsExpr pass) } ===================================== compiler/Language/Haskell/Syntax/Extension.hs ===================================== @@ -367,6 +367,11 @@ type family XXRuleDecls x type family XHsRule x type family XXRuleDecl x +-- ------------------------------------- +-- RuleBndsr type families +type family XCRuleBndrs x +type family XXRuleBndrs x + -- ------------------------------------- -- RuleBndr type families type family XCRuleBndr x ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -350,7 +350,7 @@ instance HasTrailing AnnSig where trailing _ = [] setTrailing a _ = a -instance HasTrailing HsRuleAnn where +instance HasTrailing HsRuleBndrsAnn where trailing _ = [] setTrailing a _ = a @@ -1179,8 +1179,8 @@ lhsCaseAnnsRest k parent = fmap (\new -> parent { hsCaseAnnsRest = new }) -- --------------------------------------------------------------------- --- data HsRuleAnn --- = HsRuleAnn +-- data HsRuleBndrsAnn +-- = HsRuleBndrsAnn -- { ra_tyanns :: Maybe (AddEpAnn, AddEpAnn) -- -- ^ The locations of 'forall' and '.' for forall'd type vars -- -- Using AddEpAnn to capture possible unicode variants @@ -1190,7 +1190,7 @@ lhsCaseAnnsRest k parent = fmap (\new -> parent { hsCaseAnnsRest = new }) -- , ra_rest :: [AddEpAnn] -- } deriving (Data, Eq) -lra_tyanns :: Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn)) +lra_tyanns :: Lens HsRuleBndrsAnn (Maybe (AddEpAnn, AddEpAnn)) lra_tyanns k parent = fmap (\new -> parent { ra_tyanns = new }) (k (ra_tyanns parent)) @@ -1209,26 +1209,22 @@ lff k parent = fmap (\new -> gg new) (k (ff parent)) -- (.) :: Lens' a b -> Lens' b c -> Lens' a c -lra_tyanns_fst :: Lens HsRuleAnn (Maybe AddEpAnn) +lra_tyanns_fst :: Lens HsRuleBndrsAnn (Maybe AddEpAnn) lra_tyanns_fst = lra_tyanns . lff . lfst -lra_tyanns_snd :: Lens HsRuleAnn (Maybe AddEpAnn) +lra_tyanns_snd :: Lens HsRuleBndrsAnn (Maybe AddEpAnn) lra_tyanns_snd = lra_tyanns . lff . lsnd -lra_tmanns :: Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn)) +lra_tmanns :: Lens HsRuleBndrsAnn (Maybe (AddEpAnn, AddEpAnn)) lra_tmanns k parent = fmap (\new -> parent { ra_tmanns = new }) (k (ra_tmanns parent)) -lra_tmanns_fst :: Lens HsRuleAnn (Maybe AddEpAnn) +lra_tmanns_fst :: Lens HsRuleBndrsAnn (Maybe AddEpAnn) lra_tmanns_fst = lra_tmanns . lff . lfst -lra_tmanns_snd :: Lens HsRuleAnn (Maybe AddEpAnn) +lra_tmanns_snd :: Lens HsRuleBndrsAnn (Maybe AddEpAnn) lra_tmanns_snd = lra_tmanns . lff . lsnd -lra_rest :: Lens HsRuleAnn [AddEpAnn] -lra_rest k parent = fmap (\new -> parent { ra_rest = new }) - (k (ra_rest parent)) - -- --------------------------------------------------------------------- -- data GrhsAnn @@ -2133,26 +2129,14 @@ instance ExactPrint (RuleDecl GhcPs) where getAnnotationEntry _ = NoEntryVal setAnnotationAnchor a _ _ _ = a - exact (HsRule (an,nsrc) (L ln n) act mtybndrs termbndrs lhs rhs) = do + exact (HsRule (an,nsrc) (L ln n) act bndrs lhs rhs) = do (L ln' _) <- markAnnotated (L ln (nsrc, n)) - an0 <- markActivation an lra_rest act - (an1, mtybndrs') <- - case mtybndrs of - Nothing -> return (an0, Nothing) - Just bndrs -> do - an1 <- markLensMAA' an0 lra_tyanns_fst -- AnnForall - bndrs' <- mapM markAnnotated bndrs - an2 <- markLensMAA' an1 lra_tyanns_snd -- AnnDot - return (an2, Just bndrs') - - an2 <- markLensMAA' an1 lra_tmanns_fst -- AnnForall - termbndrs' <- mapM markAnnotated termbndrs - an3 <- markLensMAA' an2 lra_tmanns_snd -- AnnDot - + an0 <- markActivation an lidl act + bndrs' <- markAnnotated bndrs lhs' <- markAnnotated lhs - an4 <- markEpAnnL an3 lra_rest AnnEqual + an1 <- markEpAnnL an0 lidl AnnEqual rhs' <- markAnnotated rhs - return (HsRule (an4,nsrc) (L ln' n) act mtybndrs' termbndrs' lhs' rhs') + return (HsRule (an1,nsrc) (L ln' n) act bndrs' lhs' rhs') markActivation :: (Monad m, Monoid w) => a -> Lens a [AddEpAnn] -> Activation -> EP w m a @@ -2223,6 +2207,26 @@ instance ExactPrint Role where -- --------------------------------------------------------------------- +instance ExactPrint (RuleBndrs GhcPs) where + getAnnotationEntry = const NoEntryVal + setAnnotationAnchor a _ _ _ = a + exact (RuleBndrs an0 mtybndrs termbndrs) = do + (an1, mtybndrs') <- + case mtybndrs of + Nothing -> return (an0, Nothing) + Just bndrs -> do + an1 <- markLensMAA' an0 lra_tyanns_fst -- AnnForall + bndrs' <- mapM markAnnotated bndrs + an2 <- markLensMAA' an1 lra_tyanns_snd -- AnnDot + return (an2, Just bndrs') + + an2 <- markLensMAA' an1 lra_tmanns_fst -- AnnForall + termbndrs' <- mapM markAnnotated termbndrs + an3 <- markLensMAA' an2 lra_tmanns_snd -- AnnDot + return (RuleBndrs an3 mtybndrs' termbndrs') + +-- --------------------------------------------------------------------- + instance ExactPrint (RuleBndr GhcPs) where getAnnotationEntry = const NoEntryVal setAnnotationAnchor a _ _ _ = a @@ -2760,6 +2764,15 @@ instance ExactPrint (Sig GhcPs) where an3 <- markEpAnnLMS'' an2 lidl AnnClose (Just "#-}") return (SpecSig an3 ln' typs' inl) + exact (SpecSigE an bndrs expr inl) = do + an0 <- markAnnOpen an (inl_src inl) "{-# SPECIALISE" -- Note: may be {-# SPECIALISE_INLINE + an1 <- markActivation an0 lidl (inl_act inl) + bndrs' <- markAnnotated bndrs + an2 <- markEpAnnL an1 lidl AnnDcolon + expr' <- markAnnotated expr + an3 <- markEpAnnLMS'' an2 lidl AnnClose (Just "#-}") + return (SpecSigE an3 bndrs' expr' inl) + exact (SpecInstSig (an,src) typ) = do an0 <- markAnnOpen an src "{-# SPECIALISE" an1 <- markEpAnnL an0 lidl AnnInstance View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b984c23304fb6a82255e88504302cd1ea8d1273a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b984c23304fb6a82255e88504302cd1ea8d1273a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 17:13:25 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 29 Mar 2024 13:13:25 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 3 commits: Simplifier improvements Message-ID: <6606f6b5962ac_3832162b2be3c8857f@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 1969924c by Simon Peyton Jones at 2024-03-29T17:11:41+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.1% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -4.0% PmSeriesV(normal) -1.7% T11195(normal) -1.3% T12227(normal) -20.5% GOOD T12545(normal) -3.2% T12707(normal) -2.2% GOOD T13253(normal) -1.5% T13253-spj(normal) +8.1% BAD T13386(normal) -3.0% GOOD T14766(normal) -2.7% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15703(normal) -14.8% GOOD T16577(normal) -2.3% GOOD T16875(normal) -0.1% T17516(normal) -39.7% GOOD T18140(normal) +1.1% T18223(normal) -17.2% GOOD T18282(normal) -5.1% GOOD T18304(normal) +10.8% BAD T18923(normal) -3.0% GOOD T19695(normal) -1.5% T20049(normal) -12.8% GOOD T21839c(normal) -4.3% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.9% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.8% GOOD T9961(normal) +1.8% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.4% parsing001(normal) +1.4% geo. mean -2.1% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T3294 T9961 - - - - - 3c25362c by Simon Peyton Jones at 2024-03-29T17:13:00+00:00 Testsuite message changes from simplifier improvements - - - - - 4dfbaad0 by Simon Peyton Jones at 2024-03-29T17:13:00+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 25 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Tickish.hs - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity09.stderr - testsuite/tests/arityanal/should_compile/Arity13.stderr - testsuite/tests/cpranal/should_compile/T18401.stderr - testsuite/tests/driver/inline-check.stderr - testsuite/tests/lib/integer/Makefile - testsuite/tests/numeric/should_compile/T19641.stderr - testsuite/tests/perf/compiler/T15630.hs - + testsuite/tests/perf/compiler/T15630a.hs - testsuite/tests/simplCore/should_compile/T18730_A.hs → testsuite/tests/perf/compiler/T18730_A.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f6f9be644bb04c94f63bab130effae0dc44727a...4dfbaad0d976a468815df21cabd0a62035e0c58f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f6f9be644bb04c94f63bab130effae0dc44727a...4dfbaad0d976a468815df21cabd0a62035e0c58f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 20:33:36 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 29 Mar 2024 16:33:36 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 2 commits: Testsuite message changes from simplifier improvements Message-ID: <660725a05236f_10d8cfff7864519d2@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 724bb252 by Simon Peyton Jones at 2024-03-29T20:33:15+00:00 Testsuite message changes from simplifier improvements - - - - - a2af3150 by Simon Peyton Jones at 2024-03-29T20:33:15+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 28 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity09.stderr - testsuite/tests/arityanal/should_compile/Arity13.stderr - testsuite/tests/cpranal/should_compile/T18401.stderr - testsuite/tests/driver/inline-check.stderr - testsuite/tests/lib/integer/Makefile - testsuite/tests/numeric/should_compile/T19641.stderr - testsuite/tests/perf/compiler/T15630.hs - + testsuite/tests/perf/compiler/T15630a.hs - testsuite/tests/simplCore/should_compile/T18730.hs → testsuite/tests/perf/compiler/T18730.hs - testsuite/tests/simplCore/should_compile/T18730_A.hs → testsuite/tests/perf/compiler/T18730_A.hs - + testsuite/tests/perf/compiler/T24582.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T12877.hs - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T20040.stderr - testsuite/tests/simplCore/should_compile/T20103.stderr - testsuite/tests/simplCore/should_compile/T22317.hs - testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/T23491a.stderr - testsuite/tests/simplCore/should_compile/T24229a.stderr - testsuite/tests/simplCore/should_compile/T24229b.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplCore/should_compile/spec-inline.stderr Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -983,7 +983,7 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine | mb_join@(JoinPoint {}) <- idJoinPointHood bndr = -- Analyse the RHS and /then/ the body let -- Analyse the rhs first, generating rhs_uds - !(rhs_uds_s, bndr', rhs') = occAnalNonRecRhs env ire mb_join bndr rhs + !(rhs_uds_s, bndr', rhs') = occAnalNonRecRhs env lvl ire mb_join bndr rhs rhs_uds = foldr1 orUDs rhs_uds_s -- NB: orUDs. See (W4) of -- Note [Occurrence analysis for join points] @@ -1009,7 +1009,7 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine -- => join arity O of Note [Join arity prediction based on joinRhsArity] (tagged_bndr, mb_join) = tagNonRecBinder lvl occ bndr - !(rhs_uds_s, final_bndr, rhs') = occAnalNonRecRhs env ire mb_join tagged_bndr rhs + !(rhs_uds_s, final_bndr, rhs') = occAnalNonRecRhs env lvl ire mb_join tagged_bndr rhs in WUD (foldr andUDs body_uds rhs_uds_s) -- Note `andUDs` (combine [NonRec final_bndr rhs'] body) @@ -1024,10 +1024,10 @@ occAnalNonRecBody env bndr thing_inside in WUD inner_uds (occ, res) ----------------- -occAnalNonRecRhs :: OccEnv -> ImpRuleEdges -> JoinPointHood - -> Id -> CoreExpr +occAnalNonRecRhs :: OccEnv -> TopLevelFlag -> ImpRuleEdges + -> JoinPointHood -> Id -> CoreExpr -> ([UsageDetails], Id, CoreExpr) -occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs +occAnalNonRecRhs !env lvl imp_rule_edges mb_join bndr rhs | null rules, null imp_rule_infos = -- Fast path for common case of no rules. This is only worth -- 0.1% perf on average, but it's also only a line or two of code @@ -1046,7 +1046,7 @@ occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs -- j will never be scrutinised. env1 | is_join_point = setTailCtxt env | otherwise = setNonTailCtxt rhs_ctxt env -- Zap occ_join_points - rhs_ctxt = mkNonRecRhsCtxt bndr unf + rhs_ctxt = mkNonRecRhsCtxt lvl bndr unf -- See Note [Sources of one-shot information] rhs_env = addOneShotsFromDmd bndr env1 @@ -1092,9 +1092,9 @@ occAnalNonRecRhs !env imp_rule_edges mb_join bndr rhs [ l `andUDs` adjustTailArity mb_join r | (_,l,r) <- rules_w_uds ] -mkNonRecRhsCtxt :: Id -> Unfolding -> OccEncl +mkNonRecRhsCtxt :: TopLevelFlag -> Id -> Unfolding -> OccEncl -- Precondition: Id is not a join point -mkNonRecRhsCtxt bndr unf +mkNonRecRhsCtxt lvl bndr unf | certainly_inline = OccVanilla -- See Note [Cascading inlines] | otherwise = OccRhs where @@ -1103,11 +1103,12 @@ mkNonRecRhsCtxt bndr unf -- has set the OccInfo for this binder before calling occAnalNonRecRhs case idOccInfo bndr of OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 } - -> active && not_stable + -> active && not stable_unf && not top_bottoming _ -> False active = isAlwaysActive (idInlineActivation bndr) - not_stable = not (isStableUnfolding unf) + stable_unf = isStableUnfolding unf + top_bottoming = isTopLevel lvl && isDeadEndId bndr ----------------- occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] @@ -2410,7 +2411,7 @@ float ==> This is worse than the slow cascade, so we only want to say "certainly_inline" if it really is certain. Look at the note with preInlineUnconditionally -for the various clauses. +for the various clauses. See #24582 for an example of the two getting out of sync. ************************************************************************ ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -751,7 +751,7 @@ prepareRhs env top_lvl occ rhs0 | is_expandable = anfise rhs0 | otherwise = return (emptyLetFloats, rhs0) where - -- We can' use exprIsExpandable because the WHOLE POINT is that + -- We can't use exprIsExpandable because the WHOLE POINT is that -- we want to treat (K ) as expandable, because we are just -- about "anfise" the expression. exprIsExpandable would -- just say no! ===================================== testsuite/tests/arityanal/should_compile/Arity01.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 65, types: 41, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 71, types: 43, coercions: 0, joins: 0/0} -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} F1.f2 :: Integer @@ -8,14 +8,18 @@ F1.f2 :: Integer F1.f2 = GHC.Num.Integer.IS 1# Rec { --- RHS size: {terms: 18, types: 4, coercions: 0, joins: 0/0} +-- RHS size: {terms: 24, types: 6, coercions: 0, joins: 0/0} F1.f1_h1 [Occ=LoopBreaker] :: Integer -> Integer -> Integer -> Integer -[GblId, Arity=3, Str=, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] F1.f1_h1 - = \ (n :: Integer) (x :: Integer) (eta :: Integer) -> - case GHC.Num.Integer.integerLt x n of { - False -> eta; - True -> F1.f1_h1 n (GHC.Num.Integer.integerAdd x F1.f2) (GHC.Num.Integer.integerAdd x eta) + = \ (n :: Integer) (x :: Integer) (eta [OS=OneShot] :: Integer) -> + case x of x1 { __DEFAULT -> + case n of y1 { __DEFAULT -> + case GHC.Num.Integer.integerLt# x1 y1 of { + __DEFAULT -> eta; + 1# -> F1.f1_h1 y1 (GHC.Num.Integer.integerAdd x1 F1.f2) (GHC.Num.Integer.integerAdd x1 eta) + } + } } end Rec } ===================================== testsuite/tests/arityanal/should_compile/Arity02.stderr ===================================== @@ -23,14 +23,14 @@ F2.f2_g [Occ=LoopBreaker] :: Integer -> Integer -> Integer [GblId, Arity=2, Str=<1L>, Unf=OtherCon []] F2.f2_g = \ (x :: Integer) (y :: Integer) -> - case x of wild { - GHC.Num.Integer.IS x1 -> - case GHC.Prim.># x1 0# of { + case x of x1 { + GHC.Num.Integer.IS x2 -> + case GHC.Prim.># x2 0# of { __DEFAULT -> y; - 1# -> F2.f2_g (GHC.Num.Integer.integerSub wild lvl) (GHC.Num.Integer.integerAdd wild y) + 1# -> F2.f2_g (GHC.Num.Integer.integerSub x1 lvl) (GHC.Num.Integer.integerAdd x1 y) }; - GHC.Num.Integer.IP x1 -> F2.f2_g (GHC.Num.Integer.integerSub wild lvl) (GHC.Num.Integer.integerAdd wild y); - GHC.Num.Integer.IN x1 -> y + GHC.Num.Integer.IP x2 -> F2.f2_g (GHC.Num.Integer.integerSub x1 lvl) (GHC.Num.Integer.integerAdd x1 y); + GHC.Num.Integer.IN x2 -> y } end Rec } ===================================== testsuite/tests/arityanal/should_compile/Arity09.stderr ===================================== @@ -18,14 +18,14 @@ F9.f91_f [Occ=LoopBreaker] :: Integer -> Integer [GblId, Arity=1, Str=<1L>, Unf=OtherCon []] F9.f91_f = \ (n :: Integer) -> - case n of wild { - GHC.Num.Integer.IS x1 -> - case GHC.Prim.<=# x1 100# of { - __DEFAULT -> GHC.Num.Integer.integerSub wild F9.f1; - 1# -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd wild lvl)) + case n of x1 { + GHC.Num.Integer.IS x -> + case GHC.Prim.<=# x 100# of { + __DEFAULT -> GHC.Num.Integer.integerSub x1 F9.f1; + 1# -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd x1 lvl)) }; - GHC.Num.Integer.IP x1 -> GHC.Num.Integer.integerSub wild F9.f1; - GHC.Num.Integer.IN x1 -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd wild lvl)) + GHC.Num.Integer.IP x -> GHC.Num.Integer.integerSub x1 F9.f1; + GHC.Num.Integer.IN x -> F9.f91_f (F9.f91_f (GHC.Num.Integer.integerAdd x1 lvl)) } end Rec } ===================================== testsuite/tests/arityanal/should_compile/Arity13.stderr ===================================== @@ -1,20 +1,24 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 32, types: 16, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 34, types: 19, coercions: 0, joins: 1/1} --- RHS size: {terms: 31, types: 12, coercions: 0, joins: 0/0} +-- RHS size: {terms: 33, types: 15, coercions: 0, joins: 1/1} f13 :: Int -> Int -> Int -> Int [GblId, Arity=3, - Str=, - Cpr=m1, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Str=<1!P(L)><1!P(L)><1!P(L)>, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Int) (y [Occ=Once2!] :: Int) (eta [Occ=Once1!] :: Int) -> - case eta of { GHC.Types.I# x1 [Occ=Once2] -> + case eta of { GHC.Types.I# x1 [Occ=Once1] -> case x of { GHC.Types.I# x2 -> + join { + $j [Occ=Once2!T[1]] :: GHC.Prim.Int# -> Int + [LclId[JoinId(1)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $j (y1 [Occ=Once1, OS=OneShot] :: GHC.Prim.Int#) = GHC.Types.I# (GHC.Prim.+# x1 y1) } in case GHC.Prim.># x2 0# of { - __DEFAULT -> case y of { GHC.Types.I# y1 [Occ=Once1] -> GHC.Types.I# (GHC.Prim.+# x1 y1) }; - 1# -> case y of { GHC.Types.I# y1 [Occ=Once1] -> GHC.Types.I# (GHC.Prim.+# x1 (GHC.Prim.*# x2 y1)) } + __DEFAULT -> case y of { GHC.Types.I# y1 [Occ=Once1] -> jump $j y1 }; + 1# -> case y of { GHC.Types.I# y1 [Occ=Once1] -> jump $j (GHC.Prim.*# x2 y1) } } } }}] @@ -22,9 +26,13 @@ f13 = \ (x :: Int) (y :: Int) (eta :: Int) -> case eta of { GHC.Types.I# x1 -> case x of { GHC.Types.I# x2 -> + join { + $j [Dmd=1C(1,!P(L))] :: GHC.Prim.Int# -> Int + [LclId[JoinId(1)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $j (y1 [OS=OneShot] :: GHC.Prim.Int#) = GHC.Types.I# (GHC.Prim.+# x1 y1) } in case GHC.Prim.># x2 0# of { - __DEFAULT -> case y of { GHC.Types.I# y1 -> GHC.Types.I# (GHC.Prim.+# x1 y1) }; - 1# -> case y of { GHC.Types.I# y1 -> GHC.Types.I# (GHC.Prim.+# x1 (GHC.Prim.*# x2 y1)) } + __DEFAULT -> case y of { GHC.Types.I# y1 -> jump $j y1 }; + 1# -> case y of { GHC.Types.I# y1 -> jump $j (GHC.Prim.*# x2 y1) } } } } ===================================== testsuite/tests/cpranal/should_compile/T18401.stderr ===================================== @@ -1,34 +1,37 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 52, types: 86, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 58, types: 93, coercions: 0, joins: 1/1} Rec { -- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} T18401.$w$spoly_$wgo1 :: forall a. a -> [a] -> (# [a] #) T18401.$w$spoly_$wgo1 - = \ (@a_s1cL) (sc_s1cM :: a_s1cL) (sc1_s1cN :: [a_s1cL]) -> - case sc1_s1cN of { - [] -> (# GHC.Types.[] @a_s1cL #); - : y_a1bH ys_a1bI -> (# GHC.Types.: @a_s1cL sc_s1cM (case T18401.$w$spoly_$wgo1 @a_s1cL y_a1bH ys_a1bI of { (# ww_s1cR #) -> ww_s1cR }) #) + = \ (@a_s1eu) (sc_s1ev :: a_s1eu) (sc1_s1ew :: [a_s1eu]) -> + case sc1_s1ew of { + [] -> (# GHC.Types.[] @a_s1eu #); + : y_a1dy ys_a1dz -> (# GHC.Types.: @a_s1eu sc_s1ev (case T18401.$w$spoly_$wgo1 @a_s1eu y_a1dy ys_a1dz of { (# ww_s1eA #) -> ww_s1eA }) #) } end Rec } --- RHS size: {terms: 17, types: 22, coercions: 0, joins: 0/0} +-- RHS size: {terms: 23, types: 29, coercions: 0, joins: 1/1} si :: forall a. [a] -> (Bool, [a]) si - = \ (@a_s1bR) (xs0_s1bS :: [a_s1bR]) -> - case xs0_s1bS of { - [] -> (GHC.Types.False, GHC.Types.[] @a_s1bR); - : y_a1bH ys_a1bI -> (GHC.Types.True, case T18401.$w$spoly_$wgo1 @a_s1bR y_a1bH ys_a1bI of { (# ww_s1cR #) -> ww_s1cR }) + = \ (@a_s1dI) (xs0_s1dJ :: [a_s1dI]) -> + join { + $j_s1eq :: Bool %1 -> [a_s1dI] %1 -> (Bool, [a_s1dI]) + $j_s1eq (ww_s1dX :: Bool) (ww1_s1dY :: [a_s1dI]) = (ww_s1dX, ww1_s1dY) } in + case xs0_s1dJ of { + [] -> jump $j_s1eq GHC.Types.False (GHC.Types.[] @a_s1dI); + : y_a1dy ys_a1dz -> jump $j_s1eq GHC.Types.True (case T18401.$w$spoly_$wgo1 @a_s1dI y_a1dy ys_a1dz of { (# ww_s1eA #) -> ww_s1eA }) } -- RHS size: {terms: 14, types: 19, coercions: 0, joins: 0/0} safeInit :: forall a. [a] -> Maybe [a] safeInit - = \ (@a_aQu) (xs_awN :: [a_aQu]) -> - case xs_awN of { - [] -> GHC.Maybe.Nothing @[a_aQu]; - : y_a1bH ys_a1bI -> GHC.Maybe.Just @[a_aQu] (case T18401.$w$spoly_$wgo1 @a_aQu y_a1bH ys_a1bI of { (# ww_s1cR #) -> ww_s1cR }) + = \ (@a_aQY) (xs_awU :: [a_aQY]) -> + case xs_awU of { + [] -> GHC.Internal.Maybe.Nothing @[a_aQY]; + : y_a1dy ys_a1dz -> GHC.Internal.Maybe.Just @[a_aQY] (case T18401.$w$spoly_$wgo1 @a_aQY y_a1dy ys_a1dz of { (# ww_s1eA #) -> ww_s1eA }) } ===================================== testsuite/tests/driver/inline-check.stderr ===================================== @@ -6,8 +6,9 @@ Considering inlining: foo is work-free: True guidance IF_ARGS [0] 30 0 case depth = 0 + inline depth = 0 depth based penalty = 0 - discounted size = 10 + adjusted size = 10 ANSWER = YES Inactive unfolding: foo1 Inactive unfolding: foo1 @@ -25,7 +26,8 @@ Considering inlining: foo is work-free: True guidance IF_ARGS [0] 30 0 case depth = 0 + inline depth = 0 depth based penalty = 0 - discounted size = 20 + adjusted size = 20 ANSWER = NO Inactive unfolding: foo1 ===================================== testsuite/tests/lib/integer/Makefile ===================================== @@ -17,16 +17,16 @@ integerConstantFolding: ! 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) - $(call CHECK,-991\>,minusIntegerN) + $(call CHECK,991\>,minusIntegerN) # itos negates -991 so we see just 991 $(call CHECK,\<989\>,minusIntegerP) - $(call CHECK,-200011\>,negateInteger) + $(call CHECK,200011\>,negateInteger) # Ditto negation $(call CHECK,\<200019\>,absInteger) $(call CHECK,\<50024\>,gcdInteger) $(call CHECK,\<1001100300\>,lcmInteger) $(call CHECK,\<532\>,andInteger) $(call CHECK,\<239575\>,orInteger) $(call CHECK,\<239041\>,xorInteger) - $(call CHECK,-200059\>,complementInteger) + $(call CHECK,200059\>,complementInteger) # Ditto negation $(call CHECK,\<813\>,quotRemInteger) $(call CHECK,\<60\>,quotRemInteger) $(call CHECK,\<219\>,divModInteger) ===================================== testsuite/tests/numeric/should_compile/T19641.stderr ===================================== @@ -14,8 +14,8 @@ integer_to_int = \ eta -> case eta of { IS ipv -> Just (I# ipv); - IP x2 -> Nothing; - IN ds -> Nothing + IP x -> Nothing; + IN ds2 -> Nothing } ===================================== testsuite/tests/perf/compiler/T15630.hs ===================================== @@ -1,5 +1,28 @@ module T15630 where +{- This is a fansastic test cose. + +* It scales really easily (just add or remove fields). + +* It can demonstrate massive (exponental) blow up if you get inlining + for join points wrong. + +* I found that a more monomorphic variant, T15630a, tickled a very similar + exponential -blowup, but somehow in a slighlty different way. To be specific, + at the time of writing, HEAD was fine on T15630, but blew up on T15630a. + So both tests are valuable. + +* Also worth noting: even if it doesn't blow up, it can result in two + very different programs. Below are the good and bad versions for 5 + fields. Note that the good version passes Maybes to the join points, + the ultimate values of the fields. But the bad version passes an + accumulating *function* to the join points. Lots of PAPs much less + efficient. + +See Note [Do not add unfoldings to join points at birth] in +GHc.Core.Opt.Simplify.Iteration. +-} + data IValue = IDefault | IInt Int | IBlob String @@ -54,3 +77,220 @@ getMenuItem vs = fst $ (pure TestStructure, vs) <+> (getInt ?) <+> (getInt ?) <+> (getString ?) + + +{- +------------- The good version (5 fields) ---------------- +getMenuItem + = \ (vs_az6 :: [IValue]) -> + case vs_az6 of { + [] -> case T15630.<+>1 of wild1_00 { }; + : v_az3 vs1_az4 -> + case vs1_az4 of { + [] -> case T15630.<+>1 of wild2_00 { }; + : v1_X4 vs2_X5 -> + case vs2_X5 of { + [] -> case T15630.<+>1 of wild3_00 { }; + : v2_X7 vs3_X8 -> + case vs3_X8 of { + [] -> case T15630.<+>1 of wild4_00 { }; + : v3_Xa vs4_Xb -> + case vs4_Xb of { + [] -> case T15630.<+>1 of wild5_00 { }; + : v4_Xd vs5_Xe -> + case v_az3 of { + __DEFAULT -> T15630.getMenuItem1; + IInt i_ayQ -> + join { + $j_sPO [Dmd=MC(1,L)] :: Maybe String -> Either () TestStructure + [LclId[JoinId(1)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $j_sPO (y_Xf [OS=OneShot] :: Maybe String) + = join { + $j1_sPR [Dmd=MC(1,L)] :: Maybe Int -> Either () TestStructure + [LclId[JoinId(1)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $j1_sPR (y1_Xg [OS=OneShot] :: Maybe Int) + = case v3_Xa of { + IDefault -> + case v4_Xd of { + IDefault -> + Data.Either.Right + @() + @TestStructure + (T15630.TestStructure + i_ayQ + y_Xf + y1_Xg + (Nothing @String) + (Nothing @Int)); + IInt i1_Xk -> + Data.Either.Right + @() + @TestStructure + (T15630.TestStructure + i_ayQ + y_Xf + y1_Xg + (Nothing @String) + (Just @Int i1_Xk)); + IBlob ipv_sPo -> T15630.getMenuItem1 + }; + IInt ipv_sPm -> T15630.getMenuItem1; + IBlob b_ayW -> + case v4_Xd of { + IDefault -> + Data.Either.Right + @() + @TestStructure + (T15630.TestStructure + i_ayQ + y_Xf + y1_Xg + (Just @String b_ayW) + (Nothing @Int)); + IInt i1_Xk -> + Data.Either.Right + @() + @TestStructure + (T15630.TestStructure + i_ayQ + y_Xf + y1_Xg + (Just @String b_ayW) + (Just @Int i1_Xk)); + IBlob ipv_sPo -> T15630.getMenuItem1 + } + } } in + case v2_X7 of { + IDefault -> jump $j1_sPR (Nothing @Int); + IInt i1_Xi -> jump $j1_sPR (Just @Int i1_Xi); + IBlob ipv_sPk -> T15630.getMenuItem1 + } } in + case v1_X4 of { + IDefault -> jump $j_sPO (Nothing @String); + IInt ipv_sPi -> T15630.getMenuItem1; + IBlob b_ayW -> jump $j_sPO (Just @String b_ayW) + }}}}}}} + + +------------- The bad version ---------------- +getMenuItem + = \ (vs_azD :: [IValue]) -> + case vs_azD of { + [] -> case T15630.<+>1 of wild1_00 { }; + : v_azA vs1_azB -> + case vs1_azB of { + [] -> case T15630.<+>1 of wild2_00 { }; + : v1_X5 vs2_X6 -> + case vs2_X6 of { + [] -> case T15630.<+>1 of wild3_00 { }; + : v2_X9 vs3_Xa -> + case vs3_Xa of { + [] -> case T15630.<+>1 of wild4_00 { }; + : v3_Xd vs4_Xe -> + case vs4_Xe of { + [] -> case T15630.<+>1 of wild5_00 { }; + : v4_Xh vs5_Xi -> + case v_azA of { + __DEFAULT -> T15630.getMenuItem1; + IInt i_azn -> + join { + $j_sQw [Dmd=MC(1,L)] + :: (Maybe String -> Maybe Int -> TestStructure) + -> Either () TestStructure + [LclId[JoinId(1)(Nothing)], + Arity=1, + Str=, + Unf=OtherCon []] + $j_sQw (f_aPr [OS=OneShot] + :: Maybe String -> Maybe Int -> TestStructure) + = case v3_Xd of { + IDefault -> + case v4_Xh of { + IDefault -> + Data.Either.Right + @() + @TestStructure + (f_aPr + (Nothing @String) + (Nothing @Int)); + IInt i1_Xl -> + Data.Either.Right + @() + @TestStructure + (f_aPr + (Nothing @String) + (Just @Int i1_Xl)); + IBlob ipv_sPM -> T15630.getMenuItem1 + }; + IInt ipv_sPK -> T15630.getMenuItem1; + IBlob b_azt -> + case v4_Xh of { + IDefault -> + Data.Either.Right + @() + @TestStructure + (f_aPr + (Just @String b_azt) + (Nothing @Int)); + IInt i1_Xl -> + Data.Either.Right + @() + @TestStructure + (f_aPr + (Just @String b_azt) + (Just @Int i1_Xl)); + IBlob ipv_sPM -> T15630.getMenuItem1 + } + } } in + case v1_X5 of { + IDefault -> + case v2_X9 of { + IDefault -> + jump $j_sQw + (\ (ds_dNN [OS=OneShot] :: Maybe String) + (ds1_dNO [OS=OneShot] :: Maybe Int) -> + T15630.TestStructure + i_azn + (Nothing @String) + (Nothing @Int) + ds_dNN + ds1_dNO); + IInt i1_Xk -> + jump $j_sQw + (\ (ds_dNN [OS=OneShot] :: Maybe String) + (ds1_dNO [OS=OneShot] :: Maybe Int) -> + T15630.TestStructure + i_azn + (Nothing @String) + (Just @Int i1_Xk) + ds_dNN + ds1_dNO); + IBlob ipv_sPI -> T15630.getMenuItem1 + }; + IInt ipv_sPG -> T15630.getMenuItem1; + IBlob b_azt -> + case v2_X9 of { + IDefault -> + jump $j_sQw + (\ (ds_Xl [OS=OneShot] :: Maybe String) + (ds1_Xm [OS=OneShot] :: Maybe Int) -> + T15630.TestStructure + i_azn + (Just @String b_azt) + (Nothing @Int) + ds_Xl + ds1_Xm); + IInt i1_Xk -> + jump $j_sQw + (\ (ds_Xm [OS=OneShot] :: Maybe String) + (ds1_Xn [OS=OneShot] :: Maybe Int) -> + T15630.TestStructure + i_azn + (Just @String b_azt) + (Just @Int i1_Xk) + ds_Xm + ds1_Xn); + IBlob ipv_sPI -> T15630.getMenuItem1 + }}}}}}}} + +-} ===================================== testsuite/tests/perf/compiler/T15630a.hs ===================================== @@ -0,0 +1,64 @@ +module T15630a where + +data IValue = IDefault + | IInt Int + | IBlob String + +(?) :: (IValue -> Either x a) -> IValue -> Either x (Maybe a) +-- With this NOINLINE pragma we get good behaviour, but disastrous without +-- {-# NOINLINE [0] (?) #-} +(?) _ IDefault = pure Nothing +(?) p x = Just <$> p x + +getInt :: IValue -> Either () Int +{-# NOINLINE getInt #-} +getInt (IInt i) = Right i +getInt v = Left () + +getString :: IValue -> Either () String +{-# NOINLINE getString #-} +getString (IBlob b) = Right $ b +getString v = Left () + +(<+>) :: (Either x (a -> b), [IValue]) -> (IValue -> Either x a) -> (Either x b, [IValue]) +(<+>) (f, (v:vs)) p = (f <*> (p v), vs) + +data TestStructure = TestStructure + { _param1 :: Int + , _param2 :: Maybe String + , _param3 :: Maybe Int + , _param4 :: Maybe String + , _param5 :: Maybe Int + , _param6 :: Maybe Int + + , _param7 :: Maybe String + , _param8 :: Maybe String + , _param9 :: Maybe Int + , _param10 :: Maybe Int + , _param11 :: Maybe String + , _param12 :: Maybe String + , _param13 :: Maybe Int + , _param14 :: Maybe Int + , _param15 :: Maybe String + + } + +getMenuItem :: [IValue] -> Either () TestStructure +getMenuItem vs = fst $ (pure TestStructure, vs) + <+> getInt + <+> (getString ?) + <+> (getInt ?) + <+> (getString ?) + <+> (getInt ?) + <+> (getInt ?) + + <+> (getString ?) + <+> (getString ?) + <+> (getInt ?) + <+> (getInt ?) + <+> (getString ?) + <+> (getString ?) + <+> (getInt ?) + <+> (getInt ?) + <+> (getString ?) + ===================================== testsuite/tests/simplCore/should_compile/T18730.hs → testsuite/tests/perf/compiler/T18730.hs ===================================== ===================================== testsuite/tests/simplCore/should_compile/T18730_A.hs → testsuite/tests/perf/compiler/T18730_A.hs ===================================== ===================================== testsuite/tests/perf/compiler/T24582.hs ===================================== @@ -0,0 +1,18 @@ +{-# OPTIONS_GHC -fmax-simplifier-iterations=20 #-} +-- This module made the Simplifier iterate for ever + +module T24582(woo) where + + +foo :: String -> Int -> a +{-# NOINLINE foo #-} +foo s _ = error s + +f :: (Int->Int) -> Int +{-# NOINLINE f #-} +f g = g 3 + +x :: Int -> a +x = foo "urk" + +woo = f x ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -206,6 +206,15 @@ test('CoOpt_Singletons', ######### +# Moved from simplCore/should_compile +test('T18730', + [ only_ways(['optasm']) + , collect_compiler_stats('bytes allocated',1) + , extra_files(['T18730_A.hs']) + ], + multimod_compile, + ['T18730', '-v0 -O']) + # LargeRecord is subject to Note [Sensitivity to unique increment] in T12545.hs # observed spread was 2.2% test ('LargeRecord', @@ -544,6 +553,11 @@ test('T15630', ], compile, ['-O2']) +test('T15630a', + [collect_compiler_stats() + ], + compile, + ['-O2']) # See https://gitlab.haskell.org/ghc/ghc/merge_requests/312#note_186960 test ('WWRec', @@ -716,3 +730,8 @@ test ('LookupFusion', test('T24471', [req_th, collect_compiler_stats('all', 5)], multimod_compile, ['T24471', '-v0 -O']) + +test ('T24582', + [ collect_compiler_stats('bytes allocated',5) ], + compile, + ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T12877.hs ===================================== @@ -21,7 +21,7 @@ test x = case x of t -> case t + 1 of 3 -> "0" 4 -> "1" - t -> case t + 1 of + t -> "n" {- case t + 1 of 4 -> "0" 5 -> "1" t -> case t + 1 of @@ -112,3 +112,4 @@ test x = case x of 34 -> "0" 35 -> "1" _ -> "n" +-} ===================================== testsuite/tests/simplCore/should_compile/T15631.stdout ===================================== @@ -1,8 +1,6 @@ - case GHC.Internal.List.$wlenAcc @a (Foo.f2 @a) 0# of v case reverse @a xs of ys { __DEFAULT -> case GHC.Internal.List.$wlenAcc @a xs 0# of ww1 { __DEFAULT -> + = case GHC.Internal.List.$wlenAcc case ys of { - [] -> case Foo.f1 @a of { GHC.Types.I# v1 -> GHC.Prim.+# ww1 v1 }; - case GHC.Internal.List.$wlenAcc case Foo.$wf @a xs of ww [Occ=Once1] { __DEFAULT -> case Foo.$wf @a xs of ww { __DEFAULT -> GHC.Types.I# ww } ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -17,6 +17,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -25,6 +27,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) @@ -38,6 +42,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op first (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op >>= (BUILTIN) @@ -48,6 +54,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @(_, ()) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -56,12 +64,16 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op . (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @(_, ()) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -70,6 +82,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op id (BUILTIN) @@ -83,6 +97,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op ||| (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) @@ -90,6 +106,8 @@ Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @(_, ()) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -98,6 +116,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -108,30 +128,10 @@ Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: mkRule @((), _) (T18013a) Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @(_, ()) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @(_, ()) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @(_, ()) (T18013a) -Rule fired: Class op fmap (BUILTIN) ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 52, types: 95, coercions: 17, joins: 0/1} + = {terms: 38, types: 90, coercions: 17, joins: 0/1} -- RHS size: {terms: 37, types: 78, coercions: 17, joins: 0/1} mapMaybeRule [InlPrag=[2]] @@ -221,46 +221,5 @@ mapMaybeRule ~R# (s -> Maybe a -> IO (Result s (Maybe b)))) } --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -T18013.$trModule4 :: GHC.Prim.Addr# -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 20 0}] -T18013.$trModule4 = "main"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T18013.$trModule3 :: GHC.Types.TrName -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T18013.$trModule3 = GHC.Types.TrNameS T18013.$trModule4 - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -T18013.$trModule2 :: GHC.Prim.Addr# -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 30 0}] -T18013.$trModule2 = "T18013"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T18013.$trModule1 :: GHC.Types.TrName -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T18013.$trModule1 = GHC.Types.TrNameS T18013.$trModule2 - --- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -T18013.$trModule :: GHC.Types.Module -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T18013.$trModule - = GHC.Types.Module T18013.$trModule3 T18013.$trModule1 - ===================================== testsuite/tests/simplCore/should_compile/T20040.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Final STG: ==================== -$WNil = CCS_DONT_CARE Nil! []; +$WNil = Nil! []; -$WCons = \r [conrep conrep] Cons [conrep conrep]; +$WCons = \r [conrep conrep1] Cons [conrep conrep1]; unSucc1 = \r [ds] ds; @@ -11,7 +11,7 @@ unSucc = \r [eta] unSucc1 eta; Rec { ifoldl' = \r [f z ds] - case ds of { + case ds of wild { Nil -> z; Cons ipv2 ipv3 -> case z of z1 { @@ -25,7 +25,7 @@ Nil = \r [void] Nil []; Cons = \r [void eta eta] Cons [eta eta]; -Z = CCS_DONT_CARE Z! []; +Z = Z! []; S = \r [eta] S [eta]; ===================================== testsuite/tests/simplCore/should_compile/T20103.stderr ===================================== @@ -6,7 +6,7 @@ T20103.hs:7:24: warning: [GHC-63394] [-Wx-partial (in -Wextended-warnings)] ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 139, types: 89, coercions: 22, joins: 0/0} + = {terms: 136, types: 88, coercions: 25, joins: 0/0} -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int @@ -117,7 +117,7 @@ lvl16 :: CallStack ~R# (?callStack::CallStack))) Rec { --- RHS size: {terms: 47, types: 42, coercions: 18, joins: 0/0} +-- RHS size: {terms: 44, types: 41, coercions: 21, joins: 0/0} T20103.$wfoo [InlPrag=[2], Occ=LoopBreaker] :: HasCallStack => GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], Arity=2, Str=<1L><1L>, Unf=OtherCon []] @@ -150,8 +150,11 @@ T20103.$wfoo { __DEFAULT -> case getCallStack wild1 of { [] -> - case wild1 of wild2 { - __DEFAULT -> case lvl16 wild2 of {}; + case $dIP + `cast` (GHC.Classes.N:IP[0] <"callStack">_N _N + :: (?callStack::CallStack) ~R# CallStack) + of wild1 { + __DEFAULT -> case lvl16 wild1 of {}; GHC.Stack.Types.FreezeCallStack ds1 -> case GHC.List.head1 @([Char], SrcLoc) ===================================== testsuite/tests/simplCore/should_compile/T22317.hs ===================================== @@ -6,9 +6,9 @@ data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) m :: Maybe a -> Maybe a -> Maybe a +-- Don't make this INLINE; if you do, ,it's not unreasonable to inline it m (Just v1) Nothing = Just v1 m _ mb = mb -{-# INLINE m #-} f :: T -> T -> T f (T a1 b1 c1 d1) (T a2 b2 c2 d2) ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -18,7 +18,7 @@ f :: Integer -> Integer -> Integer Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [0 0] 156 0}] + Guidance=IF_ARGS [0 0] 140 0}] f = \ (x :: Integer) (y :: Integer) -> joinrec { go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] ===================================== testsuite/tests/simplCore/should_compile/T23491a.stderr ===================================== @@ -1,4 +1,136 @@ -==================== Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False}) ==================== -Result size of Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False}) -==================== Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = True}) ==================== -Result size of Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = True}) +[1 of 2] Compiling Main ( T23491.hs, T23491.o ) + +==================== Float out(FOS {Lam = Just 0, + Consts = True, + JoinsToTop = False, + OverSatApps = False}) ==================== +Result size of Float out(FOS {Lam = Just 0, + Consts = True, + JoinsToTop = False, + OverSatApps = False}) + = {terms: 25, types: 13, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl_sBH :: GHC.Prim.Addr# +[LclId] +lvl_sBH = "Hello world"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl_sBI :: [Char] +[LclId] +lvl_sBI = GHC.CString.unpackCString# lvl_sBH + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +main :: IO () +[LclIdX, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 80 0}] +main = putStrLn lvl_sBI + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +:Main.main :: IO () +[LclIdX, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 20 0}] +:Main.main = GHC.TopHandler.runMainIO @() main + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl_sBJ :: GHC.Prim.Addr# +[LclId] +lvl_sBJ = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl_sBK :: GHC.Types.TrName +[LclId] +lvl_sBK = GHC.Types.TrNameS lvl_sBJ + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl_sBL :: GHC.Prim.Addr# +[LclId] +lvl_sBL = "Main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl_sBM :: GHC.Types.TrName +[LclId] +lvl_sBM = GHC.Types.TrNameS lvl_sBL + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +Main.$trModule :: GHC.Types.Module +[LclIdX, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 70 10}] +Main.$trModule = GHC.Types.Module lvl_sBK lvl_sBM + + + + +==================== Float out(FOS {Lam = Just 0, + Consts = True, + JoinsToTop = True, + OverSatApps = True}) ==================== +Result size of Float out(FOS {Lam = Just 0, + Consts = True, + JoinsToTop = True, + OverSatApps = True}) + = {terms: 25, types: 13, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl_sBH :: GHC.Prim.Addr# +[LclId] +lvl_sBH = "Hello world"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl_sBI :: [Char] +[LclId] +lvl_sBI = GHC.CString.unpackCString# lvl_sBH + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +main :: IO () +[LclIdX, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 80 0}] +main = putStrLn lvl_sBI + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +:Main.main :: IO () +[LclIdX, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 20 0}] +:Main.main = GHC.TopHandler.runMainIO @() main + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl_sBJ :: GHC.Prim.Addr# +[LclId] +lvl_sBJ = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl_sBK :: GHC.Types.TrName +[LclId] +lvl_sBK = GHC.Types.TrNameS lvl_sBJ + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl_sBL :: GHC.Prim.Addr# +[LclId] +lvl_sBL = "Main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl_sBM :: GHC.Types.TrName +[LclId] +lvl_sBM = GHC.Types.TrNameS lvl_sBL + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +Main.$trModule :: GHC.Types.Module +[LclIdX, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 70 10}] +Main.$trModule = GHC.Types.Module lvl_sBK lvl_sBM + + + +[2 of 2] Linking T23491 ===================================== testsuite/tests/simplCore/should_compile/T24229a.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 79, types: 106, coercions: 8, joins: 0/0} +Result size of Tidy Core = {terms: 83, types: 113, coercions: 8, joins: 1/1} Rec { foo_$s$wfoo @@ -14,9 +14,10 @@ end Rec } foo = \ @a ds ds1 -> case ds of { I# ww -> + join { $j ww1 = Just ww1 } in case ww of ds2 { - __DEFAULT -> case ds1 `cast` :: ... of { (x, y) -> case foo_$s$wfoo y x (-# ds2 1#) of { (# ww1 #) -> Just ww1 } }; - 0# -> Just (ds1 `cast` :: ...) + __DEFAULT -> case ds1 `cast` :: ... of { (x, y) -> case foo_$s$wfoo y x (-# ds2 1#) of { (# ww1 #) -> jump $j ww1 } }; + 0# -> jump $j (ds1 `cast` :: ...) } } ===================================== testsuite/tests/simplCore/should_compile/T24229b.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 60, types: 83, coercions: 8, joins: 0/0} +Result size of Tidy Core = {terms: 64, types: 90, coercions: 8, joins: 1/1} Rec { foo_$s$wfoo @@ -14,9 +14,10 @@ end Rec } foo = \ @a ds ds1 -> case ds of { I# ww -> + join { $j ww1 = Just ww1 } in case ww of ds2 { - __DEFAULT -> case ds1 `cast` :: ... of { (x, y) -> case foo_$s$wfoo y x (-# ds2 1#) of { (# ww1 #) -> Just ww1 } }; - 0# -> Just (ds1 `cast` :: ...) + __DEFAULT -> case ds1 `cast` :: ... of { (x, y) -> case foo_$s$wfoo y x (-# ds2 1#) of { (# ww1 #) -> jump $j ww1 } }; + 0# -> jump $j (ds1 `cast` :: ...) } } ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -53,7 +53,7 @@ test('T3717', only_ways(['optasm']), test('spec-inline', only_ways(['optasm']), compile, - ['-O2 -ddump-simpl -dsuppress-uniques -dsuppress-ticks']) + ['-O2 -ddump-simpl -dsuppress-uniques -dsuppress-ticks -dno-typeable-binds']) test('T4908', only_ways(['optasm']), compile, ['-O2 -ddump-simpl -dsuppress-uniques -dsuppress-ticks']) @@ -320,7 +320,7 @@ test('T17930', [ grep_errmsg(r'^\$sfoo') ], compile, ['-O -ddump-spec -dsuppress test('spec004', [ grep_errmsg(r'\$sfoo') ], compile, ['-O -ddump-spec -dsuppress-uniques']) # NB: T17810: -fspecialise-aggressively test('T17810', normal, multimod_compile, ['T17810', '-fspecialise-aggressively -dcore-lint -O -v0']) -test('T18013', normal, multimod_compile, ['T18013', '-v0 -O']) +test('T18013', normal, multimod_compile, ['T18013', '-v0 -O -dno-typeable-binds']) test('T18098', normal, compile, ['-dcore-lint -O2']) test('T18120', normal, compile, ['-dcore-lint -O']) @@ -342,7 +342,6 @@ test('T18603', normal, compile, ['-dcore-lint -O']) # T18649 should /not/ generate a specialisation rule test('T18649', normal, compile, ['-O -ddump-rules -Wno-simplifiable-class-constraints']) -test('T18730', normal, multimod_compile, ['T18730_A', '-dcore-lint -O']) test('T18747A', normal, compile, ['']) test('T18747B', normal, compile, ['']) test('T18815', only_ways(['optasm']), makefile_test, ['T18815']) ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -1,48 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 150, types: 60, coercions: 0, joins: 0/0} - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -Roman.$trModule4 :: GHC.Prim.Addr# -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 20 0}] -Roman.$trModule4 = "main"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -Roman.$trModule3 :: GHC.Types.TrName -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -Roman.$trModule3 = GHC.Types.TrNameS Roman.$trModule4 - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -Roman.$trModule2 :: GHC.Prim.Addr# -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 30 0}] -Roman.$trModule2 = "Roman"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -Roman.$trModule1 :: GHC.Types.TrName -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -Roman.$trModule1 = GHC.Types.TrNameS Roman.$trModule2 - --- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -Roman.$trModule :: GHC.Types.Module -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -Roman.$trModule - = GHC.Types.Module Roman.$trModule3 Roman.$trModule1 + = {terms: 136, types: 55, coercions: 0, joins: 0/0} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} lvl :: GHC.Prim.Addr# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4dfbaad0d976a468815df21cabd0a62035e0c58f...a2af315023efb666745717a856aa07a66865fbe3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4dfbaad0d976a468815df21cabd0a62035e0c58f...a2af315023efb666745717a856aa07a66865fbe3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 21:02:57 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 29 Mar 2024 17:02:57 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.10.1-alpha2 Message-ID: <66072c819a747_10d8cf13cc430588ce@gitlab.mail> Ben Gamari pushed new tag ghc-9.10.1-alpha2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.10.1-alpha2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 21:09:02 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 29 Mar 2024 17:09:02 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.10 Message-ID: <66072deebf0d2_10d8cf15371e459925@gitlab.mail> Ben Gamari pushed new branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 21:54:37 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 29 Mar 2024 17:54:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24604 Message-ID: <6607389db8b6a_10d8cf1b8585c702a2@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24604 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24604 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 23:00:52 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 29 Mar 2024 19:00:52 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 14 commits: Fix type of _get_osfhandle foreign import Message-ID: <66074824b2b5f_10d8cf23eee587532e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - e42c7e48 by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - ac81968c by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 94c5594b by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 75d58615 by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Spelling, layout, pretty-printing only - - - - - 8abb62e6 by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 9b1e466f by Simon Peyton Jones at 2024-03-29T10:23:19+00:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - c50b2ac1 by Simon Peyton Jones at 2024-03-29T10:23:20+00:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - b170fb8b by Simon Peyton Jones at 2024-03-29T10:23:20+00:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - 196129b0 by Simon Peyton Jones at 2024-03-29T10:23:20+00:00 Remove a long-commented-out line Pure refactoring - - - - - 1969924c by Simon Peyton Jones at 2024-03-29T17:11:41+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.1% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -4.0% PmSeriesV(normal) -1.7% T11195(normal) -1.3% T12227(normal) -20.5% GOOD T12545(normal) -3.2% T12707(normal) -2.2% GOOD T13253(normal) -1.5% T13253-spj(normal) +8.1% BAD T13386(normal) -3.0% GOOD T14766(normal) -2.7% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15703(normal) -14.8% GOOD T16577(normal) -2.3% GOOD T16875(normal) -0.1% T17516(normal) -39.7% GOOD T18140(normal) +1.1% T18223(normal) -17.2% GOOD T18282(normal) -5.1% GOOD T18304(normal) +10.8% BAD T18923(normal) -3.0% GOOD T19695(normal) -1.5% T20049(normal) -12.8% GOOD T21839c(normal) -4.3% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.9% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.8% GOOD T9961(normal) +1.8% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.4% parsing001(normal) +1.4% geo. mean -2.1% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T3294 T9961 - - - - - 724bb252 by Simon Peyton Jones at 2024-03-29T20:33:15+00:00 Testsuite message changes from simplifier improvements - - - - - a2af3150 by Simon Peyton Jones at 2024-03-29T20:33:15+00:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 8d7efac7 by Alan Zimmerman at 2024-03-29T19:00:47-04:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - 14 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/FloatOut.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9f13dff2370b50cef57590c6875c546d3217a3d9...8d7efac77367ee5a3bbe965307c34c05cf73a822 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9f13dff2370b50cef57590c6875c546d3217a3d9...8d7efac77367ee5a3bbe965307c34c05cf73a822 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Mar 29 23:19:01 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Fri, 29 Mar 2024 19:19:01 -0400 Subject: [Git][ghc/ghc][wip/three-way-merge-sort] 183 commits: Add @since annotation to Data.Data.mkConstrTag Message-ID: <66074c65b4723_10d8cf277ca708092f@gitlab.mail> Jade pushed to branch wip/three-way-merge-sort at Glasgow Haskell Compiler / GHC Commits: 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - 4ce5aa2c by Jade at 2024-03-29T23:08:09+01:00 Add four way merge to Data.List.sort(By) This patch aims to implement an improved version of Data.List.sortBy and therefore Data.List.sort which increases performance by up to 20% on larger lists, but also ~10% on lists of size 100 and smaller. This approach implements a four-way merge which also reuses comparisons. Fixes #24280 ------------------------- Metric Decrease: MultiLayerModulesTH_Make T10421 T13719 T15164 T18698a T18698b T1969 T9872a T9961 WWRec ------------------------- - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs-boot - 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/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - − compiler/GHC/Cmm/Dataflow/Collections.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c124815cca77a12f4e2e6fc4e8a390909b9fa7ba...4ce5aa2cecbfac659e0647b8aea27659e0a3b177 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c124815cca77a12f4e2e6fc4e8a390909b9fa7ba...4ce5aa2cecbfac659e0647b8aea27659e0a3b177 You're receiving 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 Mar 30 00:43:21 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 29 Mar 2024 20:43:21 -0400 Subject: [Git][ghc/ghc][wip/bump-parsec] Bump parsec submodule to 3.1.17.0 Message-ID: <6607602947a04_10d8cf3731dd094714@gitlab.mail> Ben Gamari pushed to branch wip/bump-parsec at Glasgow Haskell Compiler / GHC Commits: afd51cf0 by Ben Gamari at 2024-03-29T20:43:00-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 1 changed file: - libraries/parsec Changes: ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit 4a44a8cdaa8c3eaa97a73a6da05940dd3bf7c93b +Subproject commit 0736c51d0b39a9852cd39259af4cfaf6cafe36a3 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afd51cf0263ea75f263f3344aa37a03389562955 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afd51cf0263ea75f263f3344aa37a03389562955 You're receiving 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 Mar 30 05:41:40 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 30 Mar 2024 01:41:40 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] EPA: Extend StringLiteral range to include trailing commas Message-ID: <6607a613f20f3_2540e31f533d010101b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4a04085f by Alan Zimmerman at 2024-03-30T01:41:31-04:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - 2 changed files: - compiler/GHC/Parser.y - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4559,7 +4559,8 @@ addTrailingCommaN (L anns a) span = do return (L anns' a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral -addTrailingCommaS (L l sl) span = L l (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) +addTrailingCommaS (L l sl) span + = L (widenSpan l [AddEpAnn AnnComma span]) (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) -- ------------------------------------- ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -652,6 +652,10 @@ printSourceText :: (Monad m, Monoid w) => SourceText -> String -> EP w m () printSourceText (NoSourceText) txt = printStringAdvance txt >> return () printSourceText (SourceText txt) _ = printStringAdvance (unpackFS txt) >> return () +printSourceTextAA :: (Monad m, Monoid w) => SourceText -> String -> EP w m () +printSourceTextAA (NoSourceText) txt = printStringAtAA (EpaDelta (SameLine 0) []) txt >> return () +printSourceTextAA (SourceText txt) _ = printStringAtAA (EpaDelta (SameLine 0) []) (unpackFS txt) >> return () + -- --------------------------------------------------------------------- printStringAtSs :: (Monad m, Monoid w) => SrcSpan -> String -> EP w m () @@ -2099,7 +2103,7 @@ instance ExactPrint StringLiteral where setAnnotationAnchor a _ _ _ = a exact l@(StringLiteral src fs mcomma) = do - printSourceText src (show (unpackFS fs)) + printSourceTextAA src (show (unpackFS fs)) mapM_ (\r -> printStringAtRs r ",") mcomma return l View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4a04085f5b06dce8e8e2236e3544b9e8ce68060e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4a04085f5b06dce8e8e2236e3544b9e8ce68060e You're receiving 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 Mar 30 09:01:57 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 30 Mar 2024 05:01:57 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] EPA: Extend StringLiteral range to include trailing commas Message-ID: <6607d505d4299_2540e33c8613c11493@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c24dd1f3 by Alan Zimmerman at 2024-03-30T05:01:50-04:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - 2 changed files: - compiler/GHC/Parser.y - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4559,7 +4559,8 @@ addTrailingCommaN (L anns a) span = do return (L anns' a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral -addTrailingCommaS (L l sl) span = L l (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) +addTrailingCommaS (L l sl) span + = L (widenSpan l [AddEpAnn AnnComma span]) (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) -- ------------------------------------- ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -652,6 +652,10 @@ printSourceText :: (Monad m, Monoid w) => SourceText -> String -> EP w m () printSourceText (NoSourceText) txt = printStringAdvance txt >> return () printSourceText (SourceText txt) _ = printStringAdvance (unpackFS txt) >> return () +printSourceTextAA :: (Monad m, Monoid w) => SourceText -> String -> EP w m () +printSourceTextAA (NoSourceText) txt = printStringAtAA (EpaDelta (SameLine 0) []) txt >> return () +printSourceTextAA (SourceText txt) _ = printStringAtAA (EpaDelta (SameLine 0) []) (unpackFS txt) >> return () + -- --------------------------------------------------------------------- printStringAtSs :: (Monad m, Monoid w) => SrcSpan -> String -> EP w m () @@ -2099,7 +2103,7 @@ instance ExactPrint StringLiteral where setAnnotationAnchor a _ _ _ = a exact l@(StringLiteral src fs mcomma) = do - printSourceText src (show (unpackFS fs)) + printSourceTextAA src (show (unpackFS fs)) mapM_ (\r -> printStringAtRs r ",") mcomma return l View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c24dd1f3fafb27a37c6bef01796141d5228c204c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c24dd1f3fafb27a37c6bef01796141d5228c204c You're receiving 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 Mar 30 09:58:26 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Sat, 30 Mar 2024 05:58:26 -0400 Subject: [Git][ghc/ghc][wip/three-way-merge-sort] Add four way merge to Data.List.sort(By) Message-ID: <6607e24245643_1f208d3994c895464@gitlab.mail> Jade pushed to branch wip/three-way-merge-sort at Glasgow Haskell Compiler / GHC Commits: 2e435951 by Jade at 2024-03-30T11:02:58+01:00 Add four way merge to Data.List.sort(By) This patch aims to implement an improved version of Data.List.sortBy and therefore Data.List.sort which increases performance by up to 20% on larger lists, but also ~10% on lists of size 100 and smaller. This approach implements a four-way merge which also reuses comparisons. Fixes #24280 ------------------------- Metric Decrease: MultiLayerModulesTH_Make T10421 T13719 T15164 T18698a T18698b T1969 T9872a T9961 WWRec ------------------------- - - - - - 4 changed files: - libraries/ghc-internal/src/GHC/Internal/Data/OldList.hs - + testsuite/tests/lib/base/Sort.hs - + testsuite/tests/lib/base/Sort.stdout - testsuite/tests/lib/base/all.T Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/Data/OldList.hs ===================================== @@ -1640,37 +1640,99 @@ and possibly to bear similarities to a 1982 paper by Richard O'Keefe: Benchmarks show it to be often 2x the speed of the previous implementation. Fixes ticket https://gitlab.haskell.org/ghc/ghc/issues/2143 + +Further improved using a four-way merge, with an additional performance increase of ~20% +https://gitlab.haskell.org/ghc/ghc/issues/24280 -} -sort = sortBy compare -sortBy cmp = mergeAll . sequences +{-# INLINEABLE sort #-} +sort = actualSort (>) + +{-# INLINEABLE sortBy #-} +sortBy cmp = actualSort (\x y -> cmp x y == GT) + +{-# INLINE actualSort #-} +actualSort :: (a -> a -> Bool) -> [a] -> [a] +actualSort gt ns + | [] <- ns = [] + | [a] <- ns = [a] + | [a,b] <- ns = merge [a] [b] + | [a,b,c] <- ns = merge3 [a] [b] [c] + | [a,b,c,d] <- ns = merge4 [a] [b] [c] [d] + | otherwise = merge_all (sequences ns) where sequences (a:b:xs) - | a `cmp` b == GT = descending b [a] xs - | otherwise = ascending b (a:) xs + | a `gt` b = descending b [a] xs + | otherwise = ascending b (a:) xs sequences xs = [xs] descending a as (b:bs) - | a `cmp` b == GT = descending b (a:as) bs - descending a as bs = (a:as): sequences bs + | a `gt` b = descending b (a:as) bs + descending a as bs = (a:as) : sequences bs ascending a as (b:bs) - | a `cmp` b /= GT = ascending b (\ys -> as (a:ys)) bs - ascending a as bs = let !x = as [a] - in x : sequences bs - - mergeAll [x] = x - mergeAll xs = mergeAll (mergePairs xs) - - mergePairs (a:b:xs) = let !x = merge a b - in x : mergePairs xs - mergePairs xs = xs + | not (a `gt` b) = ascending b (\ys -> as (a:ys)) bs + ascending a as bs = let !x = as [a] + in x : sequences bs + + merge_all [x] = x + merge_all xs = merge_all (reduce_once xs) + + reduce_once [] = [] + reduce_once [a] = [a] + reduce_once [a,b] = [merge a b] + reduce_once [a,b,c] = [merge3 a b c] + reduce_once [a,b,c,d,e] = [merge a b, merge3 c d e] + reduce_once [a,b,c,d,e,f] = [merge3 a b c, merge3 d e f] + reduce_once (a:b:c:d:xs) = let !x = merge4 a b c d + in x : reduce_once xs merge as@(a:as') bs@(b:bs') - | a `cmp` b == GT = b:merge as bs' - | otherwise = a:merge as' bs - merge [] bs = bs - merge as [] = as + | a `gt` b = b : merge as bs' + | otherwise = a : merge as' bs + merge [] bs = bs + merge as [] = as + + -- `merge3` is a manually fused version of `merge (merge as bs) cs` + merge3 as@(a:as') bs@(b:bs') cs + | a `gt` b = merge3X b as bs' cs + | otherwise = merge3X a as' bs cs + merge3 [] bs cs = merge bs cs + merge3 as [] cs = merge as cs + + merge3X x as bs cs@(c:cs') + | x `gt` c = c : merge3X x as bs cs' + | otherwise = x : merge3 as bs cs + merge3X x as bs [] = x : merge as bs + + merge3Y as@(a:as') y bs cs + | a `gt` y = y : merge3 as bs cs + | otherwise = a : merge3Y as' y bs cs + merge3Y [] x bs cs = x : merge bs cs + + -- `merge4 as bs cs ds` is (essentially) a manually fused version of + -- `merge (merge as bs) (merge cs ds)` + merge4 as@(a:as') bs@(b:bs') cs ds + | a `gt` b = merge4X b as bs' cs ds + | otherwise = merge4X a as' bs cs ds + merge4 [] bs cs ds = merge3 bs cs ds + merge4 as [] cs ds = merge3 as cs ds + + merge4X x as bs cs@(c:cs') ds@(d:ds') + | c `gt` d = merge4XY x as bs d cs ds' + | otherwise = merge4XY x as bs c cs' ds + merge4X x as bs [] ds = merge3X x as bs ds + merge4X x as bs cs [] = merge3X x as bs cs + + merge4Y as@(a:as') bs@(b:bs') y cs ds + | a `gt` b = merge4XY b as bs' y cs ds + | otherwise = merge4XY a as' bs y cs ds + merge4Y as [] y cs ds = merge3Y as y cs ds + merge4Y [] bs y cs ds = merge3Y bs y cs ds + + merge4XY x as bs y cs ds + | x `gt` y = y : merge4X x as bs cs ds + | otherwise = x : merge4Y as bs y cs ds {- sortBy cmp l = mergesort cmp l ===================================== testsuite/tests/lib/base/Sort.hs ===================================== @@ -0,0 +1,18 @@ +module Main where + +import Data.List (sort) +import Data.Semigroup (Arg(..)) + +main :: IO () +main = do + -- correctness + test @Int [] + test [0] + test [8, 0, 2, 3, 6, 1, 5, 10, 4, 7, 9] + + -- stability + test [Arg 1 0, Arg 0 0, Arg 0 1, Arg 1 1, Arg 0 2] + test [Arg 0 0, Arg 0 1, Arg 0 2] + +test :: (Ord a, Show a) => [a] -> IO () +test = print . sort ===================================== testsuite/tests/lib/base/Sort.stdout ===================================== @@ -0,0 +1,5 @@ +[] +[0] +[0,1,2,3,4,5,6,7,8,9,10] +[Arg 0 0,Arg 0 1,Arg 0 2,Arg 1 0,Arg 1 1] +[Arg 0 0,Arg 0 1,Arg 0 2] ===================================== testsuite/tests/lib/base/all.T ===================================== @@ -11,3 +11,4 @@ test('Monoid_ByteArray', normal, compile_and_run, ['']) test('Unsnoc', normal, compile_and_run, ['']) test('First-Semigroup-sconcat', normal, compile_and_run, ['']) test('First-Monoid-sconcat', normal, compile_and_run, ['']) +test('Sort', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e435951b566b8b1a1a06704e140662290f1818c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e435951b566b8b1a1a06704e140662290f1818c You're receiving 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 Mar 30 10:27:22 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Sat, 30 Mar 2024 06:27:22 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <6607e90a25fc5_1f208d67758c960d@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: fb70cedd by Jade at 2024-03-30T11:31:55+01:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the 'haType' of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the 'haType' of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -625,7 +626,7 @@ hPutcBuffered handle_ at Handle__{..} c = do -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -633,6 +634,8 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors as 'hPutStr' hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1179,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- @hdlType@ is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- @hdlType@ is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- @hdlType@ is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- @hdlType@ is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,89 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + -stdin :: Handle -stdin = POSIX.stdin Win.stdin +-- | 'stdin' is a handle managing the programs standard input. +stdin :: Handle +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle -stdout = POSIX.stdout Win.stdout +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle + +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle + +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r + +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +openFileBlocking :: FilePath -> IOMode -> IO Handle +withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r + +#if defined(mingw32_HOST_OS) +stdin = POSIX.stdin Win.stdin +stdout = POSIX.stdout Win.stdout stderr = POSIX.stderr Win.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile Win.openFile - -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle +stdin = POSIX.stdin stdout = POSIX.stdout - -stderr :: Handle stderr = POSIX.stderr -openFile :: FilePath -> IOMode -> IO Handle openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile -openBinaryFile :: FilePath -> IOMode -> IO Handle openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile = POSIX.withBinaryFile -openFileBlocking :: FilePath -> IOMode -> IO Handle openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,48 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutStr'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors as 'putStr'. putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +308,242 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors as 'putStrLn'. +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will invoke 'show' and cause strings to be printed +-- with quotation marks and non-ascii symbols escaped. +-- +-- >>> print "λ :D" +-- "\995 :D" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). +-- +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 -- -- @since base-4.15.0.0 - getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- >>> take 5 <$> readFile "/dev/zero" +-- "\NUL\NUL\NUL\NUL\NUL" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. +-- +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. -- -- @since base-4.15.0.0 - readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'GHC.Internal.System.IO.Error.isUserError' if there is no unambiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,7 +552,7 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by -- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. @@ -393,21 +565,22 @@ localeEncoding = initLocaleEncoding -- This operation may fail with: -- -- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +588,11 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +640,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some @@ -516,7 +690,7 @@ openTempFile' loc tmp_dir template binary mode -- Otherwise, something is wrong, because (break (== '.')) should -- always return a pair with either the empty string or a string -- beginning with '.' as the second component. - _ -> errorWithoutStackTrace "bug in GHC.Internal.System.IO.openTempFile" + _ -> errorWithoutStackTrace "bug in System.IO.openTempFile" #if defined(mingw32_HOST_OS) findTempName = findTempNamePosix findTempNameWinIO View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb70cedda4dccf222dcb57c541bffe38a15e5f8d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb70cedda4dccf222dcb57c541bffe38a15e5f8d You're receiving 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 Mar 30 12:32:25 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 30 Mar 2024 08:32:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] EPA: Extend StringLiteral range to include trailing commas Message-ID: <660806595e5ff_15b10e1ecc104906e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5278cd2c by Alan Zimmerman at 2024-03-30T08:32:09-04:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - 2 changed files: - compiler/GHC/Parser.y - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4559,7 +4559,8 @@ addTrailingCommaN (L anns a) span = do return (L anns' a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral -addTrailingCommaS (L l sl) span = L l (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) +addTrailingCommaS (L l sl) span + = L (widenSpan l [AddEpAnn AnnComma span]) (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) -- ------------------------------------- ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -652,6 +652,10 @@ printSourceText :: (Monad m, Monoid w) => SourceText -> String -> EP w m () printSourceText (NoSourceText) txt = printStringAdvance txt >> return () printSourceText (SourceText txt) _ = printStringAdvance (unpackFS txt) >> return () +printSourceTextAA :: (Monad m, Monoid w) => SourceText -> String -> EP w m () +printSourceTextAA (NoSourceText) txt = printStringAtAA (EpaDelta (SameLine 0) []) txt >> return () +printSourceTextAA (SourceText txt) _ = printStringAtAA (EpaDelta (SameLine 0) []) (unpackFS txt) >> return () + -- --------------------------------------------------------------------- printStringAtSs :: (Monad m, Monoid w) => SrcSpan -> String -> EP w m () @@ -2099,7 +2103,7 @@ instance ExactPrint StringLiteral where setAnnotationAnchor a _ _ _ = a exact l@(StringLiteral src fs mcomma) = do - printSourceText src (show (unpackFS fs)) + printSourceTextAA src (show (unpackFS fs)) mapM_ (\r -> printStringAtRs r ",") mcomma return l View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5278cd2c39d550a7ba11fe5f7c8aa40339e28430 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5278cd2c39d550a7ba11fe5f7c8aa40339e28430 You're receiving 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 Mar 31 14:16:19 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Sun, 31 Mar 2024 10:16:19 -0400 Subject: [Git][ghc/ghc][wip/three-way-merge-sort] Add four way merge to Data.List.sort(By) Message-ID: <660970331ce89_f35102af6b4c72699@gitlab.mail> Jade pushed to branch wip/three-way-merge-sort at Glasgow Haskell Compiler / GHC Commits: d7b033d2 by Jade at 2024-03-31T16:20:51+02:00 Add four way merge to Data.List.sort(By) This patch aims to implement an improved version of Data.List.sortBy and therefore Data.List.sort which increases performance by up to 20% on larger lists, but also ~10% on lists of size 100 and smaller. This approach implements a four-way merge which also reuses comparisons. Fixes #24280 ------------------------- Metric Decrease: MultiLayerModulesTH_Make T10421 T13719 T15164 T18698a T18698b T1969 T9872a T9961 WWRec ------------------------- - - - - - 4 changed files: - libraries/ghc-internal/src/GHC/Internal/Data/OldList.hs - + testsuite/tests/lib/base/Sort.hs - + testsuite/tests/lib/base/Sort.stdout - testsuite/tests/lib/base/all.T Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/Data/OldList.hs ===================================== @@ -1640,37 +1640,99 @@ and possibly to bear similarities to a 1982 paper by Richard O'Keefe: Benchmarks show it to be often 2x the speed of the previous implementation. Fixes ticket https://gitlab.haskell.org/ghc/ghc/issues/2143 + +Further improved using a four-way merge, with an additional performance increase of ~20% +https://gitlab.haskell.org/ghc/ghc/issues/24280 -} -sort = sortBy compare -sortBy cmp = mergeAll . sequences +{-# INLINEABLE sort #-} +sort = actualSort (>) + +{-# INLINEABLE sortBy #-} +sortBy cmp = actualSort (\x y -> cmp x y == GT) + +{-# INLINE actualSort #-} +actualSort :: (a -> a -> Bool) -> [a] -> [a] +actualSort gt ns + | [] <- ns = [] + | [a] <- ns = [a] + | [a,b] <- ns = merge [a] [b] + | [a,b,c] <- ns = merge3 [a] [b] [c] + | [a,b,c,d] <- ns = merge4 [a] [b] [c] [d] + | otherwise = merge_all (sequences ns) where sequences (a:b:xs) - | a `cmp` b == GT = descending b [a] xs - | otherwise = ascending b (a:) xs + | a `gt` b = descending b [a] xs + | otherwise = ascending b (a:) xs sequences xs = [xs] descending a as (b:bs) - | a `cmp` b == GT = descending b (a:as) bs - descending a as bs = (a:as): sequences bs + | a `gt` b = descending b (a:as) bs + descending a as bs = (a:as) : sequences bs ascending a as (b:bs) - | a `cmp` b /= GT = ascending b (\ys -> as (a:ys)) bs - ascending a as bs = let !x = as [a] - in x : sequences bs - - mergeAll [x] = x - mergeAll xs = mergeAll (mergePairs xs) - - mergePairs (a:b:xs) = let !x = merge a b - in x : mergePairs xs - mergePairs xs = xs + | not (a `gt` b) = ascending b (\ys -> as (a:ys)) bs + ascending a as bs = let !x = as [a] + in x : sequences bs + + merge_all [x] = x + merge_all xs = merge_all (reduce_once xs) + + reduce_once [] = [] + reduce_once [a] = [a] + reduce_once [a,b] = [merge a b] + reduce_once [a,b,c] = [merge3 a b c] + reduce_once [a,b,c,d,e] = [merge a b, merge3 c d e] + reduce_once [a,b,c,d,e,f] = [merge3 a b c, merge3 d e f] + reduce_once (a:b:c:d:xs) = let !x = merge4 a b c d + in x : reduce_once xs merge as@(a:as') bs@(b:bs') - | a `cmp` b == GT = b:merge as bs' - | otherwise = a:merge as' bs - merge [] bs = bs - merge as [] = as + | a `gt` b = b : merge as bs' + | otherwise = a : merge as' bs + merge [] bs = bs + merge as [] = as + + -- `merge3` is a manually fused version of `merge (merge as bs) cs` + merge3 as@(a:as') bs@(b:bs') cs + | a `gt` b = merge3X b as bs' cs + | otherwise = merge3X a as' bs cs + merge3 [] bs cs = merge bs cs + merge3 as [] cs = merge as cs + + merge3X x as bs cs@(c:cs') + | x `gt` c = c : merge3X x as bs cs' + | otherwise = x : merge3 as bs cs + merge3X x as bs [] = x : merge as bs + + merge3Y as@(a:as') y bs cs + | a `gt` y = y : merge3 as bs cs + | otherwise = a : merge3Y as' y bs cs + merge3Y [] x bs cs = x : merge bs cs + + -- `merge4 as bs cs ds` is (essentially) a manually fused version of + -- `merge (merge as bs) (merge cs ds)` + merge4 as@(a:as') bs@(b:bs') cs ds + | a `gt` b = merge4X b as bs' cs ds + | otherwise = merge4X a as' bs cs ds + merge4 [] bs cs ds = merge3 bs cs ds + merge4 as [] cs ds = merge3 as cs ds + + merge4X x as bs cs@(c:cs') ds@(d:ds') + | c `gt` d = merge4XY x as bs d cs ds' + | otherwise = merge4XY x as bs c cs' ds + merge4X x as bs [] ds = merge3X x as bs ds + merge4X x as bs cs [] = merge3X x as bs cs + + merge4Y as@(a:as') bs@(b:bs') y cs ds + | a `gt` b = merge4XY b as bs' y cs ds + | otherwise = merge4XY a as' bs y cs ds + merge4Y as [] y cs ds = merge3Y as y cs ds + merge4Y [] bs y cs ds = merge3Y bs y cs ds + + merge4XY x as bs y cs ds + | x `gt` y = y : merge4X x as bs cs ds + | otherwise = x : merge4Y as bs y cs ds {- sortBy cmp l = mergesort cmp l ===================================== testsuite/tests/lib/base/Sort.hs ===================================== @@ -0,0 +1,18 @@ +module Main where + +import Data.List (sort) +import Data.Semigroup (Arg(..)) + +main :: IO () +main = do + -- correctness + test @Int [] + test [0] + test [8, 0, 2, 3, 6, 1, 5, 10, 4, 7, 9] + + -- stability + test [Arg 1 0, Arg 0 0, Arg 0 1, Arg 1 1, Arg 0 2] + test [Arg 0 0, Arg 0 1, Arg 0 2] + +test :: (Ord a, Show a) => [a] -> IO () +test = print . sort ===================================== testsuite/tests/lib/base/Sort.stdout ===================================== @@ -0,0 +1,5 @@ +[] +[0] +[0,1,2,3,4,5,6,7,8,9,10] +[Arg 0 0,Arg 0 1,Arg 0 2,Arg 1 0,Arg 1 1] +[Arg 0 0,Arg 0 1,Arg 0 2] ===================================== testsuite/tests/lib/base/all.T ===================================== @@ -11,3 +11,4 @@ test('Monoid_ByteArray', normal, compile_and_run, ['']) test('Unsnoc', normal, compile_and_run, ['']) test('First-Semigroup-sconcat', normal, compile_and_run, ['']) test('First-Monoid-sconcat', normal, compile_and_run, ['']) +test('Sort', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d7b033d2d1095d6cadf94a71aba3827039120021 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d7b033d2d1095d6cadf94a71aba3827039120021 You're receiving 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 Mar 31 15:25:24 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 31 Mar 2024 11:25:24 -0400 Subject: [Git][ghc/ghc][wip/T23782] Introduce 'headStrictMap' for use in derived instances Message-ID: <6609806481b62_255d12504d44254f7@gitlab.mail> Matthew Craven pushed to branch wip/T23782 at Glasgow Haskell Compiler / GHC Commits: e2b56c2d by Matthew Craven at 2024-03-31T11:24:15-04:00 Introduce 'headStrictMap' for use in derived instances Fixes #23782. - - - - - 3 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Tc/Deriv/Generate.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -351,7 +351,7 @@ basicKnownKeyNames getFieldName, setFieldName, -- List operations - concatName, filterName, mapName, + concatName, filterName, mapName, headStrictMapName, zipName, foldrName, buildName, augmentName, appendName, -- FFI primitive types that are not wired-in. @@ -739,8 +739,9 @@ ltTag_RDR = nameRdrName ordLTDataConName eqTag_RDR = nameRdrName ordEQDataConName gtTag_RDR = nameRdrName ordGTDataConName -map_RDR, append_RDR :: RdrName +map_RDR, headStrictMap_RDR, append_RDR :: RdrName map_RDR = nameRdrName mapName +headStrictMap_RDR = nameRdrName headStrictMapName append_RDR = nameRdrName appendName foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR @@ -1120,7 +1121,7 @@ considerAccessibleName = varQual gHC_INTERNAL_EXTS (fsLit "considerAccessible") -- Random GHC.Internal.Base functions fromStringName, otherwiseIdName, foldrName, buildName, augmentName, - mapName, appendName, assertName, + mapName, headStrictMapName, appendName, assertName, dollarName :: Name dollarName = varQual gHC_INTERNAL_BASE (fsLit "$") dollarIdKey otherwiseIdName = varQual gHC_INTERNAL_BASE (fsLit "otherwise") otherwiseIdKey @@ -1128,6 +1129,7 @@ foldrName = varQual gHC_INTERNAL_BASE (fsLit "foldr") foldrIdKey buildName = varQual gHC_INTERNAL_BASE (fsLit "build") buildIdKey augmentName = varQual gHC_INTERNAL_BASE (fsLit "augment") augmentIdKey mapName = varQual gHC_INTERNAL_BASE (fsLit "map") mapIdKey +headStrictMapName = varQual gHC_INTERNAL_BASE (fsLit "headStrictMap") headStrictMapIdKey appendName = varQual gHC_INTERNAL_BASE (fsLit "++") appendIdKey assertName = varQual gHC_INTERNAL_BASE (fsLit "assert") assertIdKey fromStringName = varQual gHC_INTERNAL_DATA_STRING (fsLit "fromString") fromStringClassOpKey @@ -2390,8 +2392,10 @@ inlineIdKey, noinlineIdKey, noinlineConstraintIdKey :: Unique inlineIdKey = mkPreludeMiscIdUnique 120 -- see below -mapIdKey, dollarIdKey, coercionTokenIdKey, considerAccessibleIdKey :: Unique +mapIdKey, headStrictMapIdKey, dollarIdKey, + coercionTokenIdKey, considerAccessibleIdKey :: Unique mapIdKey = mkPreludeMiscIdUnique 121 +headStrictMapIdKey = mkPreludeMiscIdUnique 122 dollarIdKey = mkPreludeMiscIdUnique 123 coercionTokenIdKey = mkPreludeMiscIdUnique 124 considerAccessibleIdKey = mkPreludeMiscIdUnique 125 ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -710,7 +710,7 @@ gen_Enum_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do enum_from tag2con_RDR maxtag_RDR = mkSimpleGeneratedFunBind loc enumFrom_RDR [mkVisPat a_Pat] $ untag_Expr [(a_RDR, ah_RDR)] $ - nlHsApps map_RDR + nlHsApps headStrictMap_RDR [nlHsVar tag2con_RDR, nlHsPar (enum_from_to_Expr (nlHsVarApps intDataCon_RDR [ah_RDR]) @@ -719,7 +719,7 @@ gen_Enum_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do enum_from_then tag2con_RDR maxtag_RDR = mkSimpleGeneratedFunBind loc enumFromThen_RDR (map mkVisPat [a_Pat, b_Pat]) $ untag_Expr [(a_RDR, ah_RDR), (b_RDR, bh_RDR)] $ - nlHsApp (nlHsVarApps map_RDR [tag2con_RDR]) $ + nlHsApp (nlHsVarApps headStrictMap_RDR [tag2con_RDR]) $ nlHsPar (enum_from_then_to_Expr (nlHsVarApps intDataCon_RDR [ah_RDR]) (nlHsVarApps intDataCon_RDR [bh_RDR]) @@ -852,7 +852,7 @@ gen_Ix_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do = mkSimpleGeneratedFunBind loc range_RDR [mkVisPat $ nlTuplePat [a_Pat, b_Pat] Boxed] $ untag_Expr [(a_RDR, ah_RDR)] $ untag_Expr [(b_RDR, bh_RDR)] $ - nlHsApp (nlHsVarApps map_RDR [tag2con_RDR]) $ + nlHsApp (nlHsVarApps headStrictMap_RDR [tag2con_RDR]) $ nlHsPar (enum_from_to_Expr (nlHsVarApps intDataCon_RDR [ah_RDR]) (nlHsVarApps intDataCon_RDR [bh_RDR])) ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -1882,7 +1882,7 @@ augment g xs = g (:) xs map :: (a -> b) -> [a] -> [b] {-# NOINLINE [0] map #-} -- We want the RULEs "map" and "map/coerce" to fire first. - -- map is recursive, so won't inline anyway, + -- map is recursive, so it won't inline anyway, -- but saying so is more explicit, and silences warnings map _ [] = [] map f (x:xs) = f x : map f xs @@ -1913,7 +1913,7 @@ The rules for map work like this. See also Note [Inline FB functions] in GHC.Internal.List -* The "mapFB" rule optimises compositions of map +* The "mapFB/mapFB" rule optimises compositions of map * The "mapFB/id" rule gets rid of 'map id' calls. You might think that (mapFB c id) will turn into c simply @@ -1930,7 +1930,7 @@ The rules for map work like this. {-# RULES "map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs) "mapList" [1] forall f. foldr (mapFB (:) f) [] = map f -"mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f.g) +"mapFB/mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f.g) "mapFB/id" forall c. mapFB c (\x -> x) = c #-} @@ -1941,6 +1941,103 @@ The rules for map work like this. {-# RULES "map/coerce" [1] map coerce = coerce #-} -- See Note [Getting the map/coerce RULE to work] in GHC.Core.SimpleOpt +-- | Less lazy variant of 'map' that evaluates each /result/ list +-- element to weak head normal form when it produces the corresponding +-- cons cell. +headStrictMap :: (a -> b) -> [a] -> [b] +{-# NOINLINE [0] headStrictMap #-} +-- See Note [The rules for map]. +-- headStrictMap is recursive, so it won't inline anyway, +-- but saying so is more explicit, and silences warnings +headStrictMap _ [] = [] +headStrictMap f (x:xs) = case f x of + !y -> y : headStrictMap f xs + +headStrictMapFB :: (elt -> lst -> lst) -> (a -> elt) -> a -> lst -> lst +{-# INLINE [0] headStrictMapFB #-} +-- See Note [Inline FB functions] in GHC.Internal.List +headStrictMapFB c f = \x ys -> case f x of + !y -> c y ys + +partiallyHeadStrictMap :: (a -> (# b #)) -> [a] -> [b] +{-# NOINLINE [0] partiallyHeadStrictMap #-} +-- See Note [The rules for map]. +-- partiallyHeadStrictMap is recursive, so it won't inline anyway, +-- but saying so is more explicit, and silences warnings +partiallyHeadStrictMap f li = case li of + [] -> [] + x : xs -> case f x of + (# y #) -> y : partiallyHeadStrictMap f xs + +partiallyHeadStrictMapFB :: (elt -> lst -> lst) -> (a -> (# elt #)) -> a -> lst -> lst +{-# INLINE [0] partiallyHeadStrictMapFB #-} +-- See Note [Inline FB functions] in GHC.Internal.List +partiallyHeadStrictMapFB c f = \x ys -> case f x of + (# y #) -> c y ys + +-- See Note [The rules for map]. +{-# RULES +"headStrictMap" [~1] + forall f xs. + headStrictMap f xs + = build (\c n -> foldr (headStrictMapFB c f) n xs) +"headStrictMapList" [1] + forall f. + foldr (headStrictMapFB (:) f) [] + = headStrictMap f + +"partiallyHeadStrictMap" [~1] + forall f xs. + partiallyHeadStrictMap f xs + = build (\c n -> foldr (partiallyHeadStrictMapFB c f) n xs) +"partiallyHeadStrictMapList" [1] + forall f. + foldr (partiallyHeadStrictMapFB (:) f) [] + = partiallyHeadStrictMap f + + +"headStrictMapFB/headStrictMapFB" + forall c f g. + headStrictMapFB (headStrictMapFB c f) g + = headStrictMapFB c (\x -> f $! g x) +"headStrictMapFB/partiallyHeadStrictMapFB" + forall c f g. + partiallyHeadStrictMapFB (headStrictMapFB c f) g + = headStrictMapFB c (\x -> case g x of (# y #) -> f y) +"headStrictMapFB/mapFB" + forall c f g. + mapFB (headStrictMapFB c f) g + = headStrictMapFB c (\x -> f (g x)) + +"partiallyHeadStrictMapFB/headStrictMapFB" + forall c f g. + headStrictMapFB (partiallyHeadStrictMapFB c f) g + = partiallyHeadStrictMapFB c (\x -> f $! g x) +"partiallyHeadStrictMapFB/partiallyHeadStrictMapFB" + forall c f g. + partiallyHeadStrictMapFB (partiallyHeadStrictMapFB c f) g + = partiallyHeadStrictMapFB c (\x -> case g x of (# y #) -> f y) +"partiallyHeadStrictMapFB/mapFB" + forall c f g. + mapFB (partiallyHeadStrictMapFB c f) g + = partiallyHeadStrictMapFB c (\x -> f (g x)) + +"mapFB/headStrictMapFB" + forall c f g. + headStrictMapFB (mapFB c f) g + = partiallyHeadStrictMapFB c (\x -> case g x of !y -> (# f y #)) +"mapFB/partiallyHeadStrictMapFB" + forall c f g. + partiallyHeadStrictMapFB (mapFB c f) g + = partiallyHeadStrictMapFB c (\x -> case g x of (# y #) -> (# f y #)) +-- "mapFB/mapFB" rule is above + + +"lazy partiallyHeadStrictMapFB" + forall c f. + partiallyHeadStrictMapFB c (\x -> (# f x #)) + = mapFB c f + #-} ---------------------------------------------- -- append ---------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e2b56c2dd28e5a5eb3583821d2492cfb71688a13 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e2b56c2dd28e5a5eb3583821d2492cfb71688a13 You're receiving 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 Mar 31 16:17:01 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 31 Mar 2024 12:17:01 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 3 commits: Simplifier improvements Message-ID: <66098c7d9db22_255d12ad92d830397@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 3a588ca2 by Simon Peyton Jones at 2024-03-31T17:16:53+01:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.1% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -4.0% PmSeriesV(normal) -1.7% T11195(normal) -1.3% T12227(normal) -20.5% GOOD T12545(normal) -3.2% T12707(normal) -2.2% GOOD T13253(normal) -1.5% T13253-spj(normal) +8.1% BAD T13386(normal) -3.0% GOOD T14766(normal) -2.7% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15703(normal) -14.8% GOOD T16577(normal) -2.3% GOOD T16875(normal) -0.1% T17516(normal) -39.7% GOOD T18140(normal) +1.1% T18223(normal) -17.2% GOOD T18282(normal) -5.1% GOOD T18304(normal) +10.8% BAD T18923(normal) -3.0% GOOD T19695(normal) -1.5% T20049(normal) -12.8% GOOD T21839c(normal) -4.3% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.9% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.8% GOOD T9961(normal) +1.8% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.4% parsing001(normal) +1.4% geo. mean -2.1% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T3294 T9961 - - - - - a1c54ec8 by Simon Peyton Jones at 2024-03-31T17:16:53+01:00 Testsuite message changes from simplifier improvements - - - - - 6483e76a by Simon Peyton Jones at 2024-03-31T17:16:53+01:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 23 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Tickish.hs - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity09.stderr - testsuite/tests/arityanal/should_compile/Arity13.stderr - testsuite/tests/cpranal/should_compile/T18401.stderr - testsuite/tests/driver/inline-check.stderr - testsuite/tests/lib/integer/Makefile - testsuite/tests/numeric/should_compile/T19641.stderr - testsuite/tests/perf/compiler/T15630.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2af315023efb666745717a856aa07a66865fbe3...6483e76a896546107d6323c9d43d9c63af3bf08b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2af315023efb666745717a856aa07a66865fbe3...6483e76a896546107d6323c9d43d9c63af3bf08b You're receiving 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 Mar 31 19:02:47 2024 From: gitlab at gitlab.haskell.org (Brandon S. Allbery (@geekosaur)) Date: Sun, 31 Mar 2024 15:02:47 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/geekosaur/clarify-cpp-note Message-ID: <6609b357913b5_255d121c11b1838625@gitlab.mail> Brandon S. Allbery pushed new branch wip/geekosaur/clarify-cpp-note at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/geekosaur/clarify-cpp-note You're receiving 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 Mar 31 21:33:30 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 31 Mar 2024 17:33:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: EPA: Extend StringLiteral range to include trailing commas Message-ID: <6609d6aa573aa_255d122c263c847691@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - f9884f01 by brandon s allbery kf8nh at 2024-03-31T17:33:20-04:00 clarify Note [Preproccesing invocations] - - - - - 3 changed files: - compiler/GHC/Parser.y - compiler/GHC/SysTools/Cpp.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4559,7 +4559,8 @@ addTrailingCommaN (L anns a) span = do return (L anns' a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral -addTrailingCommaS (L l sl) span = L l (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) +addTrailingCommaS (L l sl) span + = L (widenSpan l [AddEpAnn AnnComma span]) (sl { sl_tc = Just (epaLocationRealSrcSpan span) }) -- ------------------------------------- ===================================== compiler/GHC/SysTools/Cpp.hs ===================================== @@ -63,7 +63,22 @@ underlying program (the C compiler), the set of flags passed determines the behaviour of the preprocessor, and Cpp and HsCpp behave differently. Specifically, we rely on "traditional" (pre-standard) preprocessing semantics (which most compilers expose via the `-traditional` flag) when preprocessing -Haskell source. This avoids, e.g., the preprocessor removing C-style comments. +Haskell source. This avoids the following situations: + + * Removal of C-style comments, which are not comments in Haskell but valid + operators; + + * Errors due to an ANSI C preprocessor lexing the source and failing on + names with single quotes (TH quotes, ticked promoted constructors, + names with primes in them). + + Both of those cases may be subtle: gcc and clang permit C++-style // + comments in C code, and Data.Array and Data.Vector both export a // + operator whose type is such that a removed "comment" may leave code that + typechecks but does the wrong thing. Another example is that, since ANSI + C permits long character constants, an expression involving multiple + functions with primes in their names may not expand macros properly when + they occur between the primed functions. -} -- | Run either the Haskell preprocessor or the C preprocessor, as per the ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -652,6 +652,10 @@ printSourceText :: (Monad m, Monoid w) => SourceText -> String -> EP w m () printSourceText (NoSourceText) txt = printStringAdvance txt >> return () printSourceText (SourceText txt) _ = printStringAdvance (unpackFS txt) >> return () +printSourceTextAA :: (Monad m, Monoid w) => SourceText -> String -> EP w m () +printSourceTextAA (NoSourceText) txt = printStringAtAA (EpaDelta (SameLine 0) []) txt >> return () +printSourceTextAA (SourceText txt) _ = printStringAtAA (EpaDelta (SameLine 0) []) (unpackFS txt) >> return () + -- --------------------------------------------------------------------- printStringAtSs :: (Monad m, Monoid w) => SrcSpan -> String -> EP w m () @@ -2099,7 +2103,7 @@ instance ExactPrint StringLiteral where setAnnotationAnchor a _ _ _ = a exact l@(StringLiteral src fs mcomma) = do - printSourceText src (show (unpackFS fs)) + printSourceTextAA src (show (unpackFS fs)) mapM_ (\r -> printStringAtRs r ",") mcomma return l View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5278cd2c39d550a7ba11fe5f7c8aa40339e28430...f9884f016e07e78aff67a38786c45a536621a20e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5278cd2c39d550a7ba11fe5f7c8aa40339e28430...f9884f016e07e78aff67a38786c45a536621a20e You're receiving 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 Mar 31 23:36:08 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 31 Mar 2024 19:36:08 -0400 Subject: [Git][ghc/ghc][wip/T23490-part2] 253 commits: Improve Monad, Functor & Applicative docs Message-ID: <6609f368c60c3_23d148374a4c17558@gitlab.mail> Matthew Craven pushed to branch wip/T23490-part2 at Glasgow Haskell Compiler / GHC Commits: 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 7b5e0d83 by Matthew Craven at 2024-03-31T19:27:48-04:00 Add missing images to transformers submodule - - - - - f94bfe49 by Matthew Craven at 2024-03-31T19:31:42-04:00 Repair the 'build-cabal' hadrian target Fixes #23117, fixes #23281, fixes #23490 - - - - - 5c9605b4 by Matthew Craven at 2024-03-31T19:33:50-04:00 Revert "CI: Disable the test-cabal-reinstall job" This reverts commit 38c3afb64d3ffc42f12163c6f0f0d5c414aa8255. - - - - - 21 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - CODEOWNERS - cabal.project-reinstall - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c315014cd0abc42646bf6ef61bbeb6ed9551a07...5c9605b495f434529eecb5e7befd851bdd4e9f6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c315014cd0abc42646bf6ef61bbeb6ed9551a07...5c9605b495f434529eecb5e7befd851bdd4e9f6e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: